[erlang-questions] Erlang elseif
Thu Nov 20 10:09:29 CET 2008
Here's another list-comprehension way
[io:format("Member of capital\n") || lists:member(A,?CAPS)],
[io:format("Member of small\n") || lists:member(A,?SMALL)],
[io:format("Member of nums\n") || lists:member(A,?NUMS)],
OK, it's not else-if, rather a sequence of if-thens, but it does the same
job and it's short and sweet.
> From: kdronnqvist@REDACTED
> Subject: [erlang-questions] Erlang elseif
> To: erlang-questions@REDACTED
> Content-Type: text/plain; charset="iso-8859-1"
> Hi everyone I just joined the list and tried to search for information
> this but I could not find anything that answered my question. The thing is
> that I want a general way to branch the execution of my code based on the
> result on an expression. Very similar to how if works but I want to be
> to test expressions and not only guards. If you're thinking "then you have
> case" now look below at function elseif2() and you'll see my point.
> I wrote a couple of examples how to solve this but none of them really
> right, the logic in what I'm trying to do is really REALLY not that
> complicated. The functions takes an argument and prints something based on
> what list the argument is a member of (if any). Like this:
> 42> e:elseif4($Q).
> Member of capital
> I would appreciate any input on this, even if it means you're bashing all
> examples below :-)
> Daniel R?nnqvist
More information about the erlang-questions