Last active
December 10, 2015 05:08
-
-
Save akanehara/4385309 to your computer and use it in GitHub Desktop.
「fold書けないプログラマー」と聞いてドキっとしたので書いて確かめて気を落ち着かせる
This file contains hidden or 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 foldl f z xs = | |
let rec go acc xs = | |
match xs with | |
| [] -> acc | |
| x :: xs -> go (f acc x) xs | |
in go z xs;; | |
let foldr f z xs = | |
let rec go xs = | |
match xs with | |
| [] -> z | |
| (x :: rest) -> f x (go rest) | |
in go xs;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment