Icon+Unicon/Intro: Difference between revisions

Line 157:
=== Coercion: Implicit Type Conversions ===
 
=== Contractions ===
Icon/Unicon have a rich set of operators which combined with the fact that all successful expressions produce values makes possible contractions. These appeal of these is somewhat a question of style and if taken to extremes there is also the possibility of being overtaken by one-liners. Having said that Icon/Unicon contractions are hardly in the same league as those of [[APL]] or [[J]]. A number of examples are presented below.
 
 
These examples initializes sum and adding all the contents of arglist. The first example uses separate statements, the second too but compresses with a ;, the third is a common contraction, and the last is an error.
<lang Icon>sum := 0
every sum +:= !arglist do something()
 
sum := 0; every sum +:= !arglist do something()
 
every (sum := 0) +:= !arglist do something()
 
while sum := 0) +:= !arglist do something()</lang>
 
== Program Flow ==
Anonymous user