Skip to content

Instantly share code, notes, and snippets.

@jyc
Created June 15, 2015 00:05
Show Gist options
  • Select an option

  • Save jyc/881c44396f1ecd252915 to your computer and use it in GitHub Desktop.

Select an option

Save jyc/881c44396f1ecd252915 to your computer and use it in GitHub Desktop.
(bitmatch (u8vector 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1)
(((a double big) (b double big) (c boolean) (d boolean))
(vector a b c d)))
Press ENTER or type command to continue
; outputs #(0.0 0.0 1 1)
(write (bitmatch (u8vector 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1)
(((a double big) (b double big) (c 8) (d 8))
(vector a b c d))))
; if we take the same thing but change c and d to booleans of 8 bits...
(write (bitmatch (u8vector 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1)
(((a double big) (b double big) (c 8 boolean) (d 8 boolean))
(vector a b c d))))
; ... we get Error: bitstring-malformed-pattern
; the documentation says that 8 bits should be the default, but if we remove them...
(write (bitmatch (u8vector 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1)
(((a double big) (b double big) (c boolean) (d boolean))
(vector a b c d))))
; ... we get Error: unbound variable: boolean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment