mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
clean up linked_list_trmc test
This commit is contained in:
parent
bb335469e0
commit
b9b486e4b0
1 changed files with 4 additions and 11 deletions
|
@ -4510,17 +4510,11 @@ fn linked_list_trmc() {
|
|||
|
||||
LinkedList a : [Nil, Cons a (LinkedList a)]
|
||||
|
||||
# map : LinkedList a, (a -> b) -> LinkedList b
|
||||
# map = \list, f ->
|
||||
# when list is
|
||||
# Nil -> Nil
|
||||
# Cons x xs -> Cons (f x) (map xs f)
|
||||
|
||||
unfold : a, Nat -> LinkedList a
|
||||
unfold = \value, n ->
|
||||
repeat : a, Nat -> LinkedList a
|
||||
repeat = \value, n ->
|
||||
when n is
|
||||
0 -> Nil
|
||||
_ -> Cons value (unfold value (n - 1))
|
||||
_ -> Cons value (repeat value (n - 1))
|
||||
|
||||
length : LinkedList a -> I64
|
||||
length = \list ->
|
||||
|
@ -4530,8 +4524,7 @@ fn linked_list_trmc() {
|
|||
|
||||
main : I64
|
||||
main =
|
||||
unfold 32 1
|
||||
# |> map (\x -> x + 1i64)
|
||||
repeat "foo" 5
|
||||
|> length
|
||||
"#
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue