fix: Reordered to_list_loop parameter order
This commit is contained in:
@@ -237,18 +237,18 @@ pub fn to_list(list: DLList(a)) -> List(a) {
|
||||
True -> []
|
||||
False -> {
|
||||
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 {
|
||||
Error(_) -> []
|
||||
Ok(DLList(_, current, _)) if current == ref -> []
|
||||
Ok(DLList(_, current, _)) if current == start_ref -> []
|
||||
Ok(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)]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user