Jump to content

Define a primitive data type: Difference between revisions

(Added PicoLisp)
Line 17:
 
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
<lang algol68> # assume max int <= ABS - max negative int #
<!-- Note: I cannot use<lang algol68> here because algol support UTF-8 characters ÷×≤≥↑ etc, and some code is COMMENTED out, sorry -->
# assume max int <= ABS - max negative int #
INT max bounded = ( LENG max int * max int > long max int | ENTIER sqrt(max int) | max int );
Line 118 ⟶ 117:
ABS = (BOUNDED range)BOUNDED: ABS value OF range ASSERTIN []BOUNDED(range);
COMMENT Operators for extended characters set, and increment/decrement "commented out" to save space.<!--:
OP +:= = (REF BOUNDED a, BOUNDED b)REF BOUNDED: ( a := a + b ),
+=: = (BOUNDED a, REF BOUNDED b)REF BOUNDED: ( b := a + b ),
Line 159 ⟶ 158:
OVERAB = (REF BOUNDED a, BOUNDED b)REF BOUNDED: ( a %:= b ),
MODAB = (REF BOUNDED a, BOUNDED b)REF BOUNDED: ( a %*:= b );
 
-->END COMMENT
Test:
RANGE range = RANGE(0, 10000);
Line 178 ⟶ 177:
OD;
except bounds error:
SKIP</lang>
Output:
<pre>
Line 192 ⟶ 191:
===Other libraries or implementation specific extensions===
As of February 2009 no open source libraries to do this task have been located.
 
=={{header|C++}}==
{{works with|g++}}
Cookies help us deliver our services. By using our services, you agree to our use of cookies.