Order two numerical lists: Difference between revisions

no edit summary
(→‎{{header|Lasso}}: Added Lasso contribution)
No edit summary
Line 939:
return 0
}</lang>
 
=={{header|TUSCRIPT}}==
<lang tuscript>
Line 979 ⟶ 980:
true: 1'2 < 1'2'4
</pre>
 
=={{header|Wart}}==
<pre>def (lex_less a b)
if not.b
nil
not.a
b
(car.a = car.b)
(lex_less cdr.a cdr.b)
:else
(car.a < car.b)</pre>
 
Output:
<pre>(lex_less '(1 2 3) '(1 2 4))
=> 4
(lex_less '(1 2 4) '(1 2 3))
=> nil
 
(lex_less '(1 2 3) '(1 2 3 4))
=> (4)
(lex_less '(1 2 4) '(1 2 3 4))
=> nil</pre>
 
Wart also supports overloading infix operators (e.g. http://rosettacode.org/wiki/Repeat_a_string#Wart), but there's a subtle reason we can't overload <code>&lt;</code> in this case: infix chaining. Wart is intended to permit range operations like <code>(a &lt; b &lt; c)</code>. This expands to:
 
(< (< a b) c)
 
To ensure that a failing test short-circuits the range operation, <code>nil</code> is never less than any other value. However, the false-y value <code>nil</code> is also the degenerate empty list, and in this case we'd like it to be less than all other lists.
143

edits