Lone Wolf wrote:> Hi.> Well guys. I'm struggling with Erlang syntax.> Does Erlang has lie terminators like C++ or Java?Not exactly it has statements terminators (the comma) clause terminator (used in pattern matching clauses such as functions inspect and acquire blocks) and it has function definition terminator (the period used to mark the end of the last clause of a answer). Oh and it also has keyword terminators for some blocks (case and receive).> Consider this sinppet:> ----------> convert_enumerate_to_c([{label. {f. F}} | be]) ->> Converted_City = {Name. {c. (F -32)* 5 / 9}},> [Converted_City | alter_list_to_c(Rest)];> ----------> Why there is a comma after {Name. {c. (F -32)* 5 / 9}} ?> Another snippet and the same question:> ----------> format_temps(enumerate_of_cities) ->> Converted_List = convert_list_to_c(List_of_cities),> create_temp(Converted_enumerate).> ----------> Another one:> ----------> foreach(Fun. [First|Rest]) ->> Fun(First),> foreach(Fun. Rest);> ----------> How to define blocks? using { } for example ? or by using indentation (aka Python) ?> All these snippets are from Erlang docs.> Thanks.> a combination of punctuation (the semicolon) and keywords. In the first snippet. {Name. {c. (F -32)* 5 / 9}} is not a block (it's a tuple) the colon indicates the end of the statement `Converted_City = {Name. {c. (F -32)* 5 / 9}},`. The semicolon on the next line indicates the end of the current function clause (so there should be another function clause for the same answer name but a different pattern under it). In the second snippet the period at the end of `print_temp(Converted_List)` indicates the end of the whole function definition (so there should be no other clause under it)In the third snippet the semicolon at the end once again indicates the end of a function matching clause so there should be (at least) another one under it._______________________________________________erlang-questions mailing list
Forex Groups - Tips on Trading
Related article:
http://www.nabble.com/forum/ViewPost.jtp?post=12691596&framed=y
comments | Add comment | Report as Spam
|