λambder on software

This is my journey into the world of computer science and geekery.

It easy to handle streams of bytes in Erlang. For example consider the following simple task:
given a stream consisting of 3-byte chunks we want to return a stream consisting of those 3-byte chunks whose first byte is zero.

This can be written in the following manner:

 
keep_0XX(Bin) -> << <<0:1,X:2>> || <<0:1,X:2>> <= Bin >>.
 

I like it, I hope you too.

[update]
Previously I thought it was undocumented feature of erlang. As Bryan kindly pointed out, one can find it documented here.
Thank you Bryan.

2 years ago