Exit immediately when list is empty

This commit is contained in:
Vladan Popovic 2020-06-17 20:24:25 +02:00
parent 98d37ebf50
commit 21f5bd27ed
1 changed files with 1 additions and 1 deletions

View File

@ -31,7 +31,7 @@ let () = assert (syr 3 = 7)
let rec next_nacci n l sum =
if n = 0 then sum
else match l with
| [] -> next_nacci (n - 1) [] sum
| [] -> sum
| h :: t -> next_nacci (n - 1) t (sum + h)
let nacci n k =