Jump to content

Multiplication tables: Difference between revisions

m
→‎{{header|Icon}}: cleaned up contraction
(+Icon+Unicon)
m (→‎{{header|Icon}}: cleaned up contraction)
Line 922:
lim := 13
wid := 5
every writes(right("* |" | (1 to lim) | "\n",wid)|right("\n",wid*(lim+1),"_")) # header rowsrow and separator
every (i := 1 to lim) &
writes(right( i||" |" | (j := 1 to lim, (if j < i then "" else i*j)\1) | "\n",wid)) # table content and triangle
end </lang>
 
The above example is a somewhat exaggerated example of contractions. In both cases 'every' is used to force all alternatives including row labels, column headings, content, line terminators. The upper triangle is produced by embedding an 'if' expression inside the object of an 'every' (normally an error prone construct which would malfunction if not forcarefully separated from the operatorgenerators limitingfor generation'i' toand a'j' single- resultan (i.e.all viatoo exprtempting \possibility 1)once you get into this mind set.)
 
 
Line 945:
12 | 144 156
13 | 169 </pre>
 
 
==={{header|Unicon}}===
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.