Created
February 18, 2013 13:31
-
-
Save kjagiello/f2554604a4ac3b37d4b5 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
fun orbList l = | |
foldr Word32.orb (Word32.fromInt 0) l | |
fun bin2word x = | |
let | |
fun bin2word' ("", _) = [] | |
| bin2word' (s, i) = | |
let | |
val b = String.sub (s, 0) | |
val v = case b of | |
#"0" => 0wx0 | |
| #"1" => 0wx1 | |
| _ => raise Subscript | |
in | |
Word32.<< (v, Word.fromInt (i))::bin2int' (String.substring (s, 1, size s - 1), i - 1) | |
end | |
in | |
orbList (bin2int' (x, size x - 1)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment