Minimum numbers of three lists: Difference between revisions

m
→‎{{header|ALGOL 68}}: Use new ALGOL 68-rows library
(add fermat)
m (→‎{{header|ALGOL 68}}: Use new ALGOL 68-rows library)
Line 16:
=={{header|ALGOL 68}}==
Generallising a little...
{{libheader|ALGOL 68-rows}}
<lang algol68>BEGIN # construct a list of the minimum values of some other lists #
# lists are represented by arrays in this sample #
PR read "rows.incl.a68" PR # row-related utilities #
# returns a list composed of the minimum values of the lists in lists #
# the lists must all have te same bounds #
Line 40 ⟶ 42:
result
FI # min # ;
 
# displays a list of numbers #
PROC show = ( []INT list )VOID:
FOR i FROM LWB list TO UPB list DO print( ( " ", whole( list[ i ], 0 ) ) ) OD;
# construct the lists of numbers required by the task #
REF[]INT numbers1 = HEAP[ 1 : 5 ]INT := ( 5, 45, 23, 21, 67 );
Line 48:
REF[]INT numbers3 = HEAP[ 1 : 5 ]INT := ( 9, 98, 12, 98, 53 );
# display the minimum values for each element in the lists #
show(SHOW min( ( numbers1, numbers2, numbers3 ) ) )
END</lang>
{{out}}
3,038

edits