Created
May 14, 2009 07:32
-
-
Save angerman/111550 to your computer and use it in GitHub Desktop.
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 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