Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Counts the number of instances of num in x::xs
- * for instance, (countNum ([1;1;2;3], 0, 1)) should return 2*)
- let rec countNum (lst, soFar, num) =
- match lst with
- | [] -> soFar
- | num::xs -> countNum (xs, (soFar+1), num)
- | _::xs -> countNum (xs, soFar, num);;
- (* With this implementation the above example returns 4 *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement