list - How can I implement this code in ocaml? -


let rec list_add l =     match l       [] -> [i]     | h::t -> h::(list_add t i) 

list add adding each pair of integers 2 lists

(type) list add : int list -> int list -> int list

(description) list add [a; b; c; ...] [x; y; z; ...] returns [a + x; b + y; c + z; ...]. if 1 list longer other, remaining list of elements appended result.

(example) list add [1; 2] [3; 4; 5] returns [4; 6; 5].

let rec add l1 l2 = match l1     [] -> l2     |h::t -> (*you can rest*) ;; 

Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -