Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 40 lines (30 sloc) 0.967 kb
841f1c1 Basic separate compilation support
eb authored
1 include "Prelude.e"
3594b6b Added 'lazy' annotation
eb authored
2
fd64d9e Added inner lambdas (\x : Type . e) and a lambda lifter
Edwin Brady authored
3 main () -> Unit = printList(maintake(10,4))
4
5 maintake (x:Int, y:Int) -> Data
6 = zip ( \a : Any . \b : Any . y+a*2+b , take(x, ones()), take(x, testList()))
7
8 zip (f:Any, xs:Data, ys:Data) -> Data
9 = case xs of {
10 Con 0 () -> Con 0 ()
11 | Con 1 (x:Data, xs0:Data) -> case ys of {
12 Con 0 () -> Con 0 ()
13 | Con 1 (y:Data, ys0:Data) -> Con 1 (f(x,y), zip(f, xs0, ys0))
14 }
15 }
3594b6b Added 'lazy' annotation
eb authored
16
17 take (i:Int, x:Data) -> Data
18 = if (i==0) then Con 0 () else
19 case x of {
20 Con 0 () -> Con 0 ()
21 | Con 1 (y:Any,ys:Data) -> Con 1 (y, take(i-1, ys))
ba8e215 Make ; a sequencing operator rather than a separator
eb authored
22 }
3594b6b Added 'lazy' annotation
eb authored
23
24 testList () -> Data
ba8e215 Make ; a sequencing operator rather than a separator
eb authored
25 = Con 1 (1, Con 1 (2, Con 1 (3, Con 1 (4, Con 1 (5, Con 0 ())))))
3594b6b Added 'lazy' annotation
eb authored
26
27 ones () -> Data
ba8e215 Make ; a sequencing operator rather than a separator
eb authored
28 = Con 1 (1, lazy(ones)) -- needs to be lazy or it runs forever!
3594b6b Added 'lazy' annotation
eb authored
29
30 {- IO stuff -}
31
32 printList (x:Data) -> Data
33 = case x of {
b91fd59 case operator improvment
eb authored
34 Con 1 (y:Int, ys:Data) ->
7da3f0a Added small standard library
eb authored
35 putStr(append(intToStr(y),", "));
3594b6b Added 'lazy' annotation
eb authored
36 printList(ys)
b91fd59 case operator improvment
eb authored
37 | Con 0 () -> putStrLn("nil")
ba8e215 Make ; a sequencing operator rather than a separator
eb authored
38 }
3594b6b Added 'lazy' annotation
eb authored
39
Something went wrong with that request. Please try again.