mpiling -e
>>> Whitespace required before <= operator
>>> at -e:1
>>> --> say 1, 1, * + * ...^ *<= 100;⏏
>>> expecting any of:
>>> postfix
>>>
>>> and
>>> $ raku -e 'say 1, 1, * + * ...^ * <= 100;'
>&g
1, 1, * + * ...^ * >= 100;'
>> (1 1 2 3 5 8 13 21 34 55 89)
>>
>> So, then it dawned on me that the '>=' is "binding" (right word?) to the
>> "*" marking the end of the sequence as "until I am ge 100". Though that
>> doesn't quite wor
. Though that
> doesn't quite work,
> $ raku -e 'say 1, 1, * + * ...^ * <= 100;'
> ()
>
> Ah, I see, it does work. The end of the sequence is the first number less
> than 100, so 1 succeeds. I guess the sequence never gets started.
> --
> *
_
From: yary
Sent: Tuesday, August 24, 2021 8:39 PM
To: William Michels
Cc: Marc Chantreux ; raku-users
Subject: Re: [better solution] pairs of separators from a string
CAUTION - EXTERNAL:
Hi Bill,
When building a range that's an arithmetic or geometric progressio
Hi Bill,
When building a range that's an arithmetic or geometric progression, the
sequence operator is a little quicker to type. And thus also more likely to
be understood more quickly too.
> ('a' .. 'h')[(0..*-1).grep: * %% 2 ]
(a c e g)
> ('a' .. 'h')[ 0, 2 ... * ]
(a c e g)
> ('a' ..
Hi Marc,
My understanding is that ranges are pretty cheap to construct, and in any
case, the range @x[0..*-1] is just the index of all elements in @x. The
.grep() approach may be most useful if you have a function (e.g. %, %%, and
.is-prime shown below):
> (0...9)
(0 1 2 3 4 5 6 7 8 9)
>
hello everyone,
I made a mistake while replying to all of us so anwsers never reached
your boxes. I'll summerize in one answer:
Bill:
> Is it just even/odd elements that you want to separate out? If so, maybe
> .grep() is your friend here
I don't think it is: 0, 2 ... * seems to be
* closer
A little more of Vadim's example
> my $a = ; say $a.raku;
("a", "b", "c")
> my @a = ; say @a.raku;
["a", "b", "c"]
> @a[1]='X'; say @a.raku;
["a", "X", "c"]
> $a[1]='X'
Cannot modify an immutable List ((a b c))
in block at line 1
$a is a scalar container, holds one thing. In this example a
Sigils mean a lot. For example, they create a context:
my $a = 1,2,3;
my @a = 1,2,3;
$a = ; say $a.raku;
@a = ; say @a.raku;
If you have some (actually, a lot of) spare time you can watch my class from
TRC2021 where I cover a lot about symbols/sigils/object interaction in Raku:
Hi Marc!
Is it just even/odd elements that you want to separate out? If so, maybe
.grep() is your friend here:
> my $string0 = q!""''(){}[]!
""''(){}[]
> $string0.comb[(0..*-1).grep(* %% 2)].say;
(" ' ( { [)
> $string0.comb[(0..*-1).grep(* % 2)].say;
(" ' ) } ])
It sounds like you have some
On Sunday, August 22, Marc Chantreux wrote:
> my ($a, $b) = { @^a[0,2...Inf], @a[1,3...Inf] }.(q<(){}[]>.comb); say $a[0];
> say $b[0]
>
> oh. i never see this direct call of a lambda before but it really makes
> sense! this is the answer i like the most.
I think it's possible to avoid the
On Sun, Aug 22, 2021 at 2:58 PM Marc Chantreux wrote:
> so of course i tried
>
> my (@a, @b) = { .[0,2…∞], .[1,3…∞] }.(q.comb);
>
> because i have two lists and two containers. this doesn't work.
> which means @ and $ combines with = to define how things are stored
> but i don't understand how
hello William,
> your string, or whether-or-not some might be nested within each other. You
> show a lone ampersand ("&") at the beginning of your example, but other
> strings may not be so simple.
really sorry about this artefact from previous attempts :(
> > $string.comb(/ ( <:Ps> ~ <:Pe> .?)
hello Yary,
> and my instinct is that "map" is adding a layer you don't need or want for
> this issue, should just be sending the results of comb to a block. But I
> can't quite get the syntax right (and docs.raku.org seems down at the
> moment)
With this and what i understood from Vladim, i
thanks everyone for sharing,
Vadim,
my ($a, $b) = { @^a[0,2...Inf], @a[1,3...Inf] }.(q<(){}[]>.comb); say $a[0];
say $b[0]
oh. i never see this direct call of a lambda before but it really makes
sense! this is the answer i like the most.
i rewrote it my way and this works
my ($a, $b) = {
Hi Marc (and yary)!
I'll give this a shot, focusing on bracket pairs. It's not clear from your
question whether there's any inherent order to the bracket characters in
your string, or whether-or-not some might be nested within each other. You
show a lone ampersand ("&") at the beginning of your
I guess you need something like this:
my ($a, $b) = { @^a[0,2...Inf], @a[1,3...Inf] }.(q<(){}[]>.comb); say $a; say $b
Best regards,
Vadim Belman
> On Aug 21, 2021, at 3:04 AM, Marc Chantreux wrote:
>
> hello,
>
> i would like to get the list of opening (α) and closing
> (ω) separators
This reminds me of "the comma rule" which I haven't quite internalized yet.
This gets a little closer
map { .[0,2…∞], .[1,3…∞] }, ("012345".comb,)
(((0 2 4) (1 3 5)))
and my instinct is that "map" is adding a layer you don't need or want for
this issue, should just be sending the results of comb
hello,
i would like to get the list of opening (α) and closing
(ω) separators from this string:
&""''(){}[]
too many years of perl made me think about this solution
or something alike but it didn't work.
my (\α,\ω) =| map
{ .[0,2…∞], .[1,3…∞] },
q&""''(){}[]&.comb;
fixing this is
19 matches
Mail list logo