Erlang case statement questions
Greg Perry
Greg.Perry@REDACTED
Mon Jun 1 19:48:07 CEST 2009
Ok I've put together a simple module declaration but I am getting an
error on this case statement. What am I doing wrong with this? N is an
integer that gets passed to the module, based upon the return of N rem
9, PQ then gets assigned the list of items on the right:
----------
analyze(N) ->
case (N rem 9) of
1 -> PQ = [{1,1}, {2,5}, {4,7}, {8,8}];
2 -> PQ = [{1,2}, {4,5}, {7,8}];
3 -> PQ = [{1,3}, {2,6}, {3,4}, {3,7}, {5,6}, {6,8}];
4 -> PQ = [{1,4}, {2,2}, {5,8}, {7,7}];
5 -> PQ = [{1,5}, {2,7}, {4,8}];
6 -> PQ = [{1,6}, {2,3}, {3,5}, {3,8}, {4,6}, {6,7}];
7 -> PQ = [{1,7}, {2,8}, {4,4}, {5,5}];
8 -> PQ = [{1,8}, {2,4}, {5,7}];
9 -> PQ = [{1,9}, {2,9}, {3,3}, {3,6}, {3,9}, {4,9}, {5,9}, {6,6},
{6,9}, {7,9}, {8,9}, {9,9}];
end.
----------
I used the example in Joe's Programming Erlang book for the case
statement, but got something wrong obviously.
Thanks in advance,
Greg
More information about the erlang-questions
mailing list