We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 74c8855 + 737d94f commit d8fe280Copy full SHA for d8fe280
examples/unzip.hs
@@ -0,0 +1,17 @@
1
+-- example that unzip does some work before returning the result pair
2
+
3
+-- some generator which does some work before producing the elements of a list
4
+generate = (\x -> \y ->
5
+ if le y 0 then Nil else
6
+ if le x 0 then Nil else
7
+ Cons (Pair x y) (@generate (sub x 1) (sub y 1))
8
+ )
9
10
+unzip = (\xs -> case xs of {
11
+ Nil -> Pair Nil Nil;
12
+ Cons xy xys -> case xy of {
13
+ Pair x y -> let r = @unzip xys in Pair (Cons x (fst r)) (Cons y (snd r))
14
+ }
15
+ })
16
17
+main = @unzip (@generate 1 2)
0 commit comments