Skip to content

Instantly share code, notes, and snippets.

@kjagiello
Created February 18, 2013 13:31
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 kjagiello/f2554604a4ac3b37d4b5 to your computer and use it in GitHub Desktop.
Save kjagiello/f2554604a4ac3b37d4b5 to your computer and use it in GitHub Desktop.
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