Arithmetic/Rational: Difference between revisions

(Added PicoLisp)
Line 31:
=={{header|ALGOL 68}}==
{{works with|ALGOL 68|Standard - no extensions to language used}}
 
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
<!-- Note: I cannot use<lang algol68> hereMODE becauseFRAC algol= supportSTRUCT( UTF-8INT charactersnum ÷×≤≥↑#erator#, etc sorryden -->#ominator#);
MODE FRAC = STRUCT( INT num #erator#, den #ominator#);
FORMAT frac repr = $g(-0)"//"g(-0)$;
Line 101:
ENTIER = (FRAC frac)INT: (num OF frac OVER den OF frac) * den OF frac;
COMMENT Operators for extended characters set, and increment/decrement "commented out" to save space.<!--:
OP +:= = (REF FRAC a, FRAC b)REF FRAC: ( a := a + b ),
+=: = (FRAC a, REF FRAC b)REF FRAC: ( b := a + b ),
Line 144:
MODAB = (REF FRAC a, FRAC b)REF FRAC: ( a %*:= b );
-->END COMMENT
Example: searching for Perfect Numbers.
FRAC sum:= FRACINIT 0;
Line 163:
candidate, ENTIER sum, real sum, ENTIER sum = 1))
FI
OD</lang>
Output:
<pre>