Order two numerical lists: Difference between revisions

→‎{{header|REXX}}: added the REXX language. -- ~~~~
(Added Racket code)
(→‎{{header|REXX}}: added the REXX language. -- ~~~~)
Line 824:
<lang rascal>rascal>[2,1,3] < [5,2,1,3]
bool: true</lang>
 
=={{header|REXX}}==
This REXX example uses the same lists as BBC BASIC.
<lang rexx>/*REXX pgm finds if list1<list2 (both contain nums), returns true|false.*/
@.=
@.1=1 2 1 5 2
@.2=1 2 1 5 2 2
@.3=1 2 3 4 5
@.4=1 2 3 4 5
do i=2 while @.i\==''; m=i-1
what=' 'word("< ≥", 1+(FNorder(@.m, @.i)=='false'))" "
say right('['@.m"]", 35) what '['@.i"]"; say
end /*i*/
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────FNORDER subroutine──────────────────*/
FNorder: procedure; parse arg x,y; wx=words(x); wy=words(y)
 
do j=1 for min(wx,wy)
if word(x,j)<word(y,j) then return 'true'
end /*j*/
if wx<wy then return 'true'
return 'false'</lang>
'''output'''
<pre style="overflow:scroll">
[1 2 1 5 2] < [1 2 1 5 2 2]
 
[1 2 1 5 2 2] < [1 2 3 4 5]
 
[1 2 3 4 5] ≥ [1 2 3 4 5]
</pre>
 
=={{header|Ruby}}==