[erlang-questions] Erlang n00b figuring out bins

jasingleton.work@REDACTED jasingleton.work@REDACTED
Tue Sep 24 16:46:58 CEST 2013


I've done a lot of development, but it's been quite a while since I've done 
anything
functional.  Erlang is still brand-new for me, so be warned. 

I've got a (conceptual) string arriving in my sw as a binary, e.g. 
<<"stuff.junk.excess">>
and trying to transform it into a list of strings, e.g. ["stuff", "junk", 
"excess"]
The mechanism I'm using is giving me a list of lists of binaries, e.g.
 [ [<<"s">>, <<"t">>, <<"u">>, <<"f">>, <<"f">>], [<<"j">>, <<"u">>   (etc)

I ended up hacking it to just take each of the lists of binaries and run it 
through
list_to_binary and then binary to list.  The result is what I really 
wanted, which is 
    list_to_binary(binary_to_list( [<<"s">>, <<"t">>, <<"u">>, <<"f">>, 
<<"f">>]))
gives me back
    "stuff"

That's all well and good, and functional, but has two problems:
1) I honestly don't get why it worked; I would expect those two operations 
to
    give me back something unchanged.
2) There's got to be a more graceful way to achieve this.

Thoughts?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130924/7582098b/attachment.htm>


More information about the erlang-questions mailing list