Anonymous user
Order two numerical lists: Difference between revisions
Undo revision 127060 by Spoon! (talk)
(it seems that the task describes <=, not <) |
|||
Line 28:
b.push_back(0);
std::cout << std::boolalpha << (a <
return 0;
}</lang>
Line 42:
If your numbers happen to be in the range 0 to 255, this works:
<lang go>func less(a, b []byte) bool {
return string(a) <
}</lang>
Otherwise, the following code is equivalent and can be easily changed to support lists of other numeric types.
Line 60:
=={{header|Haskell}}==
The built-in comparison operators already do this:
<lang haskell>Prelude> [1,2,1,3,2] <
False</lang>
Line 120:
The built-in comparison operators already do this:
<lang ocaml># [1;2;1;3;2] <
- : bool = false</lang>
Line 183:
=={{header|Python}}==
The built-in comparison operators already do this:
<lang python>>>> [1,2,1,3,2] <
False</lang>
=={{header|Ruby}}==
The built-in <code><=></code> operator already does this:
<lang ruby>>> ([1,2,1,3,2] <=> [1,2,0,4,4,0,0,0]) <
=> false</lang>
=={{header|Standard ML}}==
<lang sml>- List.collate Int.compare ([1,2,1,3,2], [1,2,0,4,4,0,0,0])
val it = false : bool</lang>
|