[erlang-questions] Comma, semicolon. Aaaaa

David King dking@REDACTED
Tue Sep 18 03:05:44 CEST 2007


>> >>C:  x > y ? e1, e2 : (e3, e4)
>> Erlang: if x > y -> e1, e2 ; true -> e3, e4 end
>> I didn't understand this example.
>> Sorry guys but I didn't know anything in C language.
>> Thanks for help.
> 	(if (> x y) '(e1 e2) '(e3 e4))

Not quite. that would look like
	if x>y -> [e1, e2]; true -> [e3,e4] end.

Basically,

A=if x>y ->
     e1,
     e2;
   true ->
     e3,
     e4
   end.

Is just to show that 'if' returns a value, and it returns the return- 
value of the last statement in the clause (a section of the 'if' that  
begins with "EXPRESSION ->") of the 'if' expression that is  
evaluated. The semicolons separate those clauses. That particular  
expression binds A=e4.



More information about the erlang-questions mailing list