Order Evaluation in List Comprehension

Ben Hyde bhyde@REDACTED
Sat Dec 19 02:12:52 CET 1998


tuning in later...

box_top(X)->[E||E<-X,begin io:format("~p\n", [E]), true end].
black_box(X)->[begin io:format("~p\n", [E]), E end||E<-X].
black_n_blue(X) -> 
    [begin io:format("assemble: ~p\n", [E]), E end
     || E<-X,
	begin io:format("filter: ~p\n", [E]), true end].

...>hack:box_top([1,2,3]).
1
2
3
[1,2,3]
...>hack:black_box([1,2,3]).
3
2
1
[1,2,3]
...>hack:black_n_blue([1,2,3]).
filter: 1
filter: 2
filter: 3
assemble: 3
assemble: 2
assemble: 1
[1,2,3]
...>

Does the spec preclude interleaving the accumulation with
the iteration?  

Looping, nothing but trouble.

Claes Wikstrom writes:
> ... we
>have decided that in the next major release we shall have fixed
>and decided evaluation order.

Functional and deterministic!  Imagine!  - ben




More information about the erlang-questions mailing list