On the other hand, closures are much nicer now (JavaScript needs this): > say (1,2,3,4,5).reduce: { $^a + $^b };
15
Note about .reduce: it only supports binary functions.
A note on operators:
Hyperops, eg: (1,2,3,4) «+» (5,6,7,8)
These are permitted to auto-parallelize (implementation dependent.)
Lazy meta-ops, eg: 1,2,3,4 Z+ 5,6,7,8
These support lazy evaluation. The result is generated as needed.
Reduction meta-ops, eg: [+] 1,2,3,4,5
Triangular reduction: [code][\+] 1,2,3,4,5 # result is (1,3,6,10,15)[code]
These are basically .reduce(*[b][i]op[/i][/b]*) with the binary operator provided.
>>1
i liek perl6 cuz it reminds me so much of haskal hahahahahahahaha lol ^___^ i rly liek haskal (and i'm from /g/ hahaha nice to meet u haha lol hahahahaha lol)
>>4
NB. whatever-star is not classified as an operator. I think it's classified as a type in the auto-currying form.
Name:
Anonymous2011-01-10 11:15
>>6
I praised the power of Perl's Yada Yada Operator many times.
It is actually useful:
1. Your sub function { ... } example codes will be actual VALID Perl 6 CODE.
2. When you're working on a complex function, you can implement part of it later, using The operator on that branch: if (something) {
...; //TODO: we've got something, what to do?
} else {
// Let me work on this first
}
3. It's cute.
>>7
I think it can be classified as meta-operator, like «»/»«.
These support lazy evaluation. The result is generated as needed.
No CSE, no sharing, just call-by-name. Certain people fucking hate that myth that you can add some sort of primitively deferred computation to a strict applicative-order language and add "lazy evaluation" to your feature list.
>>14
Take it up with Larry Wall. No really--you can, he hangs out on IRC all the time. And I don't mean that in the "go away" sense, I mean it in the We're doing The Whirlpool-Larry Wall sense, i.e. if you can make a good point about it the spec and implementation will be revised.
if you can make a good point about it the spec and implementation will be revised.
I state that you are not a Perl programmer because you retain too much sanity, thus you are not eligible to participate in this discussion.
>>22
He obviously means »If you can show a cool one-liner that prints out `Just another Perl hacker,´«
Name:
Anonymous2011-01-11 23:41
>>22
Encouraging someone go visit IRC to be shot down by The Larry isn't exactly diagnostic of sanity (though it doesn't necessarily make one insane.)
One: there is a measure of call-by-need in Perl 6's lazy evaluation. Two: it is often an implementation detail according to the spec. Three: >>14 argues from some false sense of purity. Four: >>14 would throw out utility in order to promote that sense of utility. Five: Mr. Wall is very entertaining when he bursts peoples' respective bubbles.
Larry Wall is an awesome guy, and anybody who tells you otherwise is DAMN EVIL LIAR and is probably jealous. Ignore the rantings and ravings of JEALOUS, JEALOUS FAILURES. The Ruby faggots, Guido, John McCarthy, Knuth, and the Jews have all been trying to take Larry Wall down for years but they can't because he's just too damn good.
>>24
It's misleading. One would expect lazy evaluation to be, well, lazy evaluation, and not merely a nullary "thunk" that gets executed when "its value is needed".
>>28
You might want to read up on it, because it sounds like you've got the wrong idea.
Name:
Anonymous2011-01-12 21:51
>>30
I don't know if a non-destructive version has been implemented yet, but I know f/e this works:
my $a = "abcdef";
my $b = $a.map: { ~~ s/a/z/; $_ }
say $a; # abcdef
say $b; # zbcdef is copy is a great thing along similar lines:
sub foo($bar) { $bar = 'x' }; # error, read-only reference
sub foo($bar is rw) { $bar = 'x' }; # ok, rw reference
sub foo($bar is copy) { $bar = 'x' }; # ok, local copy
Name:
Anonymous2011-01-18 12:19
Recently seen on IRC (slightly modified): subset Even of Int where * %% 2;
subset DivisibleByFour of Int where * %% 4;
say DivisibleByFour ~~ Even
-> Bool::True
>>33
Perl 5 got it, apparently after much moaning.
>>34
I was hoping you'd pick up on the Halting-complete type system.
The above code is matching against the parent type. It's a bug or something, but %% 3 would have matched Even as well. I think the correct behaviour is that type comparisons should always result in False unless they are exactly equal or LHS is defined as a subset of RHS.
Name:
Anonymous2011-01-18 13:58
>>31
I still don't get the use of : ... for example on reduce or in assignments....
>>35 I was hoping you'd pick up on the Halting-complete type system.
I remember that in some version of Perl, simply parsing Perl code was not guaranteed to terminate.