git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
More pattern matching tests
6d5d974Phil Freeman
README.md+3−3
@@ -435,9 +435,9 @@ The patterns above can be combined to create larger patterns.
435For example:
435For example:
436
436
437 f = \o -> case o of
437 f = \o -> case o of
438− { arr = [] } -> 0
438+ { arr = [x:_], take = "car" } -> x
439− { arr = [x:_], take = "head" } -> x
439+ { arr = [_,x:_], take = "cadr" } -> x
440− { arr = [_:xs], take = "tail" } -> sum xs
440+ _ -> 0
441
441
442## Named Patterns
442## Named Patterns
443
443
examples/passing/Patterns.ps+15
@@ -6,3 +6,18 @@ test = \x -> case x of
6f = \o -> case o of
6f = \o -> case o of
7 { foo = "Foo" } -> o.bar
7 { foo = "Foo" } -> o.bar
8 _ -> 0
8 _ -> 0
9+
10+g = \o -> case o of
11+ { arr = [x : xs], take = "car" } -> x
12+ { arr = [_, x : xs], take = "cadr" } -> x
13+ _ -> 0
14+
15+
16+h = \o -> case o of
17+ a@[_,_,_] -> a
18+ _ -> []
19+
20+isDesc = \o -> case o of
21+ [x, y] | x > y -> true
22+ _ -> false
23+