Skip to content

Instantly share code, notes, and snippets.

@dgfitch
Created September 17, 2009 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgfitch/188724 to your computer and use it in GitHub Desktop.
Save dgfitch/188724 to your computer and use it in GitHub Desktop.
let map2zero (f: float -> float -> 'a) (s1: float list) (s2: float list) =
let rec take xs ys result =
match xs, ys with
| [], [] -> result
| x::xs', [] -> (f x 0.0) :: take xs' [] result
| [], y::ys' -> (f 0.0 y) :: take [] ys' result
| x::xs', y::ys' -> (f x y) :: take xs' ys' result
take s1 s2 []
let a = [4.0;3.0;6.0;1.5]
let b = [1.2;2.9]
let floats = map2zero (fun x y -> x - y) a b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment