
* Added standard List library and list comprehensions Added List library. Flatmaps WIP Fixed dependency in flat_map fcode generation Updated tests to use custom list lib Added comprehension test Added stdlib sanity Test * Extended stdlib for lists. Added error message for redefinition of stdlibx * Fixed type template * Improved stdlib * More functions * Fixed cyclic includes * Refixed imports and added few tests * Added fail test * Undelete removed type spec * Remove typo * Fix iter function * Fixed typo * Added if guards and let statements in list comp * Added more fail tests * Option stliv * 2 and 3 tuple stdlib * Updated stdlib to new syntax. Added recursor and changed all/any functions * Fixed performance issues. Changed include management * Fixed hash type
24 lines
885 B
Plaintext
24 lines
885 B
Plaintext
contract ListComp =
|
|
|
|
entrypoint sample1() = [1,2,3]
|
|
entrypoint sample2() = [4,5]
|
|
|
|
entrypoint l1() = [x | x <- sample1()]
|
|
entrypoint l1_true() = [1,2,3]
|
|
|
|
entrypoint l2() = [x + y | x <- sample1(), y <- sample2()]
|
|
entrypoint l2_true() = [5,6,6,7,7,8]
|
|
|
|
entrypoint l3() = [x ++ y | x <- [[":)"] | x <- [1,2]]
|
|
, y <- [[":("]]]
|
|
entrypoint l3_true() = [[":)", ":("], [":)", ":("]]
|
|
|
|
entrypoint l4() = [(a, b, c) | let is_pit(a, b, c) = a*a + b*b == c*c
|
|
, let base = [1,2,3,4,5,6,7,8,9,10]
|
|
, a <- base
|
|
, b <- base, if (b >= a)
|
|
, c <- base, if (c >= b)
|
|
, if (is_pit(a, b, c))
|
|
]
|
|
entrypoint l4_true() = [(3, 4, 5), (6, 8, 10)]
|