-
-
Save hannesm/d6f5e6451fb558450f11228f5d8e0b0e to your computer and use it in GitHub Desktop.
sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec sum xs = | |
match xs with | |
| [] -> 0 (* yield 0 if xs has the form [] *) | |
| x :: xs' -> x + sum xs';; (* recursive call if xs has the form x::xs' for suitable x and xs' *) | |
let rec sum = function | |
| [] -> 0 (* yield 0 if xs has the form [] *) | |
| x :: xs' -> x + sum xs';; (* recursive call if xs has the form x::xs' for suitable x and xs' *) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment