[erlang-questions] List comprehensions
Thu Oct 12 09:02:50 CEST 2006
Just reading the manual on list comprehensions, and looking at the
comprehension to return all permutations of a sequence:
[[H|T] || H <- L, T <- perms(L--[H])].
I'm having trouble with understanding what's happening. I assume it's
evaluated left to right from the ||, and I'm sort of grasping the
general interplay of the generators and the recursion, but I'm also
missing it at the same point.
I think I get how dual generators work now -
[[H|[T]] || H <- [a,b,c],T <- [1,2,3]]
How could I rewrite the permutations comprehension as a function so I
can sprinkle it with io:format()s so as to understand what's happening
More information about the erlang-questions