mirror of
https://github.com/anoma/juvix.git
synced 2024-12-12 14:28:08 +03:00
21 lines
414 B
Plaintext
21 lines
414 B
Plaintext
-- pattern matching and lambda-case
|
|
module test007;
|
|
|
|
import Stdlib.Prelude open;
|
|
|
|
map' {A B} (f : A → B) : List A → List B :=
|
|
\ {
|
|
| nil := nil
|
|
| (h :: t) := f h :: map' f t
|
|
};
|
|
|
|
lst : List Nat := 0 :: 1 :: nil;
|
|
|
|
main : Nat :=
|
|
ite (null lst) 1 0
|
|
+ ite (null (nil {Nat})) 1 0
|
|
+ head 1 lst
|
|
+ head 0 (tail lst)
|
|
+ head 0 (tail (map ((+) 1) lst))
|
|
+ head 0 (tail (map' ((+) 1) lst));
|