1
1
mirror of https://github.com/anoma/juvix.git synced 2024-11-30 05:42:26 +03:00
juvix/tests/Rust/Compilation/positive/test007.juvix
Łukasz Czajka 8f180ccfda
Improve Set and Map modules in the standard library (#3120)
* 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>
2024-10-24 12:29:33 +01:00

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));