Hi all,
While trying to convert Haskell statements like this to Perl 6:
data Cxt = CxtVoid -- ^ Context that isn't expecting any values
| CxtItem !Type -- ^ Context expecting a value of the specified type
| CxtSlurpy !Type -- ^ Context expecting multiple values of the
On Thursday 19 May 2005 10:51 pm, Sam Vilain wrote:
> Edward Cherlin wrote:
> > Here is the last answer from Ken Iverson, who invented reduce in
> > the 1950s, and died recently.
> > file:///usr/share/j504/system/extras/help/dictionary/intro28.htm
>
>[snip]
>
> Thanks for bringing in a little h
Mark Overmeer wrote:
'uniq' differs from 'sort' because there is no order relationship between
the elements. A quick algorithm for finding the unique elements in perl5
is
sub uniq(@)
{ my %h = map { ($_ => 1) } @elements;
keys %h;
}
...and an even quicker one is:
use Set::Object;
Luke wrote:
I wondered what uniq's default comparator should be, =:=?
&infix:<~~>
Woah there. ~~ is a good comparator and all, but it's not the right
one here. ~~ compares an object and a pattern to see if they match.
That makes it the right choice for when and grep. But we're trying to
remov
Edward Cherlin wrote:
There was a discussion of the principal value of square root on
this list some time back, making the point that for positive
[...]
It turns out that the domain and range and the location of the
cut lines have to be worked out separately for different
functions. Mathemat
Stuart Cook wrote:
In Haskell, there is a distinction between foldl and foldl1 (similar
remarks apply to foldr/foldr1[1]):
The former (foldl) requires you to give an explicit 'left unit'[2],
which is implicitly added to the left of the list being reduced. This
means that folding an empty list will
On 5/19/05, Joshua Gatcomb <[EMAIL PROTECTED]> wrote:
> All:
> I was hoping the following would give me an outright error
>
> sub foo (Int $bar) {
> say $bar;
> }
> foo('hello');
Fortunately you are right.
> I seem to recall, probably incorrectly, that one of the differences
> with int, Int,
Edward Cherlin wrote:
Here is the last answer from Ken Iverson, who invented reduce in
the 1950s, and died recently.
file:///usr/share/j504/system/extras/help/dictionary/intro28.htm
[snip]
Thanks for bringing in a little history to the discussion. Those links
are all local to your system; do yo
On 5/19/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
> Hi,
>
> quoting A12:
> > infix_postfix_meta_operator:<=> $x += 2;
> > postfix_prefix_meta_operator:{'»'} @array »++
> > prefix_postfix_meta_operator:{'«'} -« @magnitudes
> > infix_circumfix_meta_operator:{'»','«
On 5/19/05, Damian Conway <[EMAIL PROTECTED]> wrote:
> Ingo Blechschmidt wrote:
> > I wondered what uniq's default comparator should be, =:=?
>
> &infix:<~~>
Woah there. ~~ is a good comparator and all, but it's not the right
one here. ~~ compares an object and a pattern to see if they match.
Damian Conway wrote:
BTW, I am *sorely* tempted to suggest the following implementation
instead:
which would produce:
uniq ; #
uniq { lc } ; # 'a'|'A', 'b',
'C'|'c', 'd'
uniq { abs $^value } 42, 23, -23, 23, 42;# 42, 23|-23
But I'd
On Thu, 19 May 2005, Juerd wrote:
Ingo Blechschmidt skribis 2005-05-19 22:45 (+0200):
class Foo {
method bar() { 42 }
method baz() { &bar }
}
my $ref = Foo.baz;
My guess:
Foo.$ref
$object.$ref
Just like in Perl 5.
I think Ingo was trying to explicitly specify the normally-implic
Hi,
Damian Conway wrote:
> BTW, I am *sorely* tempted to suggest the following implementation
> instead:
[...]
> which would produce:
>
> uniq ; #
>
> uniq { lc } ; # 'a'|'A', 'b',
> 'C'|'c', 'd'
>
> uniq { abs $^value } 42, 23, -23,
Ingo Blechschmidt wrote:
Is it intentional that there's no uniq in the current S29[1] draft?
See [2] for Damian saying that uniq is probably in.
It still probably is.
I wondered what uniq's default comparator should be, =:=?
&infix:<~~>
Should it be possible to give an own comparator block, simil
Ingo Blechschmidt skribis 2005-05-19 22:45 (+0200):
> class Foo {
> method bar() { 42 }
> method baz() { &bar }
> }
> my $ref = Foo.baz;
My guess:
Foo.$ref
$object.$ref
Just like in Perl 5.
Juerd
--
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_ju
"TSa (Thomas Sandlaß)" skribis 2005-05-19 21:06 (+0200):
> >The above is more commonly written as
> >
> >my @b = ([1,2,[3,4]);
> Assuming you meant @b = ([1,2,[3,4]]) what do the parens accomplish
> here?
Thanks for the correction. That is indeed what I meant.
The parens do absolutely nothin
Hi,
class Foo {
method bar() { 42 }
method baz() { &bar }
}
my $ref = Foo.baz;
$ref(); # Don't think this will work
# (Error: No invocant specified or somesuch)
$ref(Foo.new); # But will this work?
How do I specify multiple invocants (when dealing wit
Hi,
quoting A12:
> infix_postfix_meta_operator:<=> $x += 2;
> postfix_prefix_meta_operator:{'Â'} @array Â++
> prefix_postfix_meta_operator:{'Â'} -Â @magnitudes
> infix_circumfix_meta_operator:{'Â','Â'} @a Â+Â @b
so will the following work?
# Silly example
sub in
On 5/19/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
> I read this as that uniq should behave like Unix's uniq(1), i.e.
> removing only successive duplicates, e.g.:
> uniq [3,3,3,4,3] => [3,4,3] # what I meant
> uniq [3,3,3,4,3] => [3,4] # what you meant
That has been discussed
Ingo Blechschmidt skribis 2005-05-19 21:07 (+0200):
> I read this as that uniq should behave like Unix's uniq(1), i.e.
> removing only successive duplicates, e.g.:
> uniq [3,3,3,4,3] => [3,4,3] # what I meant
> uniq [3,3,3,4,3] => [3,4] # what you meant
Which leads to lots of |so
> "LP" == Luke Palmer <[EMAIL PROTECTED]> writes:
LP> On 5/18/05, Anthony Heading <[EMAIL PROTECTED]> wrote:
>> Is there a way to target hyperoperators at different axes of a
>> multi-dimensional array? This is an attractive feature of
>> various APL-like languages, viz. e.g. in J:
All:
I was hoping the following would give me an outright error
sub foo (Int $bar) {
say $bar;
}
foo('hello');
I seem to recall, probably incorrectly, that one of the differences
with int, Int, and no type declaration at all is that one would
happily autoconvert for you, 1 would autoconvert b
Hi,
Adriano Ferreira wrote:
> quoting Damian's original mail[1]:
>> uniq - remove duplicates without reordering
> ^^
>
> Would not that mean the original order of the first ocurrence is
> preserved? This is what Ruby Array#uniq does:
>
> [4,1
Juerd wrote:
Parens and square brackets are very different things.
I know. The parens relevant here are the ones for precedence overrides.
And Comma is pretty low, so it almost always needs parens around it to
form lists. In particular it is below = and friends.
The above is more commonly written
The former implementation can be shortened:
sub uniq {
my %h;
return grep { ! $h{$_}++ } @_;
}
But realize that none of the proposed solutions (which are based on
hashes for computing the return) is amenable to the extension Ingo
called for with comparator blocks.
Adriano.
quoting Damian's original mail[1]:
> uniq - remove duplicates without reordering
^^
Would not that mean the original order of the first ocurrence is
preserved? This is what Ruby Array#uniq does:
[4,1,2,4,2,3,5].uniq => [ 4, 1, 2, 3, 5]
The b
Hi,
Mark Overmeer wrote:
> * Ingo Blechschmidt ([EMAIL PROTECTED]) [050519 16:52]:
>> Should it be possible to give an own comparator block, similar as
>> with grep? E.g.
>> uniq ; #
>>
>> uniq:{ abs $^a == abs $^b } 42, 23, -23, 23, 42
>> # 42, 23, 42
>
> 'uniq' d
[EMAIL PROTECTED] wrote:
I don't think that a role has a long and a short name. This is
because they aren't subject to MMD. I think of them more as
beeing expanded like C++ templates even though the actual mechanism
will be much more sophisticated. Actually I think of them as F-bounds
as well ;)
Uh
* Ingo Blechschmidt ([EMAIL PROTECTED]) [050519 16:52]:
> Should it be possible to give an own comparator block, similar as with
> grep? E.g.
> uniq ; #
>
> uniq:{ abs $^a == abs $^b } 42, 23, -23, 23, 42
> # 42, 23, 42
'uniq' differs from 'sort' because there is no
Hi,
while writing a preliminary p6explain, I wondered if the following
should work:
my $text = "aBc";
$text ~~ s/B/{ "C"|"D" }/;
say $text.values; # aCc aDc
This would be extremely handy for p6explain, as I'm currently parsing a
datafile which looks like...
+
Standard mathematical inf
Miroslav Silovic wrote:
Uhm, but C++ templates are subject to (compile-time) MMD, once you
specialise them. In other words,
role Something[Int $num] {...}
role Something[String $num] {...}
Hmm, C++ has no free floating templates. They always template a
class/struct or a function. The Perl6 equiva
On 5/18/05, Anthony Heading <[EMAIL PROTECTED]> wrote:
> Is there a way to target hyperoperators at different axes of a
> multi-dimensional array? This is an attractive feature of
> various APL-like languages, viz. e.g. in J:
>
> a =. 2 5 $ i. 7 - a simple 2-by-5 array
> a
> 0 1 2 3
On 5/19/05, Edward Cherlin <[EMAIL PROTECTED]> wrote:
> It turns out that the domain and range and the location of the
> cut lines have to be worked out separately for different
> functions. Mathematical practice is not entirely consistent in
> making these decisions, but in programming, there seem
On 5/19/05, Martin Kuehl <[EMAIL PROTECTED]> wrote:
> I have tried, but I can't make myself like it.
I'm afraid I have to agree.
When I saw it used in code after this discussion (I think it must have
been somewhere in pugs t/ or ext/) my reaction was "yuck".
(for what it's worth)
Carl
Hi,
Rod Adams wrote:
>>I wondered what uniq's default comparator should be, =:=?
> I'd have gone with ~~
Even better. :)
--Ingo
--
Linux, the choice of a GNU | Row, row, row your bits, gently down the
generation on a dual AMD | stream...
Athlon!|
Ingo Blechschmidt wrote:
I meant: The colon should still act as the delimiter between the params
which account to the long name of the role and those which don't, but
otherwise the syntax should be the same as the standard subroutine
signature syntax, allowing optional params, etc.
I don't think th
Ingo Blechschmidt wrote:
Hi,
three quick questions:
Since Aaron is still getting up to speed, I'll take a stab at these.
Is it intentional that there's no uniq in the current S29[1] draft?
See [2] for Damian saying that uniq is probably in.
Just hasn't been entered.
I wondered what uniq's def
Hi,
three quick questions:
Is it intentional that there's no uniq in the current S29[1] draft?
See [2] for Damian saying that uniq is probably in.
I wondered what uniq's default comparator should be, =:=?
Should it be possible to give an own comparator block, similar as with
grep? E.g.
uniq ;
On Wed, 18 May 2005, Rob Kinyon wrote:
On 5/18/05, Stuart Cook <[EMAIL PROTECTED]> wrote:
To summarise what I think everyone is saying, []-reducing an empty
list yields either:
1) undef (which may or may not contain an exception), or
2) some unit/identity value that is a trait of the operator,
depe
Hi,
"TSa (Thomas SandlaÃ)" wrote:
> you wrote:
>> I wondered if it would be useful/good/nice if the syntax for
>> specifying role parameters would be the same as the standard
>> subroutine signature syntax (minus the colon, which
>> separates the parameters which do account to the long name
>> of
HaloO Ingo,
you wrote:
I wondered if it would be useful/good/nice if the syntax for
specifying role parameters would be the same as the standard
subroutine signature syntax (minus the colon, which
separates the parameters which do account to the long name
of the role from the ones which don't).
On 5/15/05, Juerd <[EMAIL PROTECTED]> wrote:
> A few days ago, when typing ./pugs,... You can guess the rest :)
>
> I suggest
>
> ./method
>
> to mean $?SELF.method, and
>
> ../method
>
> to mean $?SELF.SUPER::method, or however that's normally written.
>
> This syntax doesn't clash w
Hi,
I wondered if it would be useful/good/nice if the syntax for
specifying role parameters would be the same as the standard
subroutine signature syntax (minus the colon, which
separates the parameters which do account to the long name
of the role from the ones which don't).
E.g.:
rol
Michele Dondi wrote:
On Wed, 18 May 2005, Rob Kinyon wrote:
1) undef (which may or may not contain an exception), or
2) some unit/identity value that is a trait of the operator,
I think that the unit/identity/neutral value is a trait of the
operator *and* the type of the values which are expected f
On Wednesday 18 May 2005 17:57, Matt Fowles wrote:
> All~
>
> What does the reduce metaoperator do with an empty list?
Here is the last answer from Ken Iverson, who invented reduce in
the 1950s, and died recently.
file:///usr/share/j504/system/extras/help/dictionary/intro28.htm
Identity Functions
There was a discussion of the principal value of square root on
this list some time back, making the point that for positive
real numbers the positive square root is the value of the
standard function. In the complex plane it is desirable to
define the principal value at every point so as to pr
On Wed, 18 May 2005, Rob Kinyon wrote:
1) undef (which may or may not contain an exception), or
2) some unit/identity value that is a trait of the operator,
depending on whether or not people think (2) is actually a good idea.
I would think that the Principle of Least Surprise points to (1),
I don'
On Wed, 18 May 2005, Matt Fowles wrote:
All~
What does the reduce metaoperator do with an empty list?
Interesting. Mathematically an empty sum is zero and an empty product is
one. Maybe each operator {c,s}hould have an associated method returning
its neutral element for [] to use it on empty list
On Sat, May 07, 2005 at 01>00>08PM -0700, Larry Wall wrote:
> On the other hand, since we've distinguished hyperops on
> infixes from hyperops on unaries, maybe an infix hyperop in
> unary position just does the thing to itself:
>
> @squares = Â*Â @list;
>
> which gives us a sum-of-squares tha
Is there a way to target hyperoperators at different axes of a
multi-dimensional array? This is an attractive feature of
various APL-like languages, viz. e.g. in J:
a =. 2 5 $ i. 7 - a simple 2-by-5 array
a
0 1 2 3 4 - like this
5 6 0 1 2
+/"1 a - sum reduc
50 matches
Mail list logo