On Thu, Dec 12, 2002 at 04:17:44PM -0800, Michael G Schwern wrote:
: On Thu, Dec 12, 2002 at 10:40:20PM -0000, Smylers wrote:
: > What if the thing being C<sort>ed (or whatever) is not an array but a
: > list?
: >
: > @out = sort $scalar, @array, result_of_calling_function($param);
: >
: > Would the list have to be stored in an array before it could be sorted?
:
: I would hope Perl would be smart enough to allow this:
:
: @out = ($scalar, @array, result_of_calling_function($param)).sort
It does, under the rule that says a comma list in a scalar context
assumes [...]. (The dot provides the scalar context to the comma
list--the outer list context is only meaningful to the sort.)
: which Ruby does:
:
: $ ruby -wle 'out = ["foo", "bar"].sort; print out.join " "'
: bar foo
:
: but as I said, I find the Lisp flow style worth keeping.
:
: @out = join "\n", map {...} grep {...} sort {...} @foo
That too. But you don't have to think of them as built-ins, except
insofar as any subroutine defined in * is a built-in. It's possible
the only real built-in is *sub. And maybe *rx.
Larry