Make the sample programs actually run.
This commit is contained in:
parent
c3d4ef22ce
commit
396043d801
|
@ -1,2 +0,0 @@
|
|||
data Bool = { True, False }
|
||||
data IntList = { Nil, Cons(Int, IntList) }
|
|
@ -1,6 +1,8 @@
|
|||
data IntList = { Nil, Cons(Int, IntList) }
|
||||
defn length l = {
|
||||
case l of {
|
||||
Nil -> { 0 }
|
||||
Cons(x, xs) -> { 1 + length xs }
|
||||
}
|
||||
}
|
||||
defn main = { length (Cons 1 (Cons 2 (Cons 3 (Cons 4 Nil)))) }
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
data Bool = { True, False }
|
||||
defn not b = {
|
||||
case b of {
|
||||
False -> { True }
|
||||
True -> { False }
|
||||
}
|
||||
}
|
||||
defn booli b = {
|
||||
case b of {
|
||||
False -> { 0 }
|
||||
True -> { 1 }
|
||||
}
|
||||
}
|
||||
defn main = { booli (not False) }
|
||||
|
|
8
programs/sum.lily
Normal file
8
programs/sum.lily
Normal file
|
@ -0,0 +1,8 @@
|
|||
data IntList = { Nil, Cons(Int, IntList) }
|
||||
defn sum l = {
|
||||
case l of {
|
||||
Nil -> { 0 }
|
||||
Cons(x, xs) -> { x + sum xs }
|
||||
}
|
||||
}
|
||||
defn main = { sum (Cons 1 (Cons 2 (Cons 3 (Cons 4 Nil)))) }
|
Loading…
Reference in New Issue
Block a user