Order two numerical lists: Difference between revisions

(Added Arturo implementation)
Line 1,890:
( 1 2 3 ) ( 1 2 3 ) < ?
( 1 2 3 ) ( 1 2 4 ) < ?</lang>
 
=={{header|Picat}}==
Picat has a built-in general comparison operator @<, which compares terms in lexicographic order (numeric lists as well as atoms, strings, variables, and structures).
 
<lang Picat>go =>
Tests = [
[[1,2,3], [1,2,3]],
[[1,2,3], [1,2,3,4]],
[[1,2,2], [1,2,3]],
[[1,2,4], [1,2,3]],
[1..10 , 1..8],
[[] , []],
[[] , [1]],
[[1] , [] ],
[[-1,2,3,6,5],[-1,2,3,5,6]],
[[-1,2,3,-5,6],[-1,2,3,-6,5]]
],
foreach([L1,L2] in Tests)
printf("%w @< %w: %w\n",L1,L2,cond(L1 @< L2,true,false))
end,
nl.</lang>
 
In the Picat shell, the result is yes/no rather than true/false:
<pre>
Picat> [1,2,3] @< [1,2,3]
 
no
 
Picat> [1,2,3] @< [1,2,3,4]
yes</pre>
 
 
=={{header|PicoLisp}}==
495

edits