From: Gavin Sinclair Date: 2002-08-04T23:25:14+09:00 Subject: Re: Should this work? ----- Original Message ----- From: "ts" > G> [x, y, z].map { $_ << [nil] } # -> [nil, nil, nil] > > [...] > > G> What do people think? > > Have you used a P language ? :-) > > > Guy Decoux > A "Perl" language? Yes. I'm not very proficient, because it seems practically impossible to do anything in Perl and remain sane. However, it is a very clever, creative, quirky and interesting language. Some of the solutions in "The Perl Cookbook" are remarkable for their elegance. However, that elegance is "read-only". Mere mortals cannot usually know what magic Perl interpreter will accept. In short, I love Perl, but never use it. *Anyway*, despite all that, my affection for the [x, y, z].map { $_ << [nil] } # -> [nil, nil, nil] construct is based not on Perl (despite the $_), but on Miranda (similar to Haskell). For example: fib n = # Definition of Fibonacci sequence map fib [1..10] # -> [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] In Ruby, since :map/:collect most commonly takes only one parameter in the block, it could be unambiguously shortcut using a magic local variable. I definitely think my "capitalize" example was overdoing it, as it relies on dodgy Perl $_ overuse, rather than plain old functional programming. --Gavin