Exit immediately when list is empty
This commit is contained in:
parent
98d37ebf50
commit
21f5bd27ed
1 changed files with 1 additions and 1 deletions
|
@ -31,7 +31,7 @@ let () = assert (syr 3 = 7)
|
||||||
let rec next_nacci n l sum =
|
let rec next_nacci n l sum =
|
||||||
if n = 0 then sum
|
if n = 0 then sum
|
||||||
else match l with
|
else match l with
|
||||||
| [] -> next_nacci (n - 1) [] sum
|
| [] -> sum
|
||||||
| h :: t -> next_nacci (n - 1) t (sum + h)
|
| h :: t -> next_nacci (n - 1) t (sum + h)
|
||||||
|
|
||||||
let nacci n k =
|
let nacci n k =
|
||||||
|
|
Loading…
Add table
Reference in a new issue