Jensen's Device: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added whitespace, split a compound statement.) |
|||
Line 1,288: | Line 1,288: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
⚫ | |||
Note: the 2<sup>nd</sup> and 3<sup>rd</sup> arguments for the '''sum''' function needn't be enclosed in quotes (as they're numeric); |
|||
parse arg d . /*obtain optional argument from the CL.*/ |
|||
<br>they were enclosed just to be consistent with the other arguments. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
numeric digits d /*use D decimal digits (9 is default)*/ |
numeric digits d /*use D decimal digits (9 is default)*/ |
||
say 'using ' d " decimal digits:" /*display what's being used for digits.*/ |
say 'using ' d " decimal digits:" /*display what's being used for digits.*/ |
||
say |
say |
||
say sum( |
say sum( i, 1, 100, "1/i" ) /*invoke SUM (100th harmonic number).*/ |
||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
sum: procedure; parse arg j,start,finish,exp; $=0 |
sum: procedure; parse arg j,start,finish,exp; $= 0 |
||
interpret |
interpret 'do' j "=" start 'to' finish "; $=$+" exp '; end' |
||
/*comment ──── ═ ─── ═════ ──── ══════ ────────── ═══ ───────── */ |
|||
/*comment lit var lit var lit var literal var literal */ |
|||
return $</lang> |
return $</lang> |