Skip to content

Instantly share code, notes, and snippets.

@angerman
Created May 14, 2009 07:32
Show Gist options
  • Save angerman/111550 to your computer and use it in GitHub Desktop.
Save angerman/111550 to your computer and use it in GitHub Desktop.
let rec map f x y =
match (x,y) with
([],_) | (_,[]) -> failwith "list do not have same length"
| ([a],[b]) -> [f a b]
| (h1::t1,h2::t2) -> (f h1 h2)::(map f t1 t2)
;; (* map *)
open Printf;;
Printf.printf "%d\n" (map (fun x y -> x * y) [1;2;3;4;5] [1;2;3;4;5]);;
(* line 10, characters 21-69:
Error: This expression has type int list but is here used with type int *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment