1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
%%%-------------------------------------------------------------------
%%% File : test_comprehensions.erl
%%% Author : Per Gustafsson <pergu@jobberl>
%%% Description : Test module to see that pretty printing etc.
%%% works on extended comprehensions
%%% Created : 15 Oct 2007 by Per Gustafsson <pergu@jobberl>
%%%-------------------------------------------------------------------
-module(test_comprehensions).
-compile(binary_comprehension).
-export([test/0]).
test() ->
{bbc(),llc(),blc(),lbc(),bblc(),lblc()}.
binary() ->
<<1,2,3>>.
list() ->
[1,2,3].
bbc() ->
<< <<X>> || <<X>> <= binary(), X > 1 >>.
llc() ->
[X || X <- list(), X > 1].
blc() ->
<< <<X>> || X <- list(), X > 1 >>.
lbc() ->
[X || <<X>> <= binary(), X > 1].
bblc() ->
<< <<(X+Y)>> || <<X>> <= binary(), Y <- list(), X > 1 >>.
lblc() ->
[(X+Y) || <<X>> <= binary(), Y <- list(), X > 1].
|