Skip to content

Instantly share code, notes, and snippets.

@OdaShinsuke
Created April 10, 2012 09:29
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 OdaShinsuke/2349771 to your computer and use it in GitHub Desktop.
Save OdaShinsuke/2349771 to your computer and use it in GitHub Desktop.
WEB+DB PRESS Vol.67 第2章 F#
let ret1 = List.zip [0..4] [10;20;30;40;50];;
let mul (i, x) = x * i;;
let ret2 = List.map mul ret1;;
let calc xs = List.fold (fun acc value -> acc + value) 0 (List.map mul (List.zip [0..4] xs));;
calc [10;20;30;40;50];;
List.zip [10;20;30;40;50] [0..4]
|> List.map (fun x -> fst x * snd x)
|> List.fold (fun acc value -> acc + value) 0;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment