mirror of
https://github.com/anoma/juvix.git
synced 2024-11-30 05:42:26 +03:00
8f180ccfda
* Updates the standard library to https://github.com/anoma/juvix-stdlib/pull/130 * Also changes `null` to `isEmpty`, which required updating some tests --------- Co-authored-by: Paul Cadman <git@paulcadman.dev>
21 lines
420 B
Plaintext
21 lines
420 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 (isEmpty lst) 1 0
|
|
+ ite (isEmpty (nil {Nat})) 1 0
|
|
+ head 1 lst
|
|
+ head 0 (tail lst)
|
|
+ head 0 (tail (map ((+) 1) lst))
|
|
+ head 0 (tail (map' ((+) 1) lst));
|