vault backup: 2023-09-15 14:39:17
This commit is contained in:
@ -94,3 +94,11 @@ val add : int -> bool = <fun>
|
||||
val even : int -> bool = <fun>
|
||||
```
|
||||
|
||||
An accumulator is a thing that try to get our result. In CAML we trying to not use an accumulator in our program. In CAML the syntax for the accumulator (`inv`) is: (exemple with reverse_int exercise. See 4.9 - b)
|
||||
```Ocaml
|
||||
# let reverse_int =
|
||||
let rec rev inv = function
|
||||
| 0 -> inv
|
||||
| n -> rev (inv*10 + n mod 10)(n/10)
|
||||
in rev 0 n;;
|
||||
```
|
||||
|
Reference in New Issue
Block a user