I'm quite impressed with Erlang's Bin datatype and binary pattern matching. 
I've tried to replicate some of the coolness in Clojure..
So, what can you do with it? 

Create a bin: 
  user> (<< 1 17 42)
  (1 17 42)
 
  user> (<< [0xf0f0 16] 1 17)
  (240 240 1 17)

  user> (<< "abc")
  (97 98 99)

More interesting is probably constructing a bin from a set of bound variables:
  user> (let [A 1
                     B 17
                     C 42
                     bin (<< A B [C 16])] bin)
  (1 17 0 42)

A bin can also be used for matching: 
  user> (bin-let [[D 16 E 8 F 8] (1 17 00 42)] 
              [D E F])
  [273 0 42]

That's pretty much the gist of it. Please feel free to look at the code at
g...@github.com:AndreasKostler/Binj.git

I've only put it up this morning so please don't expect polished code or 
comments ;)

I'm VERY interested in your feedback...about functionality, style, idiomatic 
usage of the language, etc.
Be as anal as possible, I'm still learning.

Cheers
Andreas


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to