-
Notifications
You must be signed in to change notification settings - Fork 3
/
prog.levy
43 lines (31 loc) · 892 Bytes
/
prog.levy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
return ( 2 + 2 ) ;
return ( 2 * 3 ) ;
return ( 2 - 4 ) ;
if 5 < 3 then return 1 else return 5 ;
if 2 = 2 then return 1 else return 5 ;
fun n : int => return ( n + 3 ) ;
fun n : int => if n < 0 then return ( 0 - n ) else return n ;
rec f : int -> F int is fun n : int =>
if n = 0 then
return 1
else
( do m <- ( ( force f ) $ ( n - 1 ) ) in return ( n * m ) ) ;
return 42 ;
let_ x = thunk ( if 3 < 5 then return 1 else return 2 ) ;
force ( thunk ( if 3 < 5 then return 1 else return 2 ) ) ;
let x = 3 + 5 in return ( x * x ) ;
do x <- return ( 3 + 5 ) in return ( x * x ) ;
let_ a = 5 ;
let_ b = 10 + a ;
let_ c = thunk ( return b ) ;
let_ fact = thunk ( rec f : int -> F int is
fun k : int =>
if k = 0
then return 1
else (
do m <- ( ( force f ) $ ( k - 1 ) ) in
return ( k * m )
)
) ;
( ( force fact ) $ 7 ) ;
force c