Skip to content

Commit

Permalink
Merge pull request #45 from pd4d10/patch-1
Browse files Browse the repository at this point in the history
update with multi-arg constructor syntax
  • Loading branch information
Yu-zh authored Mar 11, 2024
2 parents 6b430ec + 66e81a8 commit c424b68
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions list/list.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -669,13 +669,13 @@ pub fn unfold[T, State](
f : (State) -> Option[(T, State)]
) -> List[T] {
match f(init) {
Some(element, new_state) => Cons(element, unfold(new_state, f))
Some((element, new_state)) => Cons(element, unfold(new_state, f))
None => Nil
}
}

test "unfold" {
let ls = unfold(0, fn { i => if i == 3 { None } else { Some(i, i + 1) } })
let ls = unfold(0, fn { i => if i == 3 { None } else { Some((i, i + 1)) } })
@assertion.assert_eq(ls, Cons(0, Cons(1, Cons(2, Nil))))?
}

Expand Down

0 comments on commit c424b68

Please sign in to comment.