[erlang-questions] Tried this... Thought it interesting... But it didn't work.

lloyd <>
Tue Sep 1 17:30:31 CEST 2015


So, I ran across this tidbit in the Erlang cybersphere:

List Comprehension without generators

http://blog.equanimity.nl/blog/2015/03/15/erlang-one-weird-trick-goodiebag/

1> Y = 3.
3
2> Z = [X || Y > 2].
* 1: variable 'X' is unbound

OK.So I tried...

-module(test).

-compile(export_all).

test(Y) ->
  [ X || Y > 2].

>3 test:test().
Error: variable 'X' is unbound

Waah...is someone pulling my leg?

This worked...

4> Z = [X || X <- [Y >2]].

But it seems rather pointless.

I didn't check to see if the original post was dated circa April 1.

Best wishes,

LRP





More information about the erlang-questions mailing list