26 lines
472 B
Plaintext
26 lines
472 B
Plaintext
|
data Bool = { True, False }
|
||
|
data List = { Nil, Cons Int List }
|
||
|
|
||
|
defn if c t e = {
|
||
|
case c of {
|
||
|
True -> { t }
|
||
|
False -> { e }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
defn oddEven l e = {
|
||
|
case l of {
|
||
|
Nil -> { e }
|
||
|
Cons x xs -> { evenOdd xs e }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
defn evenOdd l e = {
|
||
|
case l of {
|
||
|
Nil -> { e }
|
||
|
Cons x xs -> { oddEven xs e }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
defn main = { if (oddEven (Cons 1 (Cons 2 (Cons 3 Nil))) True) (oddEven (Cons 1 (Cons 2 (Cons 3 Nil))) 1) 3 }
|