Perl6 allows us to define a custom composition operator. We can then use it with the triangular reduction metaoperator, and map each resulting function with an infinite value for x.I program a fair amount in Perl 5 and I don't recognize a thing here. I remember seeing a bit of an interview of Larry Wall, and he was talking about how much fun he was having posting code to rosettacode.org. I'm going to blame this one on him.sub infix:<⚬>(&f, &g) { -> $x { &f(&g($x)) } }
sub continued-fraction(@a, @b) { [\⚬] map { @a[$_] + @b[$_] / * }, 0 .. * }
Labels: perl
If you get in any further than a couple line script, perl just gets scary. Like today, my friend who aspires to greatness asked me if @$yy{key} was different than @{$yy{key}}.
The short answer is yes.
The long answer is that the first is an array slice dereferencing an anonymous hash in the scalar $yy. The second is dereferencing an anonymous array in the hash %yy under the key 'key'.
Perl lets you build so many layers of collections and lists that you just find yourself building these elaborate structures because they fit the data or how you want to use it. Pretty soon you're doing,
@{$res{$_->{channel_id}}{$_->{key_type}}[$k]}{qw(count z)}= @$_{qw(ct z)}
And thinking nothing of it. Ok, maybe you have to think about it a little bit because you get it wrong the first time, but a quick splash of Data::Dumper() and all is revealed.
Feb '04
Oops I dropped by satellite.
New Jets create excitement in the air.
The audience is not listening.
Mar '04
Neat chemicals you don't want to mess with.
The Lack of Practise Effect
Apr '04
Scramjets take to the air
Doing dangerous things in the fire.
The Real Way to get a job
May '04
Checking out cool tools (with the kids)
A master geek (Ink Tank flashback)
How to play with your kids