On 14/05/05, Damian Conway <[EMAIL PROTECTED]> wrote:
> Here are a few of the things I'll be using reductions for in Perl 6...
> 
>      1. To add things up:
> 
>             $sum = [+] @amounts;
> 
>      2. To calculate the probability that I'll need to use a reduction today:
> 
>             $final_prob = [*] @independent_probs;
> 
>      3. To drill down a hierarchical data structure, following the path
>         specified by a list of keys:
> 
>             $leaf_value = [.{}] %hash, @keys;
> 
>      4. To compute RMS values:
> 
>             $RMS = sqrt [+] @samples »** 2
> 
>      5. To take the dot product of two vectors:
> 
>             $dot_prod = [+] @vec1 »*« @vec2;
> 
>      6. As a cleaner form of C<< join.assuming(:sep<>) >>:
> 
>             $joined = [~] @strings;
> 
>      7. For parity checking a bitset:
> 
>             $parity = [?^] @bits;
> 
>      8. To verify the monotonicity of a sequence:
> 
>             $is_monotonic = [<] @numbers;
> 
>      9. To retrieve the first defined value in a list:
> 
>             $first_def = [//] @list;
> 
>      10. To apply a series of properties to a value:
> 
>             $propped = [but] $value, @properties;
And I note that each of these is a 'simple' operator inside the
reduce. I think the complex example earlier in this thread ([»+^=«],
warranted by the context, but still extreme) may give the wrong
picture of the 'new' metaoperator. The point is that although it opens
marvellous new ways of obfuscation, it's also extremely handy when
used properly. And that's something shared by many of Perl's existing
features.

> Personally I think a metaoperator with that many uses is more than Swiss-Army
> enough to be in the core of Perl 6.
So now it's going from Swiss-army chainsaw to Swiss-army atomic fusion bomb?

-- 
Schwäche zeigen heißt verlieren;
härte heißt regieren.
  - "Glas und Tränen", Megaherz

Reply via email to