Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • by hans (2166) on 2001.10.04 19:09 (#1501)
    Does anybody know why he introduced those hyperoperators @c = @a ^+ @b? I could imagine something like

    @c = map({$a + $b} @a, @b)

    beeing much more backward-compatible, less line-noisy and more flexible.
    • Intriguing syntax you've introduced there.

      Does it cope well if you introduce more operands? e.g.

      @e = map ( { $d + $c } @d, map ( {$c + $b } @c, map ( {$a + $b} @a, @b ))

      My apologies if I lost track of parens. It's a bit noisy compared to:

      @e = @a ^+ @b ^+ @c ^+ @dmap {} will probably just provide more power. We'll see when he gets to Apocalypse 29 ("Functions"). That's assuming he doesn't skip any numbers =)
      --
        ---ict / Spoon
      • I don't think you need the parens here. It all depends how automatic list flattening is handled: is map {} @a,@b the same as map {} @c?? I thought of the $a and $b as similar to the ones used in sort(). Its just chance that they use the same symbols (a and b) as the argument lists.

        Your example would write:

        @e=map {$a+$b} @d, map {$a+$b} @c, map {$a+$b} @a,@b

        One could even introduce an arbitrary number of parameter lists. In that case:

        @e=map {$a+$b+$c+$d} @a,@b,@c,@d

        Of cours

    • (this is all my conjecture)

      For one, it moves away from a functional interface to an operator interface, which may be more line-noisy, but I think is cleaner. Count the line-noise symbols in your two statements.

      Two, I seem to recall reading some discussion about trying to get rid of $a and $b. (Could be wrong).

      Three, it's a different way of looking at it. with map you are doing something to a set of data. Your view of that data is abstracted through map(), which makes this less intuitive to the ne