Range consolidation: Difference between revisions

(Added Algol 68)
 
Line 444:
 
# returns the consolidation of the ranges in a in #
OP + CONSOLIDATE = ( []RANGE a in )[]RANGE:
IF UPB a in <= LWB a in
THEN a in # 0 or 1 range #
Line 464:
OD;
result[ : r max ]
FI # +CONSOLIDATE # ;
 
OP FMT = ( REAL v )STRING: # prints v with at most 3 decimal places #
Line 497:
 
PROC test = ( []RANGE a )VOID:
BEGIN print( ( ( TOSTRING a PAD 60 ), " -> ", TOSTRING +CONSOLIDATE a, newline ) ) END;
test( []RANGE( RANGE( 1.1, 2.2 ) ) );
test( ( ( 6.1, 7.2 ), ( 7.2, 8.3 ) ) );
3,021

edits