Optional parameters: Difference between revisions

Content added Content deleted
(Added R code)
(J)
Line 344: Line 344:


end program UsingTest</lang>
end program UsingTest</lang>

=={{header|J}}==

<lang J>srtbl=: verb define
'' srtbl y
:
'`ordering column reverse'=. x (3{. [, ]}.~ #@[) ]`0:`0:
|.^:reverse y /: ordering (column {"1 ])y
)</lang>

For simplicity, the optional arguments are all functions, and are positional (on the left -- the table, with its arbitrary number of rows and columns, is on the right). Note also that the ordering function is expected to map its entire argument (since this offers much better efficiencies than a binary comparison).


=={{header|Java}}==
=={{header|Java}}==