Created
September 20, 2012 15:30
-
-
Save rpearl/3756624 to your computer and use it in GitHub Desktop.
Getting around stupid constraints
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
(* 03:40 < Oejet> How would you implement f n = [1, ..., n], using only map, or | |
foldl? | |
*) | |
fun range n = foldl (op ::) [] ( | |
(fn fix => fix (fn f => fn n => case n of 0 => [] | n => n::f (n-1))) | |
( | |
fn f => | |
(fn cell => | |
(fn f' => (fn () => f')(cell := SOME f') | |
)(f (fn x => valOf (!cell) x)) | |
)(ref NONE) | |
) n | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment