Created
March 26, 2013 07:34
-
-
Save sudowork/5243717 to your computer and use it in GitHub Desktop.
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
| % Basic bit-wise pattern matching | |
| 1> <<Foo,Bar,Baz>> = <<1,2,3>>. | |
| % Some more advanced pattern matching | |
| 2> <<R:8,G:8,B:8>> = <<16#BADA55:24>>. | |
| <<"ºÚU">> | |
| % Using the built in bindings command | |
| 3> b(). | |
| B = 85 | |
| Bar = 2 | |
| Baz = 3 | |
| Foo = 1 | |
| G = 218 | |
| R = 186 | |
| ok | |
| % Pattern matching + list comprehensions on bit data, producing tuples | |
| 5> [ {R,G,B} || <<R:8, G:8, B:8>> <= <<1,2,3,4,5,6,7,8,9>> ]. | |
| [{1,2,3},{4,5,6},{7,8,9}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment