fix: Reordered to_list_loop parameter order

This commit is contained in:
2025-10-17 23:29:32 +01:00
parent 8a01142ad7
commit 34d4bf1055

View File

@@ -237,18 +237,18 @@ pub fn to_list(list: DLList(a)) -> List(a) {
True -> [] True -> []
False -> { False -> {
let assert Ok(a) = get(list) let assert Ok(a) = get(list)
[a, ..to_list_loop(list.current, do_move_right(list))] [a, ..to_list_loop(do_move_right(list), list.current)]
} }
} }
} }
fn to_list_loop(ref: Int, list: Result(DLList(a), Nil)) -> List(a) { fn to_list_loop(list: Result(DLList(a), Nil), start_ref: Int) -> List(a) {
case list { case list {
Error(_) -> [] Error(_) -> []
Ok(DLList(_, current, _)) if current == ref -> [] Ok(DLList(_, current, _)) if current == start_ref -> []
Ok(list) -> { Ok(list) -> {
let assert Ok(a) = get(list) let assert Ok(a) = get(list)
[a, ..to_list_loop(ref, do_move_right(list))] [a, ..to_list_loop(do_move_right(list), start_ref)]
} }
} }
} }