[erlang-questions] List comprehensions assistance
Technion
technion@REDACTED
Tue Aug 18 00:40:35 CEST 2015
Hi,
I have the following piece of code, which works correctly:
ConvertFun = fun({X, Y}) -> {[{<<"address">>,
list_to_binary(inet:ntoa(X))}, {<<"stat">>, Y}]} end,
ScanConverted = lists:map(ConvertFun, Results),
The reason for this very specific mapping is to convert it into exactly the format jiffy expects (in order to generate the correct JSON). I've been experimenting with rewriting this as a list comprehension (largely as a learning exercise).
Code like this fails to compile:
ScanConverted = [[{<<"address">>, list_to_binary(inet:ntoa(X))},
{<<"stat">>, Y}]| {X, Y} <- Results]
src/ipmangle.erl:31: syntax error before: '<-'
Any pointers on this would be appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150817/07e4b378/attachment.htm>
More information about the erlang-questions
mailing list