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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -