Closed MikalaiLappo closed 2 weeks ago
Sample code:
func toLinkedList(arr) { if len(arr) == 0 { nil } else { { "value": first(arr), "next": toLinkedList(rest(arr)) } } } func reverseLinkedList(list, acc) { if list == nil { acc // <- missing return statement } // the call overlooked by max recursion check // (hangs forever without a symptom) reverseLinkedList(list.next, { "value": list.value, "next": acc }) } ll = toLinkedList(1 : 5) println(reverseLinkedList(ll, nil))
fixed (more generally) in #198
Sample code: