Re: .contains question

2023-12-11 Thread Andy Bach
>  I have found that when using `say` for debugging, it has been known to print 
> out the
> previous value of a variable and not the current value.  `print` does not do 
> this.

That would certainly be a surprise to me. I'd think I was misunderstanding my 
program, rather than a bug in say.

From: ToddAndMargo via perl6-users 
Sent: Monday, December 11, 2023 3:24 PM
To: perl6-users@perl.org 
Subject: Re: .contains question

CAUTION - EXTERNAL:


> "so" will collapse the junction into a Bool.
> "say" will append a \n for you, so you don't have to.
>
>> On 11 Dec 2023, at 01:52, ToddAndMargo via perl6-users 
>>  wrote:
>>
 On 10 Dec 2023, at 21:36, ToddAndMargo via perl6-users 
  wrote:

 Hi All,

 my Str $x="abc3defg"; if $x.contains( "a" || "b" || "3" )  { print 
 "True\n"; } else { print "False\n" };
 True

 Is there a way to tell .contains that you want to know
 if any of a sequence characters is in a string other that
 repeating || over and over.  Any [a..z] or [0..9] option?

 Many thanks,
 -T
>>
>> On 12/10/23 15:24, Elizabeth Mattijsen wrote:
>>> my @letters = ;
>>> if $x.contains(any @letters) {
>>
>>
>> Hi Elizabeth,
>>
>> Very interesting.  Problem: I was looking for one answer, not many
>>
>>> my $x="abc45def";my @y=; print 
>>> $x.contains(any @y) ~ "\n";
>> True
>> True
>> True
>> True
>> True
>> True
>> False
>> False
>> False
>> False
>> False
>> False
>> False
>> True
>> True

On 12/11/23 01:11, Elizabeth Mattijsen wrote:
 > my $x="abc45def";
 > my @y=; say so $x.contains(any @y);

Hi Elizabeth,

Awesome!  Thank you!

I usually stay away from `say` as in my longer programs, I have found
that when using `say` for debugging, it has been known to print out the
previous value of a variable and not the current value.  `print` does
not do this.  This is why you see me using `print` so often.  And
I can type, so the extra finger motions do not bother me.  Capitol
letter also do not for the same reason.

Some tests!

my $x="abc45def"; my @y=; say so
$x.contains(any @y);
True

my $x="abc45def"; my @y=; say so $x.contains(any @y);
False

my $x="abc45def"; my @y=; say so $x.contains(any @y);
True

my $x="abc45def"; my @y=; say so $x.contains(any @y);
False


Oh now I am really pushing it with these (note the `all` in the
second one)!


my $x="abc45def"; say so $x.contains(any );

my $x="abc45def"; say so $x.contains(all );
False

my $x="abc45def"; say so $x.contains(any );
True


-T




CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: A question on AND

2023-06-30 Thread Andy Bach
my $answer = $choice_1 or $choice_2; # this is  wrong it turns into
(my $answer = $choice_1) # or $choice_2

> there $choice_2 is only evaluated if the $answer got assigned a false
value, and then it gets evaluated in void context, discarding its value.
> Try this in Raku - what does it say? Do you still prefer "or" over "||" ?
my $answer = 0 or 5;

Well, if I were ever to write code like that, I'd not use "or" but ... I
can't recall this coming up.  I was just commenting on Perl having the same
difference in usage of those operators.

On Fri, Jun 30, 2023 at 10:14 AM yary  wrote:

> @a = @b || @c;  # this is wrong
> @a = scalar(@b) || @c;  # really meant this
>
> "or" doesn't help with this either
>
> @a = @b or @c;  # this is wrong
> (@a = scalar(@b)) or @c;  # really meant this - @c never is
> assigned to @Helen Block 
>
> the low precedence and/or is was introduced in Perl 5 for this construction
>
> open my $fh '<', $input_filename or die "Could not open $input_filename:
> $!";
>
> At $work I see bugs where people are using "or" "and" in expressions, and
> the part after the expression never gets into the variable they meant it to.
>
> my $answer = $choice_1 or $choice_2; # this is  wrong it turns into
> (my $answer = $choice_1) # or $choice_2
>
> there $choice_2 is only evaluated if the $answer got assigned a false
> value, and then it gets evaluated in void context, discarding its value.
>
> Try this in Raku - what does it say? Do you still prefer "or" over "||" ?
>
> my $answer = 0 or 5;
>
> say $answer;
>
>
> -y
>
>
> On Fri, Jun 30, 2023 at 10:53 AM Andy Bach 
> wrote:
>
>> I  always took [1]
>>  As alternatives to "&&" and "||" when used for control flow, Perl
>> provides
>> the "and" and "or" operators (see below). The short-circuit behavior
>> is
>> identical. The precedence of "and" and "or" is much lower, however, so
>> that you can safely use them after a list operator without the need
>> for
>> parentheses
>>
>> to suggest that and and or are the better ones to use and && or || should
>> be used only if they're specifically needed.  Which has always been "never"
>> for me.
>>
>> a
>>
>> [1]
>> perldoc perlop
>>The "||", "//" and "&&" operators return the last value evaluated
>> (unlike
>> C's "||" and "&&", which return 0 or 1). Thus, a reasonably portable
>> way
>> to find out the home directory might be:
>>
>> $home =  $ENV{HOME}
>>   // $ENV{LOGDIR}
>>   // (getpwuid($<))[7]
>>   // die "You're homeless!\n";
>>
>> In particular, this means that you shouldn't use this for selecting
>> between two aggregates for assignment:
>>
>> @a = @b || @c;  # this is wrong
>> @a = scalar(@b) || @c;  # really meant this
>> @a = @b ? @b : @c;  # this works fine, though
>>
>> As alternatives to "&&" and "||" when used for control flow, Perl
>> provides
>> the "and" and "or" operators (see below). The short-circuit behavior
>> is
>> identical. The precedence of "and" and "or" is much lower, however, so
>> that you can safely use them after a list operator without the need
>> for
>> parentheses:
>>
>> unlink "alpha", "beta", "gamma"
>> or gripe(), next LINE;
>>
>> With the C-style operators that would have been written like this:
>>
>> unlink("alpha", "beta", "gamma")
>> || (gripe(), next LINE);
>>
>> It would be even more readable to write that this way:
>>
>> unless(unlink("alpha", "beta", "gamma")) {
>> gripe();
>> next LINE;
>> }
>>
>> Using "or" for assignment is unlikely to do what you want; see below.
>>
>> --
>> *From:* yary 
>> *Sent:* Friday, June 30, 2023 8:45 AM
>> *To:* Richard Hainsworth 
>> *Cc:* perl6-users@perl.org 
>> *Subject:* Re: A question on AND
>>
>>
>> *CAUTION - EXTERNAL: *
>> Most of Rich

Re: A question on AND

2023-06-30 Thread Andy Bach
I  always took [1]
 As alternatives to "&&" and "||" when used for control flow, Perl provides
the "and" and "or" operators (see below). The short-circuit behavior is
identical. The precedence of "and" and "or" is much lower, however, so
that you can safely use them after a list operator without the need for
parentheses

to suggest that and and or are the better ones to use and && or || should be 
used only if they're specifically needed.  Which has always been "never" for me.

a

[1]
perldoc perlop
   The "||", "//" and "&&" operators return the last value evaluated (unlike
C's "||" and "&&", which return 0 or 1). Thus, a reasonably portable way
to find out the home directory might be:

$home =  $ENV{HOME}
  // $ENV{LOGDIR}
  // (getpwuid($<))[7]
  // die "You're homeless!\n";

In particular, this means that you shouldn't use this for selecting
between two aggregates for assignment:

@a = @b || @c;  # this is wrong
@a = scalar(@b) || @c;  # really meant this
@a = @b ? @b : @c;  # this works fine, though

As alternatives to "&&" and "||" when used for control flow, Perl provides
the "and" and "or" operators (see below). The short-circuit behavior is
identical. The precedence of "and" and "or" is much lower, however, so
that you can safely use them after a list operator without the need for
parentheses:

unlink "alpha", "beta", "gamma"
or gripe(), next LINE;

With the C-style operators that would have been written like this:

unlink("alpha", "beta", "gamma")
|| (gripe(), next LINE);

It would be even more readable to write that this way:

unless(unlink("alpha", "beta", "gamma")) {
gripe();
next LINE;
}

Using "or" for assignment is unlikely to do what you want; see below.


From: yary 
Sent: Friday, June 30, 2023 8:45 AM
To: Richard Hainsworth 
Cc: perl6-users@perl.org 
Subject: Re: A question on AND

CAUTION - EXTERNAL:

Most of Richard's parting suggestions I understand & agree with, but not this: 
" why are you using '&&' and not 'and' "

My habit (from Perl 5 days) is to use && || for expressions, and reserve "and" 
"or" for "do this if assignment/function call without parens succeeds/fails" – 
is there a refinement on that distinction in Raku which I should pay attention 
to?

-y


On Fri, Jun 30, 2023 at 5:40 AM Richard Hainsworth 
mailto:rnhainswo...@gmail.com>> wrote:

I tried this and it worked without any problem.

Here's the whole program:

use v6.d;
say @*ARGS.raku;
if @*ARGS.elems > 0  &&  "@*ARGS[0]".lc eq "debug"  {
say 'got'
}
and at the terminal:

$ raku todd-test.raku debug --debug=50
["debug", "--debug=50"]
got


FWIW
why are you quoting ARGS? The .lc coerces to string anyway.
why are you using && and not 'and'
why are you not using a sub MAIN with an optional --debug
eg. sub MAIN( @args, Bool :$debug=False) {
#stuff
if $debug { ... }




On 30/06/2023 06:06, ToddAndMargo via perl6-users wrote:
if @*ARGS.elems > 0  &&  "@*ARGS[0]".lc eq "debug"  {...}
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: Tip: Rakudo-2023.05.01 upgrade issue

2023-06-11 Thread Andy Bach
Pretty sure this is the problem:
Failed to create directory
…
with mode '0o777': Failed to mkdir: Permission denied

Not the pkg. Possibly the dir was root owned, say, and the install was
being run by a non-root user.

On Sun, Jun 11, 2023 at 1:26 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Hi All,
>
> Fedora 37
> RakudoPkgFedora37-2023.05.01.x86_64.rpm
> https://github.com/nxadm/rakudo-pkg/releases
>
> I just up graded to 2023.05.01 and nothing pl6
> worked.  Upon investigation:
>
>
> $ GetUpdates.pl6
> ===SORRY!=== Error while compiling /home/linuxutil/./GetUpdates.pl6
> Failed to create directory
> '/home/linuxutil/p6lib/.precomp/3A2B42ADB91D64FCB1BEADCC940D6B244D102F22/AB'
>
> with mode '0o777': Failed to mkdir: Permission denied
> at /home/linuxutil/./GetUpdates.pl6:6
>
>
> Erasing .precomp cured the issue.  The first run of
> a pl6 program after that took about a minute to
> compile, but after that happy camping returned.
>
> HTH someone else,
> -T
>
-- 
Andy Bach
afb...@gmail.com
Not at my desk


Re: Easier way to load a buffer?

2022-06-13 Thread Andy Bach
> You could think: what does "comb(2)" do?  Perhaps look at the documentation?  
> And then maybe realize that Simon forgot that the comb(2) should be a method 
> on $hex?  Otherwise, how would it know what to parse?

Ah, I did wonder why $hex wasn't in the 2nd line in any way.
> my $hex = "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78";
2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78
> my Buf $b=Buf.new($hex.comb(2).map( *.parse-base(16) ));
Buf:0x<2A 54 FF 53 A5 F1 D3 6F 1C EA 7E 61 FC 37 A2 0D 54 A7 7F E7 B7 08>

So, take $hex 2 at a time and run that through the parse-base(16), assigning it 
to $buf

From: Elizabeth Mattijsen 
Sent: Friday, June 10, 2022 5:28 PM
To: ToddAndMargo via perl6-users 
Subject: Re: Easier way to load a buffer?

CAUTION - EXTERNAL:


> On 10 Jun 2022, at 23:28, ToddAndMargo via perl6-users  
> wrote:
>
>>> On Fri, 10 Jun 2022 at 15:49, ToddAndMargo via perl6-users 
>>> mailto:perl6-users@perl.org>> wrote:
>>>Hi All,
>>>I am looking for an easier way to load a buffer.
>>>I know about this way
>>>[4] > my Buf $b=Buf.new(0x2A, 0x54, 0xFF, 0x53);
>>>Buf:0x<2A 54 FF 53>
>>>I would like to do it on one big blast:
>>>my Buf $b=Buf.new(0x2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78);
>>>Cannot unbox 170 bit wide bigint into native integer
>>>But do not know the proper syntax.
>>>Any words of wisdom?  Am I stuck with the hard way?
>>>Many thanks,
>>>-T
>
> On 6/10/22 08:36, Simon Proctor wrote:
>> So Buf is expecting a list of integers. If' you've got one long one in a 
>> string like "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78" you want to split 
>> it into smaller values so something like this?
>> my $hex = "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78";
>> my Buf $b=Buf.new(comb(2).map( *.parse-base(16) ));
>> Which does the trick I think.
>
>
> [0] > my $hex = "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78";
> 2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78
> [1] > my Buf $b=Buf.new(comb(2).map( *.parse-base(16) ));
> ===SORRY!=== Error while compiling:
> Calling comb(Int) will never work with signature of the proto ($, $, $?, *%)
> --> my Buf $b=Buf.new(⏏comb(2).map( *.parse-base(16) ));
> [1] >

You could think: what does "comb(2)" do?  Perhaps look at the documentation?  
And then maybe realize that Simon forgot that the comb(2) should be a method on 
$hex?  Otherwise, how would it know what to parse?

I know it is hard to think when you're in a hurry.  But you should really learn 
to be able to read code, instead of copying examples only and not understanding 
*how* they work.
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: shell to raku

2022-01-03 Thread Andy Bach
> raku is now my tool of choice when
* manipulexity is important

I had to look it up
Larry Wall: Manipulexity and Whipuptitude - Fortune
If you were a Unix programmer you either programmed in C or shell. And there 
really wasn't much in between. There were these little languages that we used 
on top of shell, but that was the big divide. The big revelation that hatched 
Perl, as it were, was that this opened up into a two-dimensional space. And C 
was good at something I like to call manipulexity, that is the manipulation of 
complex things. While shell was good at something else which I call 
whipuptitude, the aptitude for whipping things up.

So Perl was hatched. As a small egg. That was Perl 1. And it was designed from 
the very beginning to evolve. The fact that we put sigils in front of the 
variables meant that the namespaces were protected from new keywords. And that 
was intentional, so we could evolve the language fairly rapidly without 
impacting.

And it evolved… And it evolved… And finally we got to Perl 5. And… So… Perhaps 
the Perl 6 slogan should be "All Your Paradigms Are Belong To Us". We'll get to 
that.
https://www.shlomifish.org/humour/fortunes/show.cgi?id=larry-wall-big-divide

From: Marc Chantreux 
Sent: Friday, December 31, 2021 7:43 AM
To: Wesley Peng 
Cc: perl6-users 
Subject: shell to raku

CAUTION - EXTERNAL:


Le Fri, Dec 31, 2021 at 01:20:45PM +, Wesley Peng a écrit :
> Replacing Bash scripts with Raku? That’s an interesting thing

Well ... replacing bash is always a good thing but raku is not
always the rhs of the substitution (could be dash/mksh/rc,
make/mk, C, ...).

raku is now my tool of choice when

* manipulexity is important
* performance is not

The way i see the talk is:

* show how to do simple things ($PATH vs $RAKULIB, ...)
* show similarities (if you're confortable with feature X,
  then raku's Y will makes you happy)
* show some pro and cons (Shell vs Raku)

> Can Linux be shipped with Raku by default?

apt install rakudo

Is possible from the stable debian but i don't think it's a good idea
to have it as part of the default install (in a sense that there should
be nothing bigger than dash/busybox/toybox in the default install).
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: junctions with given/when

2021-11-02 Thread Andy Bach
> I'd thought that that would confirm that both elements were Int:
  say do given all(3,7) { when Int { "both are Int" }; default {"not similar"} 
};
  ## not similar

I get a different result
 $ raku -e '  say do given all(3,7) { when Int { "both are Int" }; default 
{"not similar"} };'
both are Int

 $ raku -e '  say do given all(3,"x") { when Int { "both are Int" }; default 
{"not similar"} };'
not similar

$ raku -e '  say do given all(3,7) { when Int { $_ }; default {"not similar"} 
};'
all(3, 7)

$ raku -v
This is Rakudo version 2020.05.1 built on MoarVM version 2020.05

From: Joseph Brenner 
Sent: Tuesday, November 2, 2021 11:45 AM
To: perl6-users 
Subject: junctions with given/when

CAUTION - EXTERNAL:


A given/when construct using a junction isn't quite doing what I'd expect.

I'd thought that that would confirm that both elements were Int:

  say do given all(3,7) { when Int { "both are Int" }; default {"not
similar"} };
  ## not similar

But this does what I thought it would:

  say so do all(3,7) ~~ Int;
# True

And the given seems to put the junction in $_ as expected:

  given all(3,7) { say $_; say $_.WHAT; }
# all(3, 7)
# (Junction)

And you can use that junction in a smartmatch explicitly

  given all(3,7) { say so $_ ~~ Numeric; }
# True
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: can u suggest a beginner book for perl6?

2021-10-01 Thread Andy Bach
Check out the following GitHub repo - it has a Perl6 and a Raku section, along 
with pretty much every other language!

https://github.com/EbookFoundation/free-programming-books/blob/master/books/free-programming-books-langs.md#perl
[https://opengraph.githubassets.com/b8cc5d706ff4a4449188940b96e66bb3dc092d64b1c4e51d9b8375166bf81503/EbookFoundation/free-programming-books]
free-programming-books/free-programming-books-langs.md at master · 
EbookFoundation/free-programming-books
:books: Freely available programming books. Contribute to 
EbookFoundation/free-programming-books development by creating an account on 
GitHub.
github.com


From: Elizabeth Mattijsen 
Sent: Wednesday, September 29, 2021 7:26 AM
To: perl6-users@perl.org 
Subject: Re: can u suggest a beginner book for perl6?

CAUTION - EXTERNAL:


Perhaps Think Raku: https://greenteapress.com/wp/think-perl-6/ ?

> On 29 Sep 2021, at 14:18, Walt CH  wrote:
>
> I have some ruby programming experience, and some JS.
> can you suggest a book for newbie of perl6?
>
> Thanks

CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: [better solution] pairs of separators from a string

2021-08-25 Thread Andy Bach
I "misread"
say 1, 1, * + * ...^ *>= 100;

thinking "shouldn't it be '<=' as you want the total to be less than 100?" but
$ raku -e 'say 1, 1, * + * ...^ *<= 100;'
===SORRY!=== Error while compiling -e
Whitespace required before <= operator
at -e:1
--> say 1, 1, * + * ...^ *<= 100;⏏
expecting any of:
postfix

and
$ raku -e 'say 1, 1, * + * ...^ * <= 100;'
()
$ raku -e 'say 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 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 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' .. 'h')[(0..*-1).grep: * % 2 ]
(b d f h)
> ('a' .. 'h')[1, 3...*]
(b d f h)

# Geometric example- powers of 2
> ('a' .. 'z')[1, 2, 4...*]
(b c e i q)

There isn't a simple translation for the is-prime example that I can think of, 
that is a good use for "grep"

Ranges also support arbitrary functions, the doc page shows a Fibonacci number 
generator
https://docs.raku.org/language/operators#index-entry-sequence_operator
"This allows you to write

say 1, 1, * + * ...^ *>= 100;
# OUTPUT: «(1 1 2 3 5 8 13 21 34 55 89)␤»

to generate all Fibonacci numbers up to but excluding 100."



-y


On Tue, Aug 24, 2021 at 6:36 PM William Michels via perl6-users 
mailto:perl6-users@perl.org>> wrote:
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)
> (0...9)[0..*-1]
(0 1 2 3 4 5 6 7 8 9)
> (0...9)[(0..*-1).grep: * ]
(0 1 2 3 4 5 6 7 8 9)
> (0...9)[(0..*-1).grep: * %% 2 ]
(0 2 4 6 8)
> (0...9)[(0..*-1).grep: * % 2 ]
(1 3 5 7 9)
> (0...9)[(0..*-1).grep: *.is-prime ]
(2 3 5 7)
>

You can find a related example in the docs ( 
https://docs.raku.org/routine/grep#class_HyperSeq). Anyway, I'm sure each 
approach has its fans,

Best, Bill.

On Tue, Aug 24, 2021 at 3:59 AM Marc Chantreux 
mailto:e...@phear.org>> wrote:
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 to what i have in mind when i think about the problem
  (so i invoke readability there)
* probably more efficient than (0..*).grep(* % 2) that
  * generate twice the number of required elements
  * need to filter the result

Also, trying to play with this version:

my ($a,$b) =
.[0,2...*],
.[1,3...*]
with .comb;

just don't work because the lists are squashed into scalar context
in the process.

So Brian and Fernando made my day with := and the unexpected power of
the [] operator.

my (@a,@b) := .comb[ [0,2...*], [1,3...*] ];

I really like how declarative it is. Also the use of := now seems
obvious to me.

Sigils still remains something strange to me desprite all your examples
but i'll take some time. thanks everyone.

marc

CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: File::Find using a junction with exclude

2021-05-25 Thread Andy Bach
> It's a bug in the REPL. The example from the documentation works when
fed to the compiler directly

So is the error
Cannot find method 'qast' on object of type NQPMu

any use in finding the REPL bug?

From: William Michels via perl6-users 
Sent: Tuesday, May 25, 2021 4:04 PM
To: perl6-users@perl.org 
Subject: Re: File::Find using a junction with exclude

CAUTION - EXTERNAL:

Well spotted, Gianni!

user@mbook:~$ raku -e 'my int $x = 2⁶³-1;say ++$x;'
-9223372036854775808
user@mbook:~$ raku --version
Welcome to 퐑퐚퐤퐮퐝퐨™ v2020.10.
Implementing the 퐑퐚퐤퐮™ programming language v6.d.
Built on MoarVM version 2020.10.


On Tue, May 25, 2021 at 8:38 AM Gianni Ceccarelli 
mailto:dak...@thenautilus.net>> wrote:
On Tue, 25 May 2021 15:16:03 +0000
Andy Bach mailto:andy_b...@wiwb.uscourts.gov>> 
wrote:

> > However I had to use "Int" instead of "int":
> Ah, "int" is the "lower" level, native integer and "Int" is the raku.
> An "int" is immutable or something?

It's a bug in the REPL. The example from the documentation works when
fed to the compiler directly::

  $ raku -e 'my int $x = 2⁶³-1;say ++$x;'
  -9223372036854775808

--
Dakkar - 
GPG public key fingerprint = A071 E618 DD2C 5901 9574
 6FE2 40EA 9883 7519 3F88
key id = 0x75193F88

CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: File::Find using a junction with exclude

2021-05-25 Thread Andy Bach
> However I had to use "Int" instead of "int":

Ah, "int" is the "lower" level, native integer and "Int" is the raku. An "int" 
is immutable or something? The page
https://docs.raku.org/language/numerics#Native_numerics

has:
my int $x = 2⁶³-1;
say $x; # OUTPUT: «9223372036854775807␤»
say ++$x;   # OUTPUT: «-9223372036854775808␤»

But I see
> my int $x = 2⁶³-1
9223372036854775807
> say $x
9223372036854775807
> say ++$x
Cannot find method 'qast' on object of type NQPMu

 NQP (Not Quite Perl) Mu has no "qast" method - qast is the successor to past, 
Parrot AST and AST is Abstract Syntax Tree. I guess $x *is * the int, not an 
container/variable holding an int value.

Man, there's a lot I don't know about raku!  That section on colon pairs 
cleared up a lot.

From: William Michels 
Sent: Monday, May 24, 2021 11:47 PM
To: perl6-users 
Subject: Re: File::Find using a junction with exclude

CAUTION - EXTERNAL:

Hi Andy,

A quick test with my (older) Raku install and I was able to get one of the 
examples (Daniel's) below to work. However I had to use "Int" instead of "int":

user@mbook:~$ raku
Welcome to 퐑퐚퐤퐮퐝퐨™ v2020.10.
Implementing the 퐑퐚퐤퐮™ programming language v6.d.
Built on MoarVM version 2020.10.

To exit type 'exit' or '^D'
> my int $f = 0;
0
> sub foo($) { ++$f }('a' | 'b,b' | 'c');
Cannot find method 'qast' on object of type NQPMu

> my Int $g = 0;
0
> sub foo($) { ++$g }('a' | 'b,b' | 'c');
any(1, 2, 3)
>

HTH, Bill.


On Mon, May 24, 2021 at 2:40 PM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
> Cannot sent this email in 'plain text' mode as ATOM SYMBOL disappears.

I was impressed I could copypasted that in the text/terminal sesion of raku's 
REPL and have it work. As a matter of fact:
> sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
any(1, 2, 3)
> say $c;
3

but, trying it without the cabbage, er, atomic symbol
> my atomicint $d = 0;
0
>  sub foo($) { ++$d }('a'|'b,b'|'c');
Cannot find method 'qast' on object of type NQPMu

> my int $f = 0;
0
> sub foo($) { ++$f }('a' | 'b,b' | 'c');
Cannot find method 'qast' on object of type NQPMu

but my raku's a tad long in tooth
$ raku -v
This is Rakudo version 2020.05.1 built on MoarVM version 2020.05

From: William Michels mailto:w...@caa.columbia.edu>>
Sent: Monday, May 24, 2021 2:41 PM
To: perl6-users mailto:perl6-users@perl.org>>
Subject: Re: File::Find using a junction with exclude

CAUTION - EXTERNAL:

WATs are everywhere, and (I'm not trying to pick on one language
here), I find this SO question to be intruiging:

https://stackoverflow.com/q/58340585/7270649

Joseph (and Ralph): thanks for starting off this conversation!
Fernando and Vadim: amazed at your code!
Andy: good questions always welcome!

Daniel: Thank you for your confirmation on EVAL. Also, I tried parsing
the ATOM SYMBOL character to look at classification, and this is the
best I could do (in the Raku REPL):

> say "⚛".uniprop
So
> dd "⚛".comb>>.uniprop
("So",)
Nil
> say "{uniparse 'ATOM SYMBOL'}"
⚛
> say "{uniparse 'ATOM SYMBOL'}".uniprop
So
> say "{uniparse 'ATOM SYMBOL'}".uniprop('Alphabetic')
False

HTH, Bill.

PS. Cannot sent this email in 'plain text' mode as ATOM SYMBOL disappears.


On Mon, May 24, 2021 at 11:28 AM Daniel Sockwell 
mailto:dan...@codesections.com>> wrote:
> Oh, and WAT is [short for] "Weird/will Ass Thing"?

No, it's not an abbreviation for anything – it's the word "what", but 
pronounced in a way that
indicates the speaker is surprised/confused. More specifically, it's a 
reference to the WAT talk (a
really good one, even if it is about a different language)
https://www.destroyallsoftware.com/talks/wat

(All of that is pretty much strait from the glossary, by the way)
https://docs.raku.org/language/glossary#index-entry-WAT

– codesections
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.

CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: File::Find using a junction with exclude

2021-05-24 Thread Andy Bach
> Cannot sent this email in 'plain text' mode as ATOM SYMBOL disappears.

I was impressed I could copypasted that in the text/terminal sesion of raku's 
REPL and have it work. As a matter of fact:
> sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
any(1, 2, 3)
> say $c;
3

but, trying it without the cabbage, er, atomic symbol
> my atomicint $d = 0;
0
>  sub foo($) { ++$d }('a'|'b,b'|'c');
Cannot find method 'qast' on object of type NQPMu

> my int $f = 0;
0
> sub foo($) { ++$f }('a' | 'b,b' | 'c');
Cannot find method 'qast' on object of type NQPMu

but my raku's a tad long in tooth
$ raku -v
This is Rakudo version 2020.05.1 built on MoarVM version 2020.05

From: William Michels 
Sent: Monday, May 24, 2021 2:41 PM
To: perl6-users 
Subject: Re: File::Find using a junction with exclude

CAUTION - EXTERNAL:

WATs are everywhere, and (I'm not trying to pick on one language
here), I find this SO question to be intruiging:

https://stackoverflow.com/q/58340585/7270649

Joseph (and Ralph): thanks for starting off this conversation!
Fernando and Vadim: amazed at your code!
Andy: good questions always welcome!

Daniel: Thank you for your confirmation on EVAL. Also, I tried parsing
the ATOM SYMBOL character to look at classification, and this is the
best I could do (in the Raku REPL):

> say "⚛".uniprop
So
> dd "⚛".comb>>.uniprop
("So",)
Nil
> say "{uniparse 'ATOM SYMBOL'}"
⚛
> say "{uniparse 'ATOM SYMBOL'}".uniprop
So
> say "{uniparse 'ATOM SYMBOL'}".uniprop('Alphabetic')
False

HTH, Bill.

PS. Cannot sent this email in 'plain text' mode as ATOM SYMBOL disappears.


On Mon, May 24, 2021 at 11:28 AM Daniel Sockwell 
mailto:dan...@codesections.com>> wrote:
> Oh, and WAT is [short for] "Weird/will Ass Thing"?

No, it's not an abbreviation for anything – it's the word "what", but 
pronounced in a way that
indicates the speaker is surprised/confused. More specifically, it's a 
reference to the WAT talk (a
really good one, even if it is about a different language)
https://www.destroyallsoftware.com/talks/wat

(All of that is pretty much strait from the glossary, by the way)
https://docs.raku.org/language/glossary#index-entry-WAT

– codesections
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: File::Find using a junction with exclude

2021-05-24 Thread Andy Bach
> As to "this completely lost me": there was a mistype and "taking" shoud've 
> been "talking". Sorry for this.
No, that's wasn't what lost me, it was the code
('a' | 'b,b' | 'c')».&(-> $ { ++⚛$c });
>>  Oh, and WAT is" Weird/will Ass Thing"?
> "Weird/will Ass Thing" made me totally lost as I've no idea what this means.
Typo there, too s/b "Weird/Wild".  "WAT" was featured heavily in a previous 
post, in opposition to DWIM, which I took be Do What I Mean.


From: Vadim Belman 
Sent: Monday, May 24, 2021 9:31 AM
To: perl6-users 
Subject: Re: File::Find using a junction with exclude

CAUTION - EXTERNAL:


As to " but what's that cabbage thing before $c?": we have this great 
https://docs.raku.org site. And it has great search capability:

https://docs.raku.org/type/atomicint
https://docs.raku.org/language/unicode_ascii#index-entry-%E2%9A%9B

As to "this completely lost me": there was a mistype and "taking" shoud've been 
"talking". Sorry for this.

"Weird/will Ass Thing" made me totally lost as I've no idea what this means.

Best regards,
Vadim Belman

On May 24, 2021, at 10:11 AM, Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:

my atomicint $c = 0;
sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
say $c;

I was sort of hanging on by my fingertips (this completely lost me:
>Or, taking about tricks:

('a' | 'b,b' | 'c')».&(-> $ { ++⚛$c });

) but what's that cabbage thing before $c?  Oh, and WAT is" Weird/will Ass 
Thing"?

From: Vadim Belman mailto:vr...@lflat.org>>
Sent: Monday, May 24, 2021 8:53 AM
To: perl6-users mailto:perl6-users@perl.org>>
Subject: Re: File::Find using a junction with exclude

CAUTION - EXTERNAL:


Still ugly but much more reliable trick would be to use a sub and a counter 
variable:

my atomicint $c = 0;
sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
say $c;

Or, taking about tricks:

('a' | 'b,b' | 'c')».&(-> $ { ++⚛$c });

Apparently, this one is not ugly by semantics, but by its notation too. Also 
worth noting that the hyper-op is needed here because pointy blocks are not 
auto-threaded over junctions and take them as-is:

-> $v { say $v.WHAT }(1|2); # (Junction)

Best regards,
Vadim Belman

> On May 24, 2021, at 8:42 AM, Daniel Sockwell 
> mailto:dan...@codesections.com>> wrote:
>
>> It can be done without the EVAL:
>>
>>> any('a', 'b', 'c').raku.substr(4, *-1).split(',').elems
>>
>> 3
>
> Yeah, but only at the cost of some fragility:
>
>> any('a', 'b,b', 'c').raku.substr(4, *-1).split(',').elems
> 4
>
> I suppose you could do:
>
>> any('a', 'b,b', 'c').elems.raku.substr(4, *-1).split(',').elems
> 3
>
> but I'm not sure that's _that_ much better than EVAL – either way, we're 
> depending on the Str
> representation of inherently non-Str data, which seems like the main sin of 
> EVAL.
>
> – codesections
>

CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.

CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: File::Find using a junction with exclude

2021-05-24 Thread Andy Bach
my atomicint $c = 0;
sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
say $c;

I was sort of hanging on by my fingertips (this completely lost me:
>Or, taking about tricks:

('a' | 'b,b' | 'c')».&(-> $ { ++⚛$c });

) but what's that cabbage thing before $c?  Oh, and WAT is" Weird/will Ass 
Thing"?

From: Vadim Belman 
Sent: Monday, May 24, 2021 8:53 AM
To: perl6-users 
Subject: Re: File::Find using a junction with exclude

CAUTION - EXTERNAL:


Still ugly but much more reliable trick would be to use a sub and a counter 
variable:

my atomicint $c = 0;
sub foo($) { ++⚛$c }('a' | 'b,b' | 'c');
say $c;

Or, taking about tricks:

('a' | 'b,b' | 'c')».&(-> $ { ++⚛$c });

Apparently, this one is not ugly by semantics, but by its notation too. Also 
worth noting that the hyper-op is needed here because pointy blocks are not 
auto-threaded over junctions and take them as-is:

-> $v { say $v.WHAT }(1|2); # (Junction)

Best regards,
Vadim Belman

> On May 24, 2021, at 8:42 AM, Daniel Sockwell  wrote:
>
>> It can be done without the EVAL:
>>
>>> any('a', 'b', 'c').raku.substr(4, *-1).split(',').elems
>>
>> 3
>
> Yeah, but only at the cost of some fragility:
>
>> any('a', 'b,b', 'c').raku.substr(4, *-1).split(',').elems
> 4
>
> I suppose you could do:
>
>> any('a', 'b,b', 'c').elems.raku.substr(4, *-1).split(',').elems
> 3
>
> but I'm not sure that's _that_ much better than EVAL – either way, we're 
> depending on the Str
> representation of inherently non-Str data, which seems like the main sin of 
> EVAL.
>
> – codesections
>

CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: slurpy hash signatures

2021-04-19 Thread Andy Bach
Very impressive and complete explanation, thanks!
> I'm inclined to view it as pretty good. I also think it might be seriously 
> hard to improve.

As we're looking a known "trap" could this one append of those (my favorite 
kind) leading questions "Did you mean to pass ...?"

From: Ralph Mellor 
Sent: Sunday, April 18, 2021 11:59 PM
To: Joseph Brenner 
Cc: perl6-users 
Subject: Re: slurpy hash signatures

CAUTION - EXTERNAL:


On Sun, Apr 18, 2021 at 8:00 PM Joseph Brenner  wrote:
>
> Before I get started here, a small point about defining hashes.
> There are various ways that work:
>
>my %h1 = ( 'ha' => 1, 'ho' => 2, 'hum' => 3 );
>my %h2 = (  ha  => 1,  ho  => 2,  hum  => 3 );
>my %h3 =  ha => 1, ho => 2, hum => 3;
>my %h4 = 'ha' => 1, 'ho' => 2, 'hum' => 3;

Idiomatically, %h3 is the clear favorite among those four.

The others are anti-idiomatic.

Raku is forgiving in this case, trying to ease Perl devs into
using Raku, but do not unduly take advantage of Raku's
kindness. Learn to use the right idioms as soon as possible.
Otherwise you'll get outcomes like the perspective you have
on what happens when you pass pairs as arguments.

Btw, another option that's sometimes nice is:

my %h5 = :1week, :2days, :3hours;

(Same as `my %h5 = week => 1, days => 2, hours => 3;`.)

(But generally avoid this idiom when it does not read well,
and note how subs using it will often need to double up
singular and plural versions of named arguments, in this
case week/weeks etc.)

>say join(' ',
> %h1{'ho'}, %h2{'ho'}, %h3{'ho'}, %h4{'ho'}
> );
># Output: 2 2 2 2

Idiomatically, use `<...>` subscripts instead. Again, Raku is
forgiving, but don't take advantage of its kindness. Learn to
use the best idiom.

Maybe even `say join ' ', do . for %h1, %h2, %h3, %h4;`

> Of course, when you're accessing the hash value,
> the key *does* need to be quoted (unlike in perl),

Not at all. As you note yourself, just use `<...>` subscripts.

> And because of this, I keep thinking I need to quote keys

It's not because the key needs to be quoted when you're
accessing keys. Because they don't. You note the solution
yourself.

If you keep thinking you need to quote keys it's for some
other reason.

> I often quote keys without thinking about it

That may get you into trouble if you pass pairs in an argument
list that you intend will be received as named arguments. They
will be received as positional arguments instead.

> genius( 'ha' => 1, 'ho' => 2, 'hum' => 3 );
> ## Error: Too many positionals passed; expected 0 arguments but got 3

Great example.

Fortunately, the error message makes it clear you've passed
3 positional arguments when it expected none, immediately
pinpointing where the problem lies:

* If you thought you were passing 3 named arguments, you
  now know you passed 3 positional ones instead.

* If you thought you were passing 3 positional arguments, you
  now know the sub doesn't expect them.

> So: when passing pairs to a sub, quoting the key causes things to barf

No, quoting keys when passing pairs to a sub does *not* cause it to barf:

sub church(*%fried, *@frab) { say %fried, @frab }
church( 'ha' => 1, ho => 2, 'hum' => 3 );
## Output: {ho => 2}[ha => 1 hum => 3]

Works beautifully.

Larry deliberately distinguished pairs passed as arguments based
on whether their keys were or weren't quoted. If they're unquoted,
they're named arguments. If they're quoted, they're positional.

He did a similar thing for putting pairs in parens:

sub church(*@frab) { say @frab }
church( 'ha' => 1, (ho => 2, hum => 3) );
## Output: [ha => 1 ho => 2 hum => 3]

> and the messaging is seriously LTA.

Well, it's surprising to you, because you aren't familiar with
named vs positional arguments. If you were, the message
would instantly clue you into the fact your pairs have been
received as positional arguments instead of as named ones.

I'm not convinced the error message is seriously LTA. I'm
inclined to view it as pretty good. I also think it might be
seriously hard to improve. Perhaps a champion (you?)
might step up to the plate to explore how the message
might be improved, but I think it might be really hard to
improve that message alone in a meaningful way.

I can think of one way that would work and have a much
better payoff. It would still require a champion, but there's
a much greater chance of finding and motivating them.

The short version of it is the idea that error messages can
link to doc pages. So if this error message occurs, there's
a link to a doc page matching the error. That page can then
discuss things at length, covering all the various reasons
why the too many positionals or too many nameds messages
might appear, and all the ways to fix things.

> (The pair operator is being demoted to a fat comma?)

The pair syntax is allowing you to express whether you
want to pass a pair as a positional or a named argument.

Both are useful, so 

Re: for and ^ question

2020-12-31 Thread Andy Bach
> try out these
3 .. 7
3 ..^ 7
3 ^.. 7
3 ^..^ 7

Is the last one called the kitten or the bat operator? ;->

Happy New Year to all those for whom the year ends tonight. For the rest Happy 
Tomorrow!

From: yary 
Sent: Wednesday, December 30, 2020 9:06 PM
To: ToddAndMargo 
Cc: perl6-users 
Subject: Re: for and ^ question

CAUTION - EXTERNAL:

Look up ..^ which is the long form of ^ when used in ^8 sort of thing

https://docs.raku.org/routine/..$CIRCUMFLEX_ACCENT

"Constructs a Range from the arguments, 
excluding the end point."

try out these
3 .. 7
3 ..^ 7
3 ^.. 7
3 ^..^ 7

and also see
https://docs.raku.org/routine/...html
https://docs.raku.org/routine/$CIRCUMFLEX_ACCENT...html
https://docs.raku.org/routine/$CIRCUMFLEX_ACCENT..$CIRCUMFLEX_ACCENT





-y


On Wed, Dec 30, 2020 at 9:42 PM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:
On 12/30/20 6:04 PM, Curt Tilmes wrote:
> On Wed, Dec 30, 2020 at 8:40 PM ToddAndMargo via perl6-users
> mailto:perl6-users@perl.org>> wrote:
>> In the following for loop:
>>
>>   for ^$nCount -> $i {
>>
>> What is the ^ doing?
>
> https://docs.raku.org/type/Range   About the third paragraph from the top:
>
> The caret is also a prefix operator for constructing numeric ranges
> starting from zero:
>  my $x = 10;
>  say ^$x; # same as 0 ..^ $x.Numeric
>

Thank you!

In a for look, it looks like 0 through 9.  Is that
the for loops doing?

CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: Need help understand "class"

2020-12-08 Thread Andy Bach
> Would some kind soul please explain to me what is going on line by line with 
> the "class" statement.
> cupsGetDests definition can be found at:
 https://www.cups.org/doc/cupspm.html

The point of the class is to create a "template" in raku matching the C 
structure of the cups stuct.  That way, when passed to "nativecall"
https://docs.raku.org/routine/nativecast

it can use that template to understand what the pointer is pointing to (i.e. 
the cups cstruct).
 my $dest = nativecast(CupsDest, Pointer.new($ptr + $i * 
nativesizeof(CupsDest)));

The "nativesizeof" gives the size of the struct, so the
$ptr + $i * nativesizeof(CupsDest)

moves the new Pointer down the list one struct at a time.


From: ToddAndMargo via perl6-users 
Sent: Monday, December 7, 2020 10:36 PM
To: perl6-users 
Subject: Need help understand "class"

CAUTION - EXTERNAL:


Hi All,


In the following piece of code:

use NativeCall;

class CupsDest is repr('CStruct') {
 has Str $.name;
 has Str $.instance;
 has int32 $.is-default;
 has Pointer $.options;
}

sub cupsGetDests(Pointer is rw --> int32) is native('cups', v2) {}


Would some kind soul please explain to me
what is going on line by line with the "class"
statement.

cupsGetDests definition can be found at:
 https://www.cups.org/doc/cupspm.html

I am confused.  Yes, again.

-T
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: I need to run and release a program in the background

2020-11-16 Thread Andy Bach
> this command runs OUTSIDE the shell.  There are no  environmental variables 
> to be found such as $HOME

Well, not exactly none, but a limited env

$ raku -e 'my $pA = Proc::Async.new( "env" ); $pA.start;'
TERM=xterm
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_TYPE=tty
LESSCLOSE=/usr/bin/lesspipe %s %s
COMP_WORDBREAKS=
"'><;|&(:
LANG=en_US.UTF-8
SSH_CLIENT=10.222.64.247 65064 22
SHLVL=1
GOARCH=386
XDG_DATA_DIRS=/home/andy/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
USER=andy
SSH_TTY=/dev/pts/1
XDG_SESSION_CLASS=user
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
GOROOT=/home/andy/go
LOGNAME=andy
MOTD_SHOWN=pam
LESSOPEN=| /usr/bin/lesspipe %s
GOBIN=/home/andy/bin
_=/usr/bin/perl6
HOME=/home/andy
PWD=/home/andy
XDG_SESSION_ID=596
SHELL=/bin/bash
GOOS=linux
SSH_CONNECTION=10.222.64.247 65064 156.126.45.100 22
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin



From: ToddAndMargo via perl6-users 
Sent: Monday, November 16, 2020 4:39 PM
To: perl6-users@perl.org 
Subject: Re: I need to run and release a program in the background

CAUTION - EXTERNAL:


On 2020-11-14 12:23, ToddAndMargo via perl6-users wrote:
> Hi All,
>
> How do I use qqx or other to run and release a
> program in the background, like bash's "&"?
>
> Many thanks,
> -T
>


My revised keeper:

How to run and release a file:

Note: this command runs OUTSIDE the shell.  There are no
   environmental variables to be found such as $HOME

   the parameters are in quotes, including the name of
   the program to run, just like `run`

$ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); my $promise =
$pA.start; await $promise;'
$ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); $pA.start;'
$ p6 'my $pA = Proc::Async.new( '/usr/bin/leafpad
"/home/linuxutil/XferParts.pl6.tmp"' ); $pA.start;'


To get this to run with the shell, call "bash -c".
   Note: all the parameters to the command bash executing
 with "-c" go into an embedded quote stream.
 For example:

 '/usr/bin/leafpad "/home/linuxutil/XferParts.pl6.tmp"'

my $pA = Proc::Async.new( "bash", "-c", '/usr/bin/leafpad
"/home/linuxutil/XferParts.pl6.tmp"' );
say $pA;
$pA.start;

Proc::Async.new(path => "bash", args => ["-c", "/usr/bin/leafpad
\"/home/linuxutil/XferParts.pl6.tmp\""], command => ("bash", "-c",
"/usr/bin/leafpad  \"/home/linuxutil/XferParts.pl6.tmp\""), w => Any,
enc => "utf8", translate-nl => Bool::True, win-verbatim-args =>
Bool::False, started => Bool::False)
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: print particular lines question

2020-09-02 Thread Andy Bach
> Every time $ shows up, it is a different scalar.

Ah ... I was mistakenly thinking it was akin to $_ etc, where you could just 
use it for "free" but it persisted as any var would. So, in:
 raku -e 'for  -> $alpha {  for (1..14) { say (state $ = $alpha)++; }  }

it's the "state" that keeping it around, but only ... arrgh! I'm going to have 
to read
https://docs.raku.org/language/variables#The_state_declarator

a few more times ... $ normally doesn't need state, but if you want the 
assignment to happen just once (as above), you need to explicitly add the 
state.  Without an assignment:
 raku -e 'for  -> $alpha {  for (1..14) { say  $++; }  }'   # 0-13 0-13
 raku -e 'for  -> $alpha {  for (1..14) { say state $++; }  }'  # 0-13 
0-13

Those the same, but
 raku -e 'for  -> $alpha {  for (1..14) { say ( $ = $alpha)++; }  }
just shows AA and NN 14 times.  Because the inner for loops block is being 
"rerun", the state-liness of $ works, but when the outer loop loops (from AA to 
NN) the inner block and the inner version of $ go away.
 raku -e 'for  -> $alpha {  for (1..14) { say (state $ = $alpha)++; say 
"d2: " ~ ++$ }  }'
AA
d2: 1
AB
d2: 2
...

By Geoffrey, I think I almost have it!

Thanks!




From: yary 
Sent: Tuesday, September 1, 2020 6:16 PM
To: Andy Bach 
Cc: William Michels ; perl6-users 
Subject: Re: print particular lines question

Every time $ shows up, it is a different scalar.

$=1; say $;

is similar to

my $anonONE=1; say $anonTWO;

thus they are very limited use

-y


On Tue, Sep 1, 2020 at 3:55 PM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
> My first clue that something is amiss is in your third line of code when the  
> return skips "AA" and starts "AB, AC, AD". That suggests to me that the 
> two step assign/printf call is playing havoc with the $ anonymous variable

Missed that about the missing AA - does the same thing  with a named var, 
though:
 raku -e 'for  -> $alpha {  for (1..14) { (state $sv = $alpha)++;  
printf("d: %s\n", $sv ) } }'
d: AB
d: AC

So
 raku -e 'for  -> $alpha {  for (1..14) { say (state $sv = $alpha)++;  
printf("d: %s\n", $sv ) } }'
AA
d: AB
AB
d: AC

Ah, the increment happens the initial assignment.
$sv = "AA";
$sv++;
print $sv;  # AB

but the
say (state $sv = $alpha)++

says the result of the assignment, then the increment.  My confusion was more 
about my inability to use "$" anywhere else.
 raku -e 'for  -> $alpha {  for (1..14) { say (state $ = $alpha)++;  
printf("d: %s\n", $ ) } }'
AA
Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something 
meaningful.
  in block  at -e line 1
Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something 
meaningful.
  in any join at gen/moar/stage2/NQPCORE.setting line 1075
d:
AB
Use of uninitialized value of type Any in string context.
...

break it out of the parens, and it loses some "stateness":
 raku -e 'for  -> $alpha {  for (1..14) { say state $ = $alpha; $++;  
printf("d: %s\n", $ ) } }'
AA
Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something 
meaningful.
  in block  at -e line 1
...
AA

but the named doesn't
 raku -e 'for  -> $alpha {  for (1..14) { state $sv = $alpha; say $sv; 
$sv++;  printf("d: %s\n", $sv ) } }'
AA
d: AB
AB
d: AC





From: William Michels mailto:w...@caa.columbia.edu>>
Sent: Tuesday, September 1, 2020 5:30 PM
To: Andy Bach mailto:andy_b...@wiwb.uscourts.gov>>
Cc: yary mailto:not@gmail.com>>; perl6-users 
mailto:perl6-users@perl.org>>
Subject: Re: print particular lines question

My first clue that something is amiss is in your third line of code when the  
return skips "AA" and starts "AB, AC, AD". That suggests to me that the two 
step assign/printf call is playing havoc with the $ anonymous variable. Try 
this instead:

~$ raku -e 'for  -> $alpha {  for (1..14) { printf("d: %s\n", (state $ = 
$alpha)++ ) }; };'
d: AA
d: AB
d: AC
d: AD
d: AE
d: AF
d: AG
d: AH
d: AI
d: AJ
d: AK
d: AL
d: AM
d: AN
d: NN
d: NO
d: NP
d: NQ
d: NR
d: NS
d: NT
d: NU
d: NV
d: NW
d: NX
d: NY
d: NZ
d: OA

HTH, Bill.

On Tue, Sep 1, 2020 at 2:57 PM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
I'm barely hanging on with the "$" so ... so from:
raku -e 'for  -> $alpha { for (1..14) {   print (state $ = $alpha)++ ~ " 
"  } }'
AA AB AC AD AE AF

I tried an actual, er, non-anon var
# raku -e 'for  -> $alpha { for (1..14) {   print (state $sv = $alpha)++ 
~ " "  } }'
AA AB AC AD AE AF ...

and then I tried
r

Re: print particular lines question

2020-09-01 Thread Andy Bach
> My first clue that something is amiss is in your third line of code when the  
> return skips "AA" and starts "AB, AC, AD". That suggests to me that the 
> two step assign/printf call is playing havoc with the $ anonymous variable

Missed that about the missing AA - does the same thing  with a named var, 
though:
 raku -e 'for  -> $alpha {  for (1..14) { (state $sv = $alpha)++;  
printf("d: %s\n", $sv ) } }'
d: AB
d: AC

So
 raku -e 'for  -> $alpha {  for (1..14) { say (state $sv = $alpha)++;  
printf("d: %s\n", $sv ) } }'
AA
d: AB
AB
d: AC

Ah, the increment happens the initial assignment.
$sv = "AA";
$sv++;
print $sv;  # AB

but the
say (state $sv = $alpha)++

says the result of the assignment, then the increment.  My confusion was more 
about my inability to use "$" anywhere else.
 raku -e 'for  -> $alpha {  for (1..14) { say (state $ = $alpha)++;  
printf("d: %s\n", $ ) } }'
AA
Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something 
meaningful.
  in block  at -e line 1
Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something 
meaningful.
  in any join at gen/moar/stage2/NQPCORE.setting line 1075
d:
AB
Use of uninitialized value of type Any in string context.
...

break it out of the parens, and it loses some "stateness":
 raku -e 'for  -> $alpha {  for (1..14) { say state $ = $alpha; $++;  
printf("d: %s\n", $ ) } }'
AA
Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something 
meaningful.
  in block  at -e line 1
...
AA

but the named doesn't
 raku -e 'for  -> $alpha {  for (1..14) { state $sv = $alpha; say $sv; 
$sv++;  printf("d: %s\n", $sv ) } }'
AA
d: AB
AB
d: AC





From: William Michels 
Sent: Tuesday, September 1, 2020 5:30 PM
To: Andy Bach 
Cc: yary ; perl6-users 
Subject: Re: print particular lines question

My first clue that something is amiss is in your third line of code when the  
return skips "AA" and starts "AB, AC, AD". That suggests to me that the two 
step assign/printf call is playing havoc with the $ anonymous variable. Try 
this instead:

~$ raku -e 'for  -> $alpha {  for (1..14) { printf("d: %s\n", (state $ = 
$alpha)++ ) }; };'
d: AA
d: AB
d: AC
d: AD
d: AE
d: AF
d: AG
d: AH
d: AI
d: AJ
d: AK
d: AL
d: AM
d: AN
d: NN
d: NO
d: NP
d: NQ
d: NR
d: NS
d: NT
d: NU
d: NV
d: NW
d: NX
d: NY
d: NZ
d: OA

HTH, Bill.

On Tue, Sep 1, 2020 at 2:57 PM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
I'm barely hanging on with the "$" so ... so from:
raku -e 'for  -> $alpha { for (1..14) {   print (state $ = $alpha)++ ~ " 
"  } }'
AA AB AC AD AE AF

I tried an actual, er, non-anon var
# raku -e 'for  -> $alpha { for (1..14) {   print (state $sv = $alpha)++ 
~ " "  } }'
AA AB AC AD AE AF ...

and then I tried
raku -e 'for  -> $alpha {  for (1..14) { (state $sv = $alpha)++;  
printf("d: %s\n", $sv ) } }'
d: AB
d: AC
d: AD
d: AE
d: AF
...

but back to "$"
 raku -e 'for  -> $alpha {  for (1..14) { (state $ = $alpha)++;  
printf("d: %s\n", $ ) } }'
Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something 
meaningful.
  in block  at -e line 1
Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something 
meaningful.
  in any join at gen/moar/stage2/NQPCORE.setting line 1075
d:

[27 more times]

I used printf hoping the %s context would stringify "$" as trying any of the 
suggested "methods" complain of a missing "self"
 raku -e 'for  -> $alpha {  for (1..14) { (state $ = $alpha)++;  
printf("d: %s\n", $.raku ) } }'
===SORRY!=== Error while compiling -e
Variable $.raku used where no 'self' is available
at -e:1
--> v = $alpha)++;  printf("d: %s\n", $.raku⏏ ) } }
expecting any of:
term

So I'm missing something about "$", I think






From: William Michels via perl6-users 
mailto:perl6-users@perl.org>>
Sent: Tuesday, September 1, 2020 3:17 PM
To: yary mailto:not@gmail.com>>
Cc: perl6-users mailto:perl6-users@perl.org>>
Subject: Re: print particular lines question

I tried combining Larry's code and Yary's code, variously using
"state" or "INIT" or "BEGIN". This is what I saw:

~$ raku -e 'for  -> $alpha { for (1..14) { print (state $ =
$alpha)++ ~ " " } }'
AA AB AC AD AE AF AG AH AI AJ AK AL AM AN NN NO NP NQ NR NS NT NU NV
NW NX NY NZ OA

~$ raku -e 'for  

Re: print particular lines question

2020-09-01 Thread Andy Bach
I'm barely hanging on with the "$" so ... so from:
raku -e 'for  -> $alpha { for (1..14) {   print (state $ = $alpha)++ ~ " 
"  } }'
AA AB AC AD AE AF

I tried an actual, er, non-anon var
# raku -e 'for  -> $alpha { for (1..14) {   print (state $sv = $alpha)++ 
~ " "  } }'
AA AB AC AD AE AF ...

and then I tried
raku -e 'for  -> $alpha {  for (1..14) { (state $sv = $alpha)++;  
printf("d: %s\n", $sv ) } }'
d: AB
d: AC
d: AD
d: AE
d: AF
...

but back to "$"
 raku -e 'for  -> $alpha {  for (1..14) { (state $ = $alpha)++;  
printf("d: %s\n", $ ) } }'
Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something 
meaningful.
  in block  at -e line 1
Use of uninitialized value of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something 
meaningful.
  in any join at gen/moar/stage2/NQPCORE.setting line 1075
d:

[27 more times]

I used printf hoping the %s context would stringify "$" as trying any of the 
suggested "methods" complain of a missing "self"
 raku -e 'for  -> $alpha {  for (1..14) { (state $ = $alpha)++;  
printf("d: %s\n", $.raku ) } }'
===SORRY!=== Error while compiling -e
Variable $.raku used where no 'self' is available
at -e:1
--> v = $alpha)++;  printf("d: %s\n", $.raku⏏ ) } }
expecting any of:
term

So I'm missing something about "$", I think






From: William Michels via perl6-users 
Sent: Tuesday, September 1, 2020 3:17 PM
To: yary 
Cc: perl6-users 
Subject: Re: print particular lines question

I tried combining Larry's code and Yary's code, variously using
"state" or "INIT" or "BEGIN". This is what I saw:

~$ raku -e 'for  -> $alpha { for (1..14) { print (state $ =
$alpha)++ ~ " " } }'
AA AB AC AD AE AF AG AH AI AJ AK AL AM AN NN NO NP NQ NR NS NT NU NV
NW NX NY NZ OA

~$ raku -e 'for  -> $alpha { for (1..14) { print (INIT $ =
$alpha)++ ~ " " } }'
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

~$ raku -e 'for  -> $alpha { for (1..14) { print (BEGIN $ =
$alpha)++ ~ " " } }'
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

Expected?  --Bill.

On Tue, Sep 1, 2020 at 11:44 AM yary  wrote:
>
>
> Thanks, that's cool, and shows me something I was wondering about
>
> On Tue, Sep 1, 2020 at 11:36 AM Larry Wall  wrote:
>>
>> If you want to re-initialize a state variable, it's probably better to make
>> it explicit with the state declarator:
>>
>> $ raku -e "for  { for (1..2) { say (state $ = 'AAA')++ } }"
>> AAA
>> AAB
>> AAA
>> AAB
>
>
> $ raku -e 'for  -> $alpha { for (1..3) { say (state $ = $alpha)++ } }'
> AA
> AB
> AC
> OO
> OP
> OQ
>


Re: print particular lines question

2020-08-31 Thread Andy Bach
> Not getting back line #11 with
 perl -ne 'print if $. =~ /\b[3 2 5 11]\b/' test_lines.txt

Right, as the char class contains , 1, 2, 3 and 5. I guess alternatives
 perl -ne 'print if $. =~ /\b(1|5|3|11)\b/' /tmp/lines.txt
line: 1
line: 3
line: 5
line: 11




From: William Michels 
Sent: Monday, August 31, 2020 10:28 AM
To: Brian Duggan 
Cc: Andy Bach ; perl6-users 
Subject: Re: print particular lines question

How would P5 handle line numbers > 10 ? Not getting back line #11 with
the P5 examples below:

$ raku -ne '.say if ++$ == 3|2|5|11' test_lines.txt
Line 2
Line 3
Line 5
Line 11

~$ perl -ne 'print if $. =~ /\b[3 2 5 11]\b/' test_lines.txt
Line 1
Line 2
Line 3
Line 5

~$ perl -ne 'print if $. =~ /\b[3,2, 5, 11]\b/' test_lines.txt
Line 1
Line 2
Line 3
Line 5

On Mon, Aug 31, 2020 at 8:17 AM Brian Duggan  wrote:
>
> On Monday, August 31, Andy Bach wrote:
> > >  raku -ne '.say if $++ == 3|2|5' Lines.txt
> >
> > OT, maybe, but is
> > perl -ne 'print if $. =~ /\b[325]\b/' Lines.txt
> >
> > or
> > perl -ne 'print if $c++ =~ /\b[436]\b/' Lines.txt
> >
> > the best you can do in P5?
>
> I can't think of anything better :-)
>
> Brian


Re: print particular lines question

2020-08-31 Thread Andy Bach
>  raku -ne '.say if $++ == 3|2|5' Lines.txt

OT, maybe, but is
perl -ne 'print if $. =~ /\b[325]\b/' Lines.txt

or
perl -ne 'print if $c++ =~ /\b[436]\b/' Lines.txt

the best you can do in P5?

a

Andy Bach, BS, MSCMECFA
Systems Mangler
Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
Voice: (608) 261-5738, Cell: (608) 658-1890

"The three great problems of computer science:
compiler complexity and 'off-by-one' errors".
https://martinfowler.com/bliki/TwoHardThings.html


From: Brian Duggan 
Sent: Monday, August 31, 2020 7:53 AM
To: Curt Tilmes 
Cc: perl6-users 
Subject: Re: print particular lines question

On Monday, August 24, Curt Tilmes wrote:
> $ cat Lines.txt | raku -e '.say for lines()[3,2,5]'

The -n flag is an option here too:

   raku -ne '.say if $++ == 3|2|5' Lines.txt

Brian


Re: Raku User's Survey 2020 out now....

2020-08-28 Thread Andy Bach
>> Without any arguments, sub lines operates on $*ARGFILES, which
>> defaults to $*IN in the absence of any filenames.

> Be careful with that one, $*IN will lop of the first line if you are not 
> careful.

I think you're talking about mixing $*IN with the "-n" option
# raku -e 'say join(", ", $*IN.lines())' < /tmp/lines.txt
lines 1, lines 2, lines 3, lines 4, lines 5
# raku -ne 'say join(", ", $*IN.lines())' < /tmp/lines.txt
lines 2, lines 3, lines 4, lines 5

It's not lopping, the "-n" takes one line from $*IN before your code executes.

a

p.s.
"cryptogram", at least in my newspaper, is a quote and author's name encoded in 
a substitution cipher (G for A etc) to solve.

Andy Bach, BS, MSCMECFA
Systems Mangler
Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
Voice: (608) 261-5738, Cell: (608) 658-1890

"The three great problems of computer science:
compiler complexity and 'off-by-one' errors".
https://martinfowler.com/bliki/TwoHardThings.html


From: ToddAndMargo via perl6-users 
Sent: Thursday, August 27, 2020 8:41 PM
To: perl6-users@perl.org 
Subject: Re: Raku User's Survey 2020 out now

On 2020-08-27 16:53, Daniel Long Sockwell wrote:

>> Very few of the other [methods are documented] this way.
>> This one also started with an error in the cryptogram
>> as well.  (That is another complaint about the
>> documentation.  The cryptograms are often wrong.)
>> And there should be zero tolerance for "insider knowledge".
>
> This might be a bit ironic, but I can't follow what you're saying here.
> What do you mean by "cryptogram"?  To me, that strikes me as _much_ more
> of an esoteric term than anything in the Raku docs -- but maybe it has a
> common meaning in this context that I just haven't come across (and that
> a basic Internet search didn't turn up).

Here is one.

multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase),
:m(:$ignoremark) --> Bool:D)

This one is pretty easy to figure out.  Most of the time
though, I get the "what is the world?" thing. When
I do figure them out and they are correct, they can
actually be very helpful.

And I never remember the official name.

>> And "in your face example" would be one of my all time
>> favorite routines which is "lines".  I use "lines"
>> ALL-THE-TIME.
>>
>> https://docs.raku.org/routine/lines
>
> This is so fascinating to me -- you provide that as an example of poor
> documentation, but *I* would look at that as an area where Raku (with
> the help of its docs) just clicks perfectly into place.  Everything that
> the docs explain for this and related topics fits together into a
> cohesive whole, and after reading the docs, I not only see how the language
> works, but am also left with the feeling that the language couldn't
> possibly work any other way.

I picked "lines" on purpose as I KNOW ow it operates.
It is one sweet function, especially when I am careening through raw web
pages.  I as not looking for help with it.


>
>> Without any arguments, sub lines operates on $*ARGFILES, which
>> defaults to $*IN in the absence of any filenames.

Be careful with that one, $*IN will lop of the first line
if you are not careful.


> If you're willing to post your "keepers", I bet others would enjoy
> reading them as well.

Most of them are written specifically for me.  As you can
tell, I am "weird".  It would be anenormous undertaking
for me to clean most of them up.

Usually, when someone asks about a specific thing I have
a keeper on, I will (clean it up and) post it back.
Or if I am just tickled with what I came up with.

When I do, I get all my misspelling pointed out an
any booboo annotated.  It does really help enormously.

Since you are working on the documentation, feel free to
ping me to see if I have something written on the subject.
I am more than happy to have you use from it.  Or maybe
just to see what I find important about he subject.

>
>> Hope that explains it.  I ADORE Raku.  The only thing
>> I dislike is the documentation.
>
> I'm glad you like Raku -- I feel the same way.  Now, I'm going to get
> back to trying to improve the documentation; I've submitted two pull
> requests today, and am making decent progress towards a third.  Maybe
> one day, you'll like the docs as much as you like the language itself.

I have programmed in several languages in my lifetime.  I have to say,
Raku is just damned fun to program in!  And
the community is wonderful.

-T

p.s. my favorite variable is the Associative Array (hash).
(I like put both descriptions together as it nicely describes
what a has is.)

Here is my keeper on a hash:

12/08/2019:

Per

Re: print particular lines question

2020-08-25 Thread Andy Bach
> this preserves the order of the lines (which may or may not be desired)


raku -ne '.say if $++ == any 6,3,1' line0-10.txt

So there is no "$."/current input line # built-in?  I started with
# cat /tmp/lines.txt | perl -ne  'print if $. == 1 or $. == 3 or $. == 7'

but couldn't find a $. raku-ism.
https://docs.raku.org/language/variables#Special_variables

Pretty cool - I didn't know about the bare "$" as a magic state var.

a

Andy Bach, BS, MSCMECFA
Systems Mangler
Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
Voice: (608) 261-5738, Cell: (608) 658-1890

"The three great problems of computer science:
compiler complexity and 'off-by-one' errors".
https://martinfowler.com/bliki/TwoHardThings.html


From: yary 
Sent: Tuesday, August 25, 2020 4:13 PM
To: William Michels 
Cc: perl6-users ; Parrot Raiser <1parr...@gmail.com>; 
ToddAndMargo ; Andy Bach ; 
Curt Tilmes 
Subject: Re: print particular lines question

> Now, does anyone have a simpler way than using the ".map" above?

There were a few in the thread!

Here's my golfing, unlike the others, this preserves the order of the lines 
(which may or may not be desired)


raku -ne '.say if $++ == any 6,3,1' line0-10.txt

-y


On Tue, Aug 25, 2020 at 12:03 PM William Michels via perl6-users 
mailto:perl6-users@perl.org>> wrote:
If Todd wants to print lines containing "Line 1", "Line 3", and "Line 7", he's 
going to have to correct for zero-indexing:

user@book:~$ raku -e '$*IN.lines[ 1,3,7 ].join("\n").put;' < Lines.txt
Line 2
Line 4
Line 8

#Below: subtracting one from (1,3,7) gives the return he wants:

user@book:~$ raku -e '$*IN.lines[ (1,3,7).map: { $_ - 1 } ].join("\n").put;' < 
Lines.txt
Line 1
Line 3
Line 7

Now, does anyone have a simpler way than using the ".map" above?

HTH, Bill.



On Tue, Aug 25, 2020 at 10:46 AM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
Ah, I see, the -n reads a line and then my lines on $*IN starts with the next 
one
C:\> type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -e "my @x = 
$*IN.lines(); say @x[0,1,7,3]; "
(Line 0 Line 1 Line 7 Line 3)

and so $*IN is the default for lines()
C:\> type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -e "my @x = 
lines(); say @x[0,1,7,3]; "
(Line 0 Line 1 Line 7 Line 3)

This hangs, with and without the -n
C:\> "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "my @x = $*IN.lines(); 
say @x[0,1,7,3]; " lines.txt

Though:
C:\> "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "my @x = lines(); say 
@x[0,1,7,3]; " lines.txt
(Line 1 Line 2 Line 8 Line 4)
Cannot do 'get' on a handle in binary mode
  in block  at -e line 1

a

Andy Bach, BS, MSCMECFA
Systems Mangler
Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
Voice: (608) 261-5738, Cell: (608) 658-1890

"The three great problems of computer science:
compiler complexity and 'off-by-one' errors".
https://martinfowler.com/bliki/TwoHardThings.html


From: Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>>
Sent: Tuesday, August 25, 2020 12:18 PM
To: Parrot Raiser <1parr...@gmail.com<mailto:1parr...@gmail.com>>
Cc: perl6-users mailto:perl6-users@perl.org>>; 
ToddAndMargo mailto:toddandma...@zoho.com>>
Subject: Re: print particular lines question

On Win10
C:\>type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "say 
lines()[1,7,3]; "
(Line 2 Line 8 Line 4)
(Line 11 Nil Nil)

C:\>type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "say 
lines()[1,7,3].join(qq~\n~); "
Line 2
Line 8
Line 4
Use of Nil in string context
  in block  at -e line 1
Use of Nil in string context
  in block  at -e line 1
Line 11

and, speaking of that off by one problem ... lines.txt does start with "line 0"
C:\> type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "my @x = 
$*IN.lines(); say @x[0,1,7,3]; "
(Line 1 Line 2 Line 8 Line 4)

a

Andy Bach, BS, MSCMECFA
Systems Mangler
Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
Voice: (608) 261-5738, Cell: (608) 658-1890

"The three great problems of computer science:
compiler complexity and 'off-by-one' errors".
https://martinfowler.com/bliki/TwoHardThings.html


From: Parrot Raiser <1parr...@gmail.com<mailto:1parr...@gmail.com>>
Sent: Tuesday, August 25, 2020 11:22 AM
To: Andy Bach mailto:andy_b...@wiwb.uscourts.gov>>
Cc: perl6-users mailto:perl6-users@perl.org>>; 
ToddAndMargo mailto:toddandma...@zoho.com>>
Subject: Re: print particular lines question

That will golf a little (and i

Re: print particular lines question

2020-08-25 Thread Andy Bach
Ah, I see, the -n reads a line and then my lines on $*IN starts with the next 
one
C:\> type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -e "my @x = 
$*IN.lines(); say @x[0,1,7,3]; "
(Line 0 Line 1 Line 7 Line 3)

and so $*IN is the default for lines()
C:\> type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -e "my @x = 
lines(); say @x[0,1,7,3]; "
(Line 0 Line 1 Line 7 Line 3)

This hangs, with and without the -n
C:\> "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "my @x = $*IN.lines(); 
say @x[0,1,7,3]; " lines.txt

Though:
C:\> "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "my @x = lines(); say 
@x[0,1,7,3]; " lines.txt
(Line 1 Line 2 Line 8 Line 4)
Cannot do 'get' on a handle in binary mode
  in block  at -e line 1

a

Andy Bach, BS, MSCMECFA
Systems Mangler
Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
Voice: (608) 261-5738, Cell: (608) 658-1890

"The three great problems of computer science:
compiler complexity and 'off-by-one' errors".
https://martinfowler.com/bliki/TwoHardThings.html


From: Andy Bach 
Sent: Tuesday, August 25, 2020 12:18 PM
To: Parrot Raiser <1parr...@gmail.com>
Cc: perl6-users ; ToddAndMargo 
Subject: Re: print particular lines question

On Win10
C:\>type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "say 
lines()[1,7,3]; "
(Line 2 Line 8 Line 4)
(Line 11 Nil Nil)

C:\>type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "say 
lines()[1,7,3].join(qq~\n~); "
Line 2
Line 8
Line 4
Use of Nil in string context
  in block  at -e line 1
Use of Nil in string context
  in block  at -e line 1
Line 11

and, speaking of that off by one problem ... lines.txt does start with "line 0"
C:\> type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "my @x = 
$*IN.lines(); say @x[0,1,7,3]; "
(Line 1 Line 2 Line 8 Line 4)

a

Andy Bach, BS, MSCMECFA
Systems Mangler
Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
Voice: (608) 261-5738, Cell: (608) 658-1890

"The three great problems of computer science:
compiler complexity and 'off-by-one' errors".
https://martinfowler.com/bliki/TwoHardThings.html


From: Parrot Raiser <1parr...@gmail.com>
Sent: Tuesday, August 25, 2020 11:22 AM
To: Andy Bach 
Cc: perl6-users ; ToddAndMargo 
Subject: Re: print particular lines question

That will golf a little (and improve it) to:

$ raku -e '.say for lines()[3,2,5]' lines.txt

but you have to remember that it's zero-based. I used the first sample
file and got
Line 4
Line 3
Line 6

"The three great problems of computer science: compiler complexity and
'off-by-one' errors".


On 8/25/20, Andy Bach  wrote:
>> Assigning  `my @x=$_.lines` puts everything into $x[0]
>
> Trying this on windows
>
> C:\> raku.exe   -e "my @x = 'lines.txt'.IO.lines; say
> @x[1,7,3].join(qq~\n~); "
> Line 1
> Line 7
> Line 3
>
> or
> C:\> raku.exe -e " say 'lines.txt'.IO.lines[1,7,3].join(qq~\n~); "
> Line 1
> Line 7
> Line 3
>
> a
>
> Andy Bach, BS, MSCMECFA
> Systems Mangler
> Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
> Voice: (608) 261-5738, Cell: (608) 658-1890
>
> Every man has the right to an opinion but no man
> has a right to be wrong in his facts. Nor, above all,
> to persist in errors as to facts. Bernard Baruch
>
> 
> From: ToddAndMargo via perl6-users 
> Sent: Monday, August 24, 2020 9:35 PM
> To: perl6-users 
> Subject: print particular lines question
>
> Hi All,
>
> I seems I should know how to do this, but
> I am drawing a blank.
>
> $ cat Lines.txt | raku -ne 'say $_;'
> Line 1
> Line 2
> Line 3
> Line 4
> Line 5
> Line 6
> Line 7
> Line 8
> Line 9
> Line 10
> Line 11
>
>
> I want to print liens 1, 3, and 7.
>
> Assigning  `my @x=$_.lines` puts everything into $x[0]
>
>
> Many thanks,
> -T
>


Re: print particular lines question

2020-08-25 Thread Andy Bach
On Win10
C:\>type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "say 
lines()[1,7,3]; "
(Line 2 Line 8 Line 4)
(Line 11 Nil Nil)

C:\>type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "say 
lines()[1,7,3].join(qq~\n~); "
Line 2
Line 8
Line 4
Use of Nil in string context
  in block  at -e line 1
Use of Nil in string context
  in block  at -e line 1
Line 11

and, speaking of that off by one problem ... lines.txt does start with "line 0"
C:\> type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe"   -ne "my @x = 
$*IN.lines(); say @x[0,1,7,3]; "
(Line 1 Line 2 Line 8 Line 4)

a

Andy Bach, BS, MSCMECFA
Systems Mangler
Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
Voice: (608) 261-5738, Cell: (608) 658-1890

"The three great problems of computer science:
compiler complexity and 'off-by-one' errors".
https://martinfowler.com/bliki/TwoHardThings.html

____
From: Parrot Raiser <1parr...@gmail.com>
Sent: Tuesday, August 25, 2020 11:22 AM
To: Andy Bach 
Cc: perl6-users ; ToddAndMargo 
Subject: Re: print particular lines question

That will golf a little (and improve it) to:

$ raku -e '.say for lines()[3,2,5]' lines.txt

but you have to remember that it's zero-based. I used the first sample
file and got
Line 4
Line 3
Line 6

"The three great problems of computer science: compiler complexity and
'off-by-one' errors".


On 8/25/20, Andy Bach  wrote:
>> Assigning  `my @x=$_.lines` puts everything into $x[0]
>
> Trying this on windows
>
> C:\> raku.exe   -e "my @x = 'lines.txt'.IO.lines; say
> @x[1,7,3].join(qq~\n~); "
> Line 1
> Line 7
> Line 3
>
> or
> C:\> raku.exe -e " say 'lines.txt'.IO.lines[1,7,3].join(qq~\n~); "
> Line 1
> Line 7
> Line 3
>
> a
>
> Andy Bach, BS, MSCMECFA
> Systems Mangler
> Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
> Voice: (608) 261-5738, Cell: (608) 658-1890
>
> Every man has the right to an opinion but no man
> has a right to be wrong in his facts. Nor, above all,
> to persist in errors as to facts. Bernard Baruch
>
> 
> From: ToddAndMargo via perl6-users 
> Sent: Monday, August 24, 2020 9:35 PM
> To: perl6-users 
> Subject: print particular lines question
>
> Hi All,
>
> I seems I should know how to do this, but
> I am drawing a blank.
>
> $ cat Lines.txt | raku -ne 'say $_;'
> Line 1
> Line 2
> Line 3
> Line 4
> Line 5
> Line 6
> Line 7
> Line 8
> Line 9
> Line 10
> Line 11
>
>
> I want to print liens 1, 3, and 7.
>
> Assigning  `my @x=$_.lines` puts everything into $x[0]
>
>
> Many thanks,
> -T
>


Re: print particular lines question

2020-08-25 Thread Andy Bach
> Assigning  `my @x=$_.lines` puts everything into $x[0]

Trying this on windows

C:\> raku.exe   -e "my @x = 'lines.txt'.IO.lines; say @x[1,7,3].join(qq~\n~); "
Line 1
Line 7
Line 3

or
C:\> raku.exe -e " say 'lines.txt'.IO.lines[1,7,3].join(qq~\n~); "
Line 1
Line 7
Line 3

a

Andy Bach, BS, MSCMECFA
Systems Mangler
Internet: andy_b...@wiwb.uscourts.gov<mailto:andy_b...@wiwb.uscourts.gov>
Voice: (608) 261-5738, Cell: (608) 658-1890

Every man has the right to an opinion but no man
has a right to be wrong in his facts. Nor, above all,
to persist in errors as to facts. Bernard Baruch


From: ToddAndMargo via perl6-users 
Sent: Monday, August 24, 2020 9:35 PM
To: perl6-users 
Subject: print particular lines question

Hi All,

I seems I should know how to do this, but
I am drawing a blank.

$ cat Lines.txt | raku -ne 'say $_;'
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
Line 11


I want to print liens 1, 3, and 7.

Assigning  `my @x=$_.lines` puts everything into $x[0]


Many thanks,
-T


Re: I reproduced one of the errors!

2020-06-02 Thread Andy Bach
>> Repeating any of this material won't help you. So what is a method to
>> you? How do you think it might be used?

> Some times methods are great for human readability.  I would like to have 
> both in my tool chest.

Not sure that's really answering the question Richard was asking.  I believe he 
was looking for a more specific answer - when would you want to use a method vs 
wanting to use a sub.

It may be just me, but I can see methods as class related subroutines (subs 
with the class object passed as an "unlisted" parameter) or subroutines as 
classless methods.  I'm not sure what you see them as or how you see them as 
different than subs.

From: ToddAndMargo via perl6-users 
Sent: Monday, June 1, 2020 5:49 PM
To: perl6-users@perl.org 
Subject: Re: I reproduced one of the errors!

On 2020-06-01 15:19, Richard Hainsworth wrote:
> Todd,
>
> You said you asked if you could create your own methods, and that you
> were told 'no'. That was a surprising statement, so I asked about some
> context about who would say such a stupid(?!) thing. Seems like this was
> a half-remembered 'no' somewhere in a cloud . Lets leave it there.

My memory is clear on it.


> You often ask questions that get interesting answers. But rather than
> guessing what you're thinking, perhaps you might explain how you see a
> 'subroutine' differing from a 'method'. If you look at the Raku
> documentation, which I know for you, is like shoving your head in a
> barrel of cold water, you will find quite a few examples of methods,
> subs, blocks, and pointies, together with things called signatures.
> Repeating any of this material won't help you. So what is a method to
> you? How do you think it might be used?
>
> Richard


Some times methods are great for human readability.  I
would like to have both in my tool chest.


Re: I reproduced one of the errors!

2020-05-27 Thread Andy Bach
#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
$x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }

K:\Windows\NtUtil>raku Contains.Test.pl6
Cannot resolve caller starts-with(Str:U: Str:D); none of these
signatures match

 (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_
--> Bool)
 (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
 (Cool:D: Cool:D $needle, *%_ --> Bool)
 (Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ -->
Bool)
 (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
 (Str:D: Str:D $needle, *%_ --> Bool)
   in block  at Contains.Test.pl6 line 3

>  The function should just complain that the variable is not initialized.

Well, it is:
Cannot resolve caller starts-with(Str:U: Str:D);
...
in block  at Contains.Test.pl6 line 3

it says:
For line 3:
if $x.starts-with( "[" )
looking for a possible method 'starts-with' with a signature of 2 params; an 
undefined string ('Str:U:') and a defined one ('Str:D:') failed - here's the 
list of the possible signatures raku currently has ..."

I'd not be surprise if you could write your own "starts-with(Str:U: Str:D); " 
method in raku and take care of this.  You could probably even have it "say"
You have an undefined String var in this call, not going to be able to do much 
useful matching against that.  Did you forget to initialize something?


From: ToddAndMargo via perl6-users 
Sent: Wednesday, May 27, 2020 4:05 PM
To: perl6-users 
Subject: I reproduced one of the errors!

I managed to reproduce one of the errors I was getting.
I specifically did not initialize $x.  If I do, the
error goes away.  In my code, I did a "say $x" and it
said $x had something in it.  That is what threw me off


K:\Windows\NtUtil>raku -v
This is Rakudo version 2020.05.1 built on MoarVM version
2020.05 implementing Raku 6.d.



#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
$x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }



K:\Windows\NtUtil>raku Contains.Test.pl6
Cannot resolve caller starts-with(Str:U: Str:D); none of these
signatures match

 (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_
--> Bool)
 (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
 (Cool:D: Cool:D $needle, *%_ --> Bool)
 (Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ -->
Bool)
 (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
 (Str:D: Str:D $needle, *%_ --> Bool)
   in block  at Contains.Test.pl6 line 3


The function should just complain that the variable is
not initialized.



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: tip: Windows, Git, and those nice Linux utilities

2020-04-09 Thread Andy Bach
To get access to them:

-->  sysdm.cpl
   --> Advanced (tab at the top)
--> Environmental Variables (button, lower right)
 --> Path, Edit, add to the end
   ;C:\Program Files\Git\usr\bin

I edited my local user path before installing:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\ProgramData\Oracle\Java\javapath
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\Program Files\Perceptive Workgroup Search 10
c:\JFW
c:\JFW-scanclient
C:\WINDOWS\System32\OpenSSH\
C:\Program Files\PuTTY\
C:\Users\andybach\AppData\Local\Microsoft\WindowsApps
c:\program files\git\usr\bin

I saw it did some PATH munging on its own - after installing :
C:\Users\andybach>echo %path% | tr ';' '\n'
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
...
C:\WINDOWS\System32\OpenSSH\
C:\Program Files\PuTTY\
C:\Program Files\Git\cmd
C:\Program Files\Git\mingw64\bin
C:\Program Files\Git\usr\bin
C:\Users\andybach\AppData\Local\Microsoft\WindowsApps
c:\program files\git\usr\bin

so you don't need to munge it yourself.  Nice to have ls and tr though I meant 
to try MS's linux extension at some point.

From: ToddAndMargo via perl6-users 
Sent: Thursday, April 9, 2020 5:47 AM
To: perl6-users 
Subject: tip: Windows, Git, and those nice Linux utilities

Hi All,

Since the Raku Windows Installer forgets to install Git along
with Zef:

 https://github.com/rakudo/star/issues/145

You have to install Git yourself:

 https://git-for-windows.github.io/

Now here is a sweet feature of having Git installed.
It comes with all kind of nice Linux utilities, like ls,
tar, more, etc..

To get access to them:

-->  sysdm.cpl
   --> Advanced (tab at the top)
--> Environmental Variables (button, lower right)
 --> Path, Edit, add to the end
   ;C:\Program Files\Git\usr\bin

I don't know about you guys, but every time I
want a directory listing in Windows, I type
`ls` and have to go back and change it to `dir`.
No longer!

:-)

-T


Re: stashing an array in a hash and yanking it back out

2020-03-16 Thread Andy Bach
Vadim clarified for us, off-list:
> So, you basically needed:
my %h = :a(1); %h.append: (:b(2));

> Am I correct?
I think so, I mean, I believe the append method(?) for hashes would solve the 
problem the "whatever star" was attempted to be used for - so:
> my @monsters = << godzilla grendel wormface blob fingfangfoom tingler >>;
[godzilla grendel wormface blob fingfangfoom tingler]
> my @rocks = << marble sandstone granite chert pumice limestone >>
[marble sandstone granite chert pumice limestone]
> my  %stash = monsters => @monsters
{monsters => [godzilla grendel wormface blob fingfangfoom tingler]}
>  %stash.append: (:rocks(@rocks));
{monsters => [godzilla grendel wormface blob fingfangfoom tingler], rocks => 
[marble sandstone granite chert pumice limestone]}
Or:
> my  %stash = monsters => @monsters
{monsters => [godzilla grendel wormface blob fingfangfoom tingler]}
> %stash.append: (:rocks => @rocks);
{monsters => [godzilla grendel wormface blob fingfangfoom tingler], rocks True 
=> [marble sandstone granite chert pumice limestone]}
Or:
> my  %stash = monsters => @monsters
{monsters => [godzilla grendel wormface blob fingfangfoom tingler]}
> %stash.append: (rocks => @rocks);
{monsters => [godzilla grendel wormface blob fingfangfoom tingler], rocks => 
[marble sandstone granite chert pumice limestone]}

Though I've no idea what those colons are/are not doing.  And we can get to 
those "inner" array elements via
> say %stash[1]
sandstone




From: Vadim Belman 
Sent: Friday, March 13, 2020 12:50 PM
To: Andy Bach 
Cc: William Michels via perl6-users ; Joseph Brenner 
; Timo Paulssen ; yary 
Subject: Re: stashing an array in a hash and yanking it back out


There is no mystery whatsoever.

Consider the following:

my %h = "a", 1; # {a => 1}

Then consider this:

say *, *; # **


and also:

say *.VAR.WHAT; # (Whatever)

Taking into account that => has tighter precedence than , what you get in:

my %h = *, a => [1,2,3];

is actually the following data structure:

%( Whatever => Pair )

Regarding your use of postcircumfix [ ] on the data, you use it on Pair.

Best regards,
Vadim Belman

On Mar 13, 2020, at 11:52 AM, Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:

> my  %stash = monsters => @monsters, rocks => @rocks
{monsters => [godzilla grendel wormface blob fingfangfoom tingler], rocks => 
[marble sandstone granite chert pumice limestone]}
> my @more_rocks = << marble sandstone granite chert pumice limestone >>
[marble sandstone granite chert pumice limestone]
> my  %stash = *, morerocks => @rocks
{* => morerocks => [marble sandstone granite chert pumice limestone]}
> say %stash{*}
(morerocks => [marble sandstone granite chert pumice limestone])

So, I'm guessing the display
{* => morerocks => [marble sandstone granite chert pumice limestone]}

really means something like
{* => (morerocks => [marble sandstone granite chert pumice limestone])}

maybe?
> say @(%stash{*})
(morerocks => [marble sandstone granite chert pumice limestone])
> say @(%stash{*}).[0]
morerocks => [marble sandstone granite chert pumice limestone]
> say @(%stash{*}).[1]
Nil
> say @(%stash{*}).[0].{morerocks}
===SORRY!=== Error while compiling:
Undeclared routine:
morerocks used at line 1

> say @(%stash{*}).[0].[0]
morerocks => [marble sandstone granite chert pumice limestone]
> say @(%stash{*}).[0].[1]
Index out of range. Is: 1, should be in 0..0
  in block  at  line 1

> say @(%stash{*}).[0].[0].perl
:morerocks(["marble", "sandstone", "granite", "chert", "pumice", "limestone"])
> say @(%stash{*}).[0].perl
:morerocks(["marble", "sandstone", "granite", "chert", "pumice", "limestone"])


I dunno.


From: William Michels via perl6-users 
mailto:perl6-users@perl.org>>
Sent: Thursday, March 12, 2020 5:44 PM
To: perl6-users mailto:perl6-users@perl.org>>
Cc: Joseph Brenner mailto:doom...@gmail.com>>; Timo Paulssen 
mailto:t...@wakelift.de>>; yary 
mailto:not@gmail.com>>
Subject: Re: stashing an array in a hash and yanking it back out

Thanks yary! The code you posted works perfectly.

Okay, one last question. I tried to use the 'DRY' principle to add
things to a hash. However, (thinking that a 'whatever star' might
reduce typing), I came up with an odd "ternary" structure. Can anyone
explain the last line of code, below?

mbook:~ homedir$ perl6
To exit type 'exit' or '^D'
> my @monsters = << godzilla grendel wormface blob fingfangfoom tingler >>;
[godzilla grendel wormface blob fingfangfoom tingler]
> my @rocks = << marble sandstone granite

Re: stashing an array in a hash and yanking it back out

2020-03-15 Thread Andy Bach
>> really means something like
{* => (morerocks => [marble sandstone granite chert pumice limestone])}

> Taking into account that => has tighter precedence than , what you get in:
my %h = *, a => [1,2,3];

> is actually the following data structure:
%( Whatever => Pair )

That's sort of what I said, or, at least, saw.
> Regarding your use of postcircumfix [ ] on the data, you use it on Pair.

Not quite sure what this means, but is that how you'd get the [] 
array from %stash? I could get the pair back, but not the "inner" array of the 
pair's 2nd partner, so to speak:
>> say @(%stash{*})
(morerocks => [marble sandstone granite chert pumice limestone])
>> say @(%stash{*}).[0]
morerocks => [marble sandstone granite chert pumice limestone]
>> say @(%stash{*}).[1]
Nil
>> say @(%stash{*}).[0].{morerocks}
===SORRY!=== Error while compiling:
Undeclared routine:
morerocks used at line 1

>> say @(%stash{*}).[0].[0]
morerocks => [marble sandstone granite chert pumice limestone]


a

____
From: Vadim Belman 
Sent: Friday, March 13, 2020 12:50 PM
To: Andy Bach 
Cc: William Michels via perl6-users ; Joseph Brenner 
; Timo Paulssen ; yary 
Subject: Re: stashing an array in a hash and yanking it back out


There is no mystery whatsoever.

Consider the following:

my %h = "a", 1; # {a => 1}

Then consider this:

say *, *; # **


and also:

say *.VAR.WHAT; # (Whatever)

Taking into account that => has tighter precedence than , what you get in:

my %h = *, a => [1,2,3];

is actually the following data structure:

%( Whatever => Pair )

Regarding your use of postcircumfix [ ] on the data, you use it on Pair.

Best regards,
Vadim Belman

On Mar 13, 2020, at 11:52 AM, Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:

> my  %stash = monsters => @monsters, rocks => @rocks
{monsters => [godzilla grendel wormface blob fingfangfoom tingler], rocks => 
[marble sandstone granite chert pumice limestone]}
> my @more_rocks = << marble sandstone granite chert pumice limestone >>
[marble sandstone granite chert pumice limestone]
> my  %stash = *, morerocks => @rocks
{* => morerocks => [marble sandstone granite chert pumice limestone]}
> say %stash{*}
(morerocks => [marble sandstone granite chert pumice limestone])

So, I'm guessing the display
{* => morerocks => [marble sandstone granite chert pumice limestone]}

really means something like
{* => (morerocks => [marble sandstone granite chert pumice limestone])}

maybe?
> say @(%stash{*})
(morerocks => [marble sandstone granite chert pumice limestone])
> say @(%stash{*}).[0]
morerocks => [marble sandstone granite chert pumice limestone]
> say @(%stash{*}).[1]
Nil
> say @(%stash{*}).[0].{morerocks}
===SORRY!=== Error while compiling:
Undeclared routine:
morerocks used at line 1

> say @(%stash{*}).[0].[0]
morerocks => [marble sandstone granite chert pumice limestone]
> say @(%stash{*}).[0].[1]
Index out of range. Is: 1, should be in 0..0
  in block  at  line 1

> say @(%stash{*}).[0].[0].perl
:morerocks(["marble", "sandstone", "granite", "chert", "pumice", "limestone"])
> say @(%stash{*}).[0].perl
:morerocks(["marble", "sandstone", "granite", "chert", "pumice", "limestone"])


I dunno.


From: William Michels via perl6-users 
mailto:perl6-users@perl.org>>
Sent: Thursday, March 12, 2020 5:44 PM
To: perl6-users mailto:perl6-users@perl.org>>
Cc: Joseph Brenner mailto:doom...@gmail.com>>; Timo Paulssen 
mailto:t...@wakelift.de>>; yary 
mailto:not@gmail.com>>
Subject: Re: stashing an array in a hash and yanking it back out

Thanks yary! The code you posted works perfectly.

Okay, one last question. I tried to use the 'DRY' principle to add
things to a hash. However, (thinking that a 'whatever star' might
reduce typing), I came up with an odd "ternary" structure. Can anyone
explain the last line of code, below?

mbook:~ homedir$ perl6
To exit type 'exit' or '^D'
> my @monsters = << godzilla grendel wormface blob fingfangfoom tingler >>;
[godzilla grendel wormface blob fingfangfoom tingler]
> my @rocks = << marble sandstone granite chert pumice limestone >>
[marble sandstone granite chert pumice limestone]
> my  %stash = monsters => @monsters
{monsters => [godzilla grendel wormface blob fingfangfoom tingler]}
> my %stash = *, rocks => @rocks;
{* => rocks => [marble sandstone granite chert pumice limestone]}

Thanks, Bill.


On Wed, Mar 11, 2020 at 9:06 PM yary 
mailto:not@gmail.com>> wrote:
>
> The fat-arrow example makes sense, what this says
> %stash = rocks => @rocks
> is "replace 

Re: stashing an array in a hash and yanking it back out

2020-03-13 Thread Andy Bach
> my  %stash = monsters => @monsters, rocks => @rocks
{monsters => [godzilla grendel wormface blob fingfangfoom tingler], rocks => 
[marble sandstone granite chert pumice limestone]}
> my @more_rocks = << marble sandstone granite chert pumice limestone >>
[marble sandstone granite chert pumice limestone]
> my  %stash = *, morerocks => @rocks
{* => morerocks => [marble sandstone granite chert pumice limestone]}
> say %stash{*}
(morerocks => [marble sandstone granite chert pumice limestone])

So, I'm guessing the display
{* => morerocks => [marble sandstone granite chert pumice limestone]}

really means something like
{* => (morerocks => [marble sandstone granite chert pumice limestone])}

maybe?
> say @(%stash{*})
(morerocks => [marble sandstone granite chert pumice limestone])
> say @(%stash{*}).[0]
morerocks => [marble sandstone granite chert pumice limestone]
> say @(%stash{*}).[1]
Nil
> say @(%stash{*}).[0].{morerocks}
===SORRY!=== Error while compiling:
Undeclared routine:
morerocks used at line 1

> say @(%stash{*}).[0].[0]
morerocks => [marble sandstone granite chert pumice limestone]
> say @(%stash{*}).[0].[1]
Index out of range. Is: 1, should be in 0..0
  in block  at  line 1

> say @(%stash{*}).[0].[0].perl
:morerocks(["marble", "sandstone", "granite", "chert", "pumice", "limestone"])
> say @(%stash{*}).[0].perl
:morerocks(["marble", "sandstone", "granite", "chert", "pumice", "limestone"])


I dunno.


From: William Michels via perl6-users 
Sent: Thursday, March 12, 2020 5:44 PM
To: perl6-users 
Cc: Joseph Brenner ; Timo Paulssen ; yary 

Subject: Re: stashing an array in a hash and yanking it back out

Thanks yary! The code you posted works perfectly.

Okay, one last question. I tried to use the 'DRY' principle to add
things to a hash. However, (thinking that a 'whatever star' might
reduce typing), I came up with an odd "ternary" structure. Can anyone
explain the last line of code, below?

mbook:~ homedir$ perl6
To exit type 'exit' or '^D'
> my @monsters = << godzilla grendel wormface blob fingfangfoom tingler >>;
[godzilla grendel wormface blob fingfangfoom tingler]
> my @rocks = << marble sandstone granite chert pumice limestone >>
[marble sandstone granite chert pumice limestone]
> my  %stash = monsters => @monsters
{monsters => [godzilla grendel wormface blob fingfangfoom tingler]}
> my %stash = *, rocks => @rocks;
{* => rocks => [marble sandstone granite chert pumice limestone]}

Thanks, Bill.


On Wed, Mar 11, 2020 at 9:06 PM yary  wrote:
>
> The fat-arrow example makes sense, what this says
> %stash = rocks => @rocks
> is "replace %stash in its entirety with key rocks gets value @rocks"
> anything that used to be in %stash doesn't matter because this assignment 
> (left side) is the entirety of %stash
>
> what this says
> %stash{'rocks'} = @rocks
> is "replace the slot 'rocks' in %stash with @rocks"
> This assignment only is for the 'rocks' element of %stash so the other 
> elements remain unchanged.
>
> Extending the examples, first 3 lines are unchanged from before
>
> > my @monsters = << godzilla grendel wormface blob fingfangfoom tingler >>;
> [godzilla grendel wormface blob fingfangfoom tingler]
> > my @rocks = << marble sandstone granite chert pumice limestone >>
> [marble sandstone granite chert pumice limestone]
> > my  %stash = monsters => @monsters
> {monsters => [godzilla grendel wormface blob fingfangfoom tingler]}
>
> > %stash = %stash, rocks => @rocks
> {monsters => [godzilla grendel wormface blob fingfangfoom tingler], rocks => 
> [marble sandstone granite chert pumice limestone]}
> > my %together = monsters => @monsters, rocks => @rocks
> {monsters => [godzilla grendel wormface blob fingfangfoom tingler], rocks => 
> [marble sandstone granite chert pumice limestone]}
>
>
> -y
>
>
> On Tue, Mar 10, 2020 at 1:12 PM William Michels via perl6-users 
>  wrote:
>>
>> Hi Joe,
>>
>> So I had a chance to play with hashes further, and I noticed something
>> that you might be interested in. It seems that 'bare' declaration of a
>> hash with a "my" lexical scope enables you to stash away multiple
>> 'hash' elements at the top level using a 'curly brace' syntax. However
>> using the 'fat arrow' syntax will overwrite any previously stashed
>> 'top level' hash elements.
>>
>> Hopefully the REPL code below illustrates. First, 'curly brace' syntax:
>>
>> mbook:~ homedir$ perl6
>> To exit type 'exit' or '^D'
>> > my @monsters = << godzilla grendel wormface blob fingfangfoom tingler >>;
>> [godzilla grendel wormface blob fingfangfoom tingler]
>> > my @rocks = << marble sandstone granite chert pumice limestone >>
>> [marble sandstone granite chert pumice limestone]
>> > my %stash
>> {}
>> > %stash{'monsters'} = @monsters
>> [godzilla grendel wormface blob fingfangfoom tingler]
>> > say %stash
>> {monsters => [godzilla grendel wormface blob fingfangfoom tingler]}
>> > %stash{'rocks'} = @rocks
>> [marble sandstone granite chert pumice limestone]
>> > say 

Re: qqx with quotes

2020-02-28 Thread Andy Bach
rakudo 2020.01 built on moar 2020.01.1 implementing perl 6.d

From: Todd Chester via perl6-users 
Sent: Friday, February 28, 2020 4:57 AM
To: perl6-users@perl.org 
Subject: Re: qqx with quotes



On 2020-02-27 15:38, Andy Bach wrote:
> Win10 with a new raku install.

would you do a
perl6 -v
for me?


Re: qqx with quotes

2020-02-27 Thread Andy Bach
> What OS did you test this on?
Win10 with a new raku install.  Wouldn't help if you've got other files that 
fit the glob, I suppose.  Did it not work for you?

From: ToddAndMargo via perl6-users 
Sent: Thursday, February 27, 2020 2:03 PM
To: perl6-users@perl.org 
Subject: Re: qqx with quotes

On 2020-02-27 11:05, Andy Bach wrote:
> This did work
> my $file = 'hi mom'
> $file ~~ s:g/\s+/*/;
> my $res = qqx(dir $file);
> say $res;

Hi Andy,

What OS did you test this on?

-T


Re: qqx with quotes

2020-02-27 Thread Andy Bach
This did work
my $file = 'hi mom'
$file ~~ s:g/\s+/*/;
my $res = qqx(dir $file);
say $res;



From: Andy Bach 
Sent: Wednesday, February 26, 2020 4:16 PM
To: ToddAndMargo via perl6-users 
Subject: Re: qqx with quotes

 @Result = qqx { C:/Windows/System32/fsutil.exe usn readdata \"$FileName\" 
}.lines;

Doesn't windows do something special for files with spaces in them?  Hm,
$ type "hi mom" > "test 1"
$ dir test
$ dir "test 1"

but, you're right, I couldn't find a combination of dbl, single, q, qq, qqx, qx 
that'd let me run
dir "test 1"
via qqx or qx - windows is funny that way, I guess.

From: ToddAndMargo via perl6-users 
Sent: Tuesday, February 25, 2020 11:12 AM
To: perl6-users@perl.org 
Subject: Re: qqx with quotes

>> On Mon, Feb 24, 2020 at 4:01 PM ToddAndMargo via perl6-users
>> mailto:perl6-users@perl.org>> wrote:
>>
>> Hi All,
>>
>> Windows 7
>>
>> In the following
>>
>> @Result = qqx { C:/Windows/System32/fsutil.exe usn readdata
>> \"$FileName\" }.lines;
>>
>>
>> $FileName needs to be in quotes as it can have
>> spaces in it.
>>
>>
>> The following did not work:
>>
>> \"$FileName\"
>> "$FileName\
>> $FileName
>>
>> What am I doing wrong, this time?
>>
>> Many thanks,
>> -T

On 2020-02-25 08:29, Paul Procacci wrote:
> The following works on FreeBSD:
>
> my $fn = "file name";
> say qqx { ls -l "$fn" };
>
> Not sure why this would be any different on Windows.

What version are you running?


Re: qqx with quotes

2020-02-26 Thread Andy Bach
 @Result = qqx { C:/Windows/System32/fsutil.exe usn readdata \"$FileName\" 
}.lines;

Doesn't windows do something special for files with spaces in them?  Hm,
$ type "hi mom" > "test 1"
$ dir test
$ dir "test 1"

but, you're right, I couldn't find a combination of dbl, single, q, qq, qqx, qx 
that'd let me run
dir "test 1"
via qqx or qx - windows is funny that way, I guess.

From: ToddAndMargo via perl6-users 
Sent: Tuesday, February 25, 2020 11:12 AM
To: perl6-users@perl.org 
Subject: Re: qqx with quotes

>> On Mon, Feb 24, 2020 at 4:01 PM ToddAndMargo via perl6-users
>> mailto:perl6-users@perl.org>> wrote:
>>
>> Hi All,
>>
>> Windows 7
>>
>> In the following
>>
>> @Result = qqx { C:/Windows/System32/fsutil.exe usn readdata
>> \"$FileName\" }.lines;
>>
>>
>> $FileName needs to be in quotes as it can have
>> spaces in it.
>>
>>
>> The following did not work:
>>
>> \"$FileName\"
>> "$FileName\
>> $FileName
>>
>> What am I doing wrong, this time?
>>
>> Many thanks,
>> -T

On 2020-02-25 08:29, Paul Procacci wrote:
> The following works on FreeBSD:
>
> my $fn = "file name";
> say qqx { ls -l "$fn" };
>
> Not sure why this would be any different on Windows.

What version are you running?


Re: variable as subroutine?

2020-02-12 Thread Andy Bach
> watch about a minute of this Damian Conway video--where he shows the new Raku 
> (Perl6) sigil table:

https://youtu.be/Nq2HkAYbG5o?t=568

Watch the whole thing - D.C. is one of the most entertaining instructors I've 
ever had the pleasure to list to[1],  plus he's smarter than a sitting on a 
bushel of thumbtacks!  Okay, and the accent.

a

[1]
I really wish there were somewhere a copy of his presentation at the Chicago 
YAPC long ago where he presented a clip on why to go to YAPC in Australia the 
next year - "of the 10 most deadly snakes in the world, 11 of them are native 
to Australia".  Before that YAPC, he had a meet at a bar in Chicago with the PM 
group there where he "explained" his obfu Conway (no relation) "game of 
life"/quine script
https://everything2.com/title/SelfGOL

From: William Michels 
Sent: Wednesday, February 12, 2020 1:27 PM
To: Aureliano Guedes 
Cc: Andy Bach ; perl6-users 
Subject: Re: variable as subroutine?



On Wed, Feb 12, 2020 at 8:12 AM Aureliano Guedes 
mailto:guedes.aureli...@gmail.com>> wrote:


On Wed, Feb 12, 2020 at 1:09 PM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
> So, the problem is you didn't call the same var you had declared.

my $foo = * **2;
> Then you call
foo(2).say
> Missing the $
D'oh!  Thanks.

> About the
my @a = * **2;
> Your suggestion works
@a[0](2)
> or
@a[0].(2)
> But I would appreciate an explanation about why `$a[0](0)` didn't work.

Same reason as mine didn't work "$a" of "$a[0]" is *not* the same variable as 
@a - raku doesn't swap sigils, so arrays always use @ even when they're being 
dereferenced (?) to a single element - unlike Perl5
Now I see. I din't know that. Thanks. I must study better Raku.

Hi Aureliano, watch about a minute of this Damian Conway video--where he shows 
the new Raku (Perl6) sigil table:

https://youtu.be/Nq2HkAYbG5o?t=568

HTH, Bill.



From: Aureliano Guedes 
mailto:guedes.aureli...@gmail.com>>
Sent: Tuesday, February 11, 2020 7:00 PM
To: Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>>; perl6-users 
mailto:perl6-users@perl.org>>
Subject: Re: variable as subroutine?

Sorry, I sent my answer just for you.

So, the problem is you didn't call the same var you had declared.

my $foo = * **2;
Then you call
foo(2).say
Missing the $
Try:
$foo(2).say
or
say $foo(2)

About the
my @a = * **2;
Your suggestion works
@a[0](2)
or
@a[0].(2)
But I would appreciate an explanation about why `$a[0](0)` didn't work.


On Tue, Feb 11, 2020 at 9:45 PM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
> I think it should be like this:

> my $foo = * **2;
{ ... }
> say $foo(4)
16

That's what the doc says, but that's not what my install version says.  I do get
> my $foo = * **2;
{ ... }

but say foo get the "unknown sub" error

> But I have another point::

> my @a = * **2;
> @a(2)
Invocant of method 'CALL-ME' must be a type object of type 'List', not an 
object instance of type 'Array'.  Did you forget a 'multi'?
  in block  at  line 1
Yeah, I'd be surprised if that worked

> $a[0](2)
===SORRY!=== Error while compiling:
Variable '$a' is not declared. Did you mean '@a'?
--> ⏏$a[0](2)

raku doesn't swap sigils anymore, so it should be
@a[0](2)

maybe, pass the param, to the first bucket in @a which is holding a sub, so run 
it  - works here
> my @a = * **2;
[{ ... }]
> say @a[0](4);
16

as does ".()"
> say @a[0].(5);
25

From: Aureliano Guedes 
mailto:guedes.aureli...@gmail.com>>
Sent: Tuesday, February 11, 2020 6:36 PM
To: Andy Bach mailto:andy_b...@wiwb.uscourts.gov>>
Subject: Re: variable as subroutine?

I think it should be like this:

> my $foo = * **2;
{ ... }
> say $foo(4)
16

But I have another point::

> my @a = * **2;
[{ ... }]
> @a(2)
Invocant of method 'CALL-ME' must be a type object of type 'List', not an 
object instance of type 'Array'.  Did you forget a 'multi'?
  in block  at  line 1

> $a[0](2)
===SORRY!=== Error while compiling:
Variable '$a' is not declared. Did you mean '@a'?
--> ⏏$a[0](2)



On Tue, Feb 11, 2020 at 8:43 PM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
>The * * * call generates a WhateverCode block. This is expecting 2 arguments.

-> $x { $x * $x } is taking one argument.

> The best documentation would probably be : https://docs.raku.org/type/Whatever

so, from:
Multiple * in one expression generate closures with as many arguments:

my $c = * + *;  # same as   -> $x, $y { $x + $y }
Using * in complex expressions will also generate closures:

my $c = 4 * * + 5;  # same as   -> $x { 4 * $x + 5 }

The * *  * the parser says "one whatever, one math op (*) and one more whatever"
my $foo =  $x, $y { $x + $y };

so,
my $foo = *  **2;
shou

Re: variable as subroutine?

2020-02-12 Thread Andy Bach
> So, the problem is you didn't call the same var you had declared.

my $foo = * **2;
> Then you call
foo(2).say
> Missing the $
D'oh!  Thanks.

> About the
my @a = * **2;
> Your suggestion works
@a[0](2)
> or
@a[0].(2)
> But I would appreciate an explanation about why `$a[0](0)` didn't work.

Same reason as mine didn't work "$a" of "$a[0]" is *not* the same variable as 
@a - raku doesn't swap sigils, so arrays always use @ even when they're being 
dereferenced (?) to a single element - unlike Perl5

From: Aureliano Guedes 
Sent: Tuesday, February 11, 2020 7:00 PM
To: Andy Bach ; perl6-users 
Subject: Re: variable as subroutine?

Sorry, I sent my answer just for you.

So, the problem is you didn't call the same var you had declared.

my $foo = * **2;
Then you call
foo(2).say
Missing the $
Try:
$foo(2).say
or
say $foo(2)

About the
my @a = * **2;
Your suggestion works
@a[0](2)
or
@a[0].(2)
But I would appreciate an explanation about why `$a[0](0)` didn't work.


On Tue, Feb 11, 2020 at 9:45 PM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
> I think it should be like this:

> my $foo = * **2;
{ ... }
> say $foo(4)
16

That's what the doc says, but that's not what my install version says.  I do get
> my $foo = * **2;
{ ... }

but say foo get the "unknown sub" error

> But I have another point::

> my @a = * **2;
> @a(2)
Invocant of method 'CALL-ME' must be a type object of type 'List', not an 
object instance of type 'Array'.  Did you forget a 'multi'?
  in block  at  line 1
Yeah, I'd be surprised if that worked

> $a[0](2)
===SORRY!=== Error while compiling:
Variable '$a' is not declared. Did you mean '@a'?
--> ⏏$a[0](2)

raku doesn't swap sigils anymore, so it should be
@a[0](2)

maybe, pass the param, to the first bucket in @a which is holding a sub, so run 
it  - works here
> my @a = * **2;
[{ ... }]
> say @a[0](4);
16

as does ".()"
> say @a[0].(5);
25

From: Aureliano Guedes 
mailto:guedes.aureli...@gmail.com>>
Sent: Tuesday, February 11, 2020 6:36 PM
To: Andy Bach mailto:andy_b...@wiwb.uscourts.gov>>
Subject: Re: variable as subroutine?

I think it should be like this:

> my $foo = * **2;
{ ... }
> say $foo(4)
16

But I have another point::

> my @a = * **2;
[{ ... }]
> @a(2)
Invocant of method 'CALL-ME' must be a type object of type 'List', not an 
object instance of type 'Array'.  Did you forget a 'multi'?
  in block  at  line 1

> $a[0](2)
===SORRY!=== Error while compiling:
Variable '$a' is not declared. Did you mean '@a'?
--> ⏏$a[0](2)



On Tue, Feb 11, 2020 at 8:43 PM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
>The * * * call generates a WhateverCode block. This is expecting 2 arguments.

-> $x { $x * $x } is taking one argument.

> The best documentation would probably be : https://docs.raku.org/type/Whatever

so, from:
Multiple * in one expression generate closures with as many arguments:

my $c = * + *;  # same as   -> $x, $y { $x + $y }
Using * in complex expressions will also generate closures:

my $c = 4 * * + 5;  # same as   -> $x { 4 * $x + 5 }

The * *  * the parser says "one whatever, one math op (*) and one more whatever"
my $foo =  $x, $y { $x + $y };

so,
my $foo = *  **2;
should do $x * $x? Though I see

> my $foo = * **2;
{ ... }
say foo(4);
===SORRY!=== Error while compiling:
Undeclared routine:
foo used at line 1

but '&' works
> my  = * **2;
{ ... }
> foo(4);
16
> my  = * **2;
{ ... }
> say c(4);
16






From: Simon Proctor mailto:simon.proc...@gmail.com>>
Sent: Tuesday, February 11, 2020 9:27 AM
To: Andy Bach mailto:andy_b...@wiwb.uscourts.gov>>
Cc: perl6-users mailto:perl6-users@perl.org>>
Subject: Re: variable as subroutine?

The * * * call generates a WhateverCode block. This is expecting 2 arguments.

-> $x { $x * $x } is taking one argument.

The best documentation would probably be : https://docs.raku.org/type/Whatever

Hope that helps.

(For giggles earlier I made this dumb example of functional programming)


my  = {$_};
my  = {$_ * $_};
sub trinar( , , , *@values ) { @values.map( -> $v { ($v) 
?? ($v) !! ($v) } ) };
trinar( *.is-prime, ,, ^30 ).say

Enjoy. ;)

On Tue, 11 Feb 2020 at 15:22, Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
I have a few less related questions
>> those are 3 ways to write the same sub:

sub foo ($x) { $x * $x }
my  = -> $x { $x * $x }
my  = * * *;

> A Note on Marc's comment:
my  = * * *
is not the same as:
my  = -> $x { $x * $x }
it is the same  as:
my  = -> $x, $y { $x * $y }

Okay, "* * *" - how does that work?  How is it different than
-> $x { $x * $x }
?  It needs two params?

I followed the callable link but that left me with more ques

Re: variable as subroutine?

2020-02-11 Thread Andy Bach
>The * * * call generates a WhateverCode block. This is expecting 2 arguments.

-> $x { $x * $x } is taking one argument.

> The best documentation would probably be : https://docs.raku.org/type/Whatever

so, from:
Multiple * in one expression generate closures with as many arguments:

my $c = * + *;  # same as   -> $x, $y { $x + $y }
Using * in complex expressions will also generate closures:

my $c = 4 * * + 5;  # same as   -> $x { 4 * $x + 5 }

The * *  * the parser says "one whatever, one math op (*) and one more whatever"
my $foo =  $x, $y { $x + $y };

so,
my $foo = *  **2;
should do $x * $x? Though I see

> my $foo = * **2;
{ ... }
say foo(4);
===SORRY!=== Error while compiling:
Undeclared routine:
foo used at line 1

but '&' works
> my  = * **2;
{ ... }
> foo(4);
16
> my  = * **2;
{ ... }
> say c(4);
16






From: Simon Proctor 
Sent: Tuesday, February 11, 2020 9:27 AM
To: Andy Bach 
Cc: perl6-users 
Subject: Re: variable as subroutine?

The * * * call generates a WhateverCode block. This is expecting 2 arguments.

-> $x { $x * $x } is taking one argument.

The best documentation would probably be : https://docs.raku.org/type/Whatever

Hope that helps.

(For giggles earlier I made this dumb example of functional programming)


my  = {$_};
my  = {$_ * $_};
sub trinar( , , , *@values ) { @values.map( -> $v { ($v) 
?? ($v) !! ($v) } ) };
trinar( *.is-prime, ,, ^30 ).say

Enjoy. ;)

On Tue, 11 Feb 2020 at 15:22, Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
I have a few less related questions
>> those are 3 ways to write the same sub:

sub foo ($x) { $x * $x }
my  = -> $x { $x * $x }
my  = * * *;

> A Note on Marc's comment:
my  = * * *
is not the same as:
my  = -> $x { $x * $x }
it is the same  as:
my  = -> $x, $y { $x * $y }

Okay, "* * *" - how does that work?  How is it different than
-> $x { $x * $x }
?  It needs two params?

I followed the callable link but that left me with more questions:

method CALL-ME
method CALL-ME(Callable:D $self: |arguments)
This method is required for postfix:«( )» and postfix:«.( )». It's what makes 
an object actually call-able and needs to be overloaded to let a given object 
act like a routine. If the object needs to be stored in a &-sigiled container, 
is has to implement Callable.

class A does Callable {
submethod CALL-ME(|c){ 'called' }
}
my  = A;
say a(); # OUTPUT: «called␤»

That second "postfix" operator, means
say a.();  # also outputs "called"

but what is the "pipe c" signature doing for the submethod?

From: Simon Proctor mailto:simon.proc...@gmail.com>>
Sent: Tuesday, February 11, 2020 3:17 AM
To: ToddAndMargo mailto:toddandma...@zoho.com>>
Cc: perl6-users mailto:perl6-users@perl.org>>
Subject: Re: variable as subroutine?

If you can store a subroutine in a variable then you can pass said subroutine 
to another one as an argument.

This leads us into the joys of functional programming.

And you may have used it already and not even realised.

The .map and .grep methods (and .reduce and bunch of others) all expect a 
callable code block (that might be a subroutine) as a function.

This :

my @a = (1..10).map( * ** 2 )

and this :

my  = sub ($v) { $v ** 2 };
my @a = (1..10).map(  );

are doing the same thing. Except the second one has the  function available 
for other things.

(A Note on Marc's comment * * * is not the same as -> $x { $x * $x } it is the 
same  as -> $x, $y { $x * $y } )

You can then start doing things like storing functions as values in hashes and 
doing all *kinds* of fun stuff.

Welcome to the tip of the iceberg.

Simon


On Tue, 11 Feb 2020 at 03:21, ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:
Hi All,

Is Larry using his magic powder again?

Can I declare a subroutine as a variable?

 my $abc = my sub (UInt $u, Str $s, Int $I) {

How would I use it?

And why would do such a thing?

-T


--
Simon Proctor
Cognoscite aliquid novum cotidie

http://www.khanate.co.uk/


--
Simon Proctor
Cognoscite aliquid novum cotidie

http://www.khanate.co.uk/


Re: variable as subroutine?

2020-02-11 Thread Andy Bach
I have a few less related questions
>> those are 3 ways to write the same sub:

sub foo ($x) { $x * $x }
my  = -> $x { $x * $x }
my  = * * *;

> A Note on Marc's comment:
my  = * * *
is not the same as:
my  = -> $x { $x * $x }
it is the same  as:
my  = -> $x, $y { $x * $y }

Okay, "* * *" - how does that work?  How is it different than
-> $x { $x * $x }
?  It needs two params?

I followed the callable link but that left me with more questions:

method CALL-ME
method CALL-ME(Callable:D $self: |arguments)
This method is required for postfix:«( )» and postfix:«.( )». It's what makes 
an object actually call-able and needs to be overloaded to let a given object 
act like a routine. If the object needs to be stored in a &-sigiled container, 
is has to implement Callable.

class A does Callable {
submethod CALL-ME(|c){ 'called' }
}
my  = A;
say a(); # OUTPUT: «called␤»

That second "postfix" operator, means
say a.();  # also outputs "called"

but what is the "pipe c" signature doing for the submethod?

From: Simon Proctor 
Sent: Tuesday, February 11, 2020 3:17 AM
To: ToddAndMargo 
Cc: perl6-users 
Subject: Re: variable as subroutine?

If you can store a subroutine in a variable then you can pass said subroutine 
to another one as an argument.

This leads us into the joys of functional programming.

And you may have used it already and not even realised.

The .map and .grep methods (and .reduce and bunch of others) all expect a 
callable code block (that might be a subroutine) as a function.

This :

my @a = (1..10).map( * ** 2 )

and this :

my  = sub ($v) { $v ** 2 };
my @a = (1..10).map(  );

are doing the same thing. Except the second one has the  function available 
for other things.

(A Note on Marc's comment * * * is not the same as -> $x { $x * $x } it is the 
same  as -> $x, $y { $x * $y } )

You can then start doing things like storing functions as values in hashes and 
doing all *kinds* of fun stuff.

Welcome to the tip of the iceberg.

Simon


On Tue, 11 Feb 2020 at 03:21, ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:
Hi All,

Is Larry using his magic powder again?

Can I declare a subroutine as a variable?

 my $abc = my sub (UInt $u, Str $s, Int $I) {

How would I use it?

And why would do such a thing?

-T


--
Simon Proctor
Cognoscite aliquid novum cotidie

http://www.khanate.co.uk/


Re: Using raku/perl6 as unix "cat"....

2020-01-21 Thread Andy Bach
"  'while' ...will stop when it encounters a false line--typically an
empty line or '0'  ".

Wasn't that the point of p5's defined
while ( defined(my $line = <> ) ) {

or (previously lexified '$val'):
 print "$val\n" while defined($val = pop(@ary));

From: William Michels via perl6-users 
Sent: Tuesday, January 21, 2020 1:08 PM
To: Trey Harris ; perl6-users 
Cc: Andrew Shitov ; Curt Tilmes ; Joseph 
Brenner ; ToddAndMargo ; yary 
; Elizabeth Mattijsen ; ngayw...@une.edu.au 

Subject: Re: Using raku/perl6 as unix "cat"

Good answers, all. Thanks to everyone for contributing.
For anyone who wants a golfed "cat" replacement, command line
arguments can give you shorter code:

mydir$ perl6 -e  '.say for lines'  ab_cd.txt
a
b

c
d
mydir$ perl6 -ne  '.say'  ab_cd.txt
a
b

c
d
mydir$ # below two single quotes as empty arg:
mydir$ perl6 -pe  ''  ab_cd.txt
a
b

c
d
mydir$


Finally, a question about the 'get' docs, which use 'while' as an
example for the (IO::CatHandle) 'get' method.  The docs say
"(IO::CatHandle) method get:  Returns a single line of input from the
handle... . Returns Nil when there is no more input. ... ." And,
"(IO::Handle) routine get: Reads a single line of input from the
handle... . Returns Nil, if no more input is available... ." See:

https://docs.raku.org/routine/get

Should a different example other than "while/get" be used on the docs
page? Or should some of the comments Yary made regarding "while/get"
be incorporated into the docs--so programmers can be warned about
truncating their output on blank lines with "while/get"?  Yary, from
Jan. 18th:

"  'while' ...will stop when it encounters a false line--typically an
empty line or '0'  ".

Best Regards, Bill.


On Mon, Jan 20, 2020 at 4:13 PM Trey Harris  wrote:
>
> On Mon, Jan 20, 2020 at 19:03 Trey Harris  wrote:
>>
>> On Mon, Jan 20, 2020 at 02:59 William Michels via perl6-users 
>>  wrote:
>>>
>>> Hi Yary (and Todd),
>>>
>>> Thank you both for your responses. Yary, the problem seems to be with
>>> "get". I can change 'while' to 'for' below, but using 'get' raku/perl6
>>> actually returns fewer lines with "for" than it did with "while":
>>
>>
>> If you want to do line-oriented input, use `.lines` with `for`; it returns 
>> something `for` can iterate over.
>
>
> Sorry, in a setting where a handle isn’t the context, I meant `lines`, not 
> `.lines`, though I was referring _to_ a thing called `.lines`, the multi 
> method. I don’t think we’ve all yet agreed on how multis that can be called 
> as plain routines should be referred to in umbrella term. `.lines` is more 
> “correct”, but it’s less likely to actually work without understanding more, 
> which is a strange conundrum for documentation.
>
> Trey


Re: NativeCall bug: can't find final ')'

2020-01-02 Thread Andy Bach
Just a guess, but isn't it possible that this is a quoting problem?  Doing work 
from the Winx cmd line and trying to match up the single/double 
quote/multi-line mess is a way towards madness ... if you put your "-e" program 
in a file and run that, do you get a different error?

Just my 2 cents, but when ever I think I've come across a "bug" in the 
programming language, I always think again. 99.9% of the time, it's really 
me, not the language.

a


From: ToddAndMargo via perl6-users 
Sent: Tuesday, December 31, 2019 8:53 PM
To: perl6-users 
Subject: NativeCall bug: can't find final ')'


perl6 -I. -e "use WinReg :WinReadRegKey; say WinReadRegKey(
HKEY_LOCAL_MACHINE,
Q[SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system],
Q[EnableLUA] );"

===SORRY!=== Error while compiling K:\Windows\NtUtil\WinReg.pm6 (WinReg)

Unable to parse expression in argument list; couldn't find final ')'
(corresponding starter was at line 178) at K:\Windows\NtUtil\WinReg.pm6
(WinReg):178

--> eName, DWORD, REG_SZ, $lpData, $lpcbData is rw );
 expecting any of:
 infix
 infix stopper


"final ')' " is a bad error.   The actual error is that NativeCall does
not like the "is rw".  Please fix.

Many thanks,
-T


Re: env?

2019-11-04 Thread Andy Bach
> At the top of all my Perl 6 programs, I place
> #!/usr/bin/env perl6
>
> So I decided to run env by itself and see what I got:
>
>   $ /usr/bin/env perl6
>   You may want to `zef install Readline` or `zef install
>   Linenoise` or use rlwrap for a line editor
>
>   To exit type 'exit' or '^D'
>
> Is this suppose to happen?

Yes. The "shebang" line
 #!/usr/bin/env perl6

means "use the env to find the perl6 exe and run it" just as:
#!/usr/local/bin/perl6

does, only that's more specific.  So, you're seeing P6 in interactive mode, and 
it's advising you that w/o Linenoise or Readline, you won't be able to use "" etc for editing in interactive mode.
$ man env
NAME
   env - run a program in a modified environment

You can do
$ which perl6
to see where the exe might be found, too.

From: ToddAndMargo via perl6-users 
Sent: Sunday, November 3, 2019 11:26 PM
To: perl6-users 
Subject: env?

Hi All,

Fedora 13 (Linux)
rakudo-pkg-Fedora31-2019.07.1-03.x86_64.rpm

At the top of all my Perl 6 programs, I place
#!/usr/bin/env perl6

So I decided to run env by itself and see what I got:

  $ /usr/bin/env perl6
  You may want to `zef install Readline` or `zef install
  Linenoise` or use rlwrap for a line editor

  To exit type 'exit' or '^D'

Is this suppose to happen?

Many thanks,
-T


--
~~
When you say, "I wrote a program that
crashed Windows," people just stare at
you blankly and say, "Hey, I got those
with the system, for free."
  -- Linus Torvalds
~~


Re: anything faster than say [+] lines?

2019-09-27 Thread Andy Bach
> So these are equivalent:

seq 10 | perl6 -ne 'my Int $y += $_; END { print $y; }'
seq 10 | perl6 -e '(my Int $y += $_; END { print $y; }) for lines'

> (Note that I needed to surround it in parentheses so that it is one 
> statement.)
> It could be argued that -n should turn your code into a lambda first.

seq 10 | perl6 -e '{   my Int $y += $_; END { print $y; }   } for lines'
10

Right, this is what I sort of expect from
 seq 10 | perl6 -ne 'my Int $y += $_; END { print $y; }'

as the "my" would seem to localize $y in the while (or for) loop, so it 
shouldn't accumulate. But it does.

> Then you would need to use the 「state」 keyword more often.

seq 10 | perl6 -e '{   state Int $y += $_; END { print $y; }   } for lines'
55

The use of "state" makes sense.  In p5
 $ seq 10 | perl -nE ' my  $y += $_} ; END { say $y; '
[crickets]
$ seq 10 | perl -nE '   $y += $_} ;  { say $y; '
55
$ seq 10 | perl -nE ' our  $y += $_} ;  { say $y; '
55

Hmm:
$ seq 10 | perl -mstrict -wnE '   $y += $_} ;  { say $y; '
55
$ seq 10 | perl -mstrict -wnE ' my   $y += $_} ;  { say $y; '
Name "main::y" used only once: possible typo at -e line 1.
Use of uninitialized value $y in say at -e line 1, <> line 10.
$ seq 10 | perl -mstrict -wnE ' our   $y += $_} ;  { say $y; '
55

I'd've thought the first one would get a warning too.

$ seq 10 | perl6 -ne 'our Int $y += $_; END { say $y; }'
===SORRY!=== Error while compiling -e
Cannot put a type constraint on an 'our'-scoped variable
at -e:1
--> our Int $y⏏ += $_; END { say $y; }
expecting any of:
constraint


From: Brad Gilbert 
Sent: Thursday, September 26, 2019 9:52 PM
To: Andy Bach 
Cc: William Michels ; yary ; perl6 
; Joseph Brenner ; Elizabeth Mattijsen 
; Marc Chantreux ; Vittore Scolari 

Subject: Re: anything faster than say [+] lines?

With the Perl5 compiler the -n flag literally adds this around your code before 
compiling:

while ( <> ) {
…
}

Rakudo handles -n by transforming the AST (or the bytecode) into something that 
loops.

Basically it is more like:

… for lines

(In that it doesn't affect scoping or compile-time effects.)

So these are equivalent:

seq 10 | perl6 -ne 'my Int $y += $_; END { print $y; }'
seq 10 | perl6 -e '(my Int $y += $_; END { print $y; }) for lines'

(Note that I needed to surround it in parentheses so that it is one statement.)

It could be argued that -n should turn your code into a lambda first.

seq 10 | perl6 -e '{   my Int $y += $_; END { print $y; }   } for lines'
10

Then you would need to use the 「state」 keyword more often.

seq 10 | perl6 -e '{   state Int $y += $_; END { print $y; }   } for lines'
55



On Thu, Sep 26, 2019 at 4:31 PM Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>> wrote:
> Could the "-e" flag be limiting variable initializations to one?

I don't think so. I recall the -n being shorthand for wrapping your -e program 
in
while ( <> ) {
# your program here
}

(-p just adds a continue "print" block, I believe), as folks would do cool 
tricks of writing their -e script to have an early close while curly, instead 
of, say, using END blocks
$ seq 10 | perl -nE '   $y += $_} ;  { say $y; '
55

Note: using "my"
$ seq 10 | perl -nE ' my  $y += $_} ;  { say $y; '
[crickets]

gets you nothing, as $y is scoped to the -n while loop ;->


From: William Michels mailto:w...@caa.columbia.edu>>
Sent: Thursday, September 26, 2019 3:01 PM
To: yary mailto:not@gmail.com>>
Cc: perl6 mailto:perl6-users@perl.org>>; Andy Bach 
mailto:andy_b...@wiwb.uscourts.gov>>; Joseph 
Brenner mailto:doom...@gmail.com>>; Elizabeth Mattijsen 
mailto:l...@dijkmat.nl>>; Marc Chantreux 
mailto:e...@phear.org>>; Vittore Scolari 
mailto:vittore.scol...@gmail.com>>
Subject: Re: anything faster than say [+] lines?

Hi Yary,

Honestly, I just tried re-writing the fastest StackOverflow answer
(written in Perl 5) that I found below, in Perl 6. To write P5 as P6 I
had to declare the variable $x with 'my'. Then I played around with a
declaration restricting to "Int" type (to look at potential
performance hits), just because well--with Perl 6--I could.

>#Perl 5 code:
>seq 100 | perl -lne '$x += $_; END { print $x; }'

https://stackoverflow.com/a/47162173

I'm guessing the answer as to 'why "my Int $y" isn't re-initialized
every time'  in P6 is similar to the reason in P5? Could the "-e" flag
be limiting variable initializations to one?

Best Regards, Bill.




On Thu, Sep 26, 2019 at 12:00 PM yary 
mailto:not@gmail.com>> wrote:
>
> I see that Int/Num error, and also would like an explanation as to why "my 
> Int $y" isn't re-initialized to Any each time through this loop
>
> $ seq 10

Re: anything faster than say [+] lines?

2019-09-26 Thread Andy Bach
> Could the "-e" flag be limiting variable initializations to one?

I don't think so. I recall the -n being shorthand for wrapping your -e program 
in
while ( <> ) {
# your program here
}

(-p just adds a continue "print" block, I believe), as folks would do cool 
tricks of writing their -e script to have an early close while curly, instead 
of, say, using END blocks
$ seq 10 | perl -nE '   $y += $_} ;  { say $y; '
55

Note: using "my"
$ seq 10 | perl -nE ' my  $y += $_} ;  { say $y; '
[crickets]

gets you nothing, as $y is scoped to the -n while loop ;->


From: William Michels 
Sent: Thursday, September 26, 2019 3:01 PM
To: yary 
Cc: perl6 ; Andy Bach ; 
Joseph Brenner ; Elizabeth Mattijsen ; Marc 
Chantreux ; Vittore Scolari 
Subject: Re: anything faster than say [+] lines?

Hi Yary,

Honestly, I just tried re-writing the fastest StackOverflow answer
(written in Perl 5) that I found below, in Perl 6. To write P5 as P6 I
had to declare the variable $x with 'my'. Then I played around with a
declaration restricting to "Int" type (to look at potential
performance hits), just because well--with Perl 6--I could.

>#Perl 5 code:
>seq 100 | perl -lne '$x += $_; END { print $x; }'

https://stackoverflow.com/a/47162173

I'm guessing the answer as to 'why "my Int $y" isn't re-initialized
every time'  in P6 is similar to the reason in P5? Could the "-e" flag
be limiting variable initializations to one?

Best Regards, Bill.




On Thu, Sep 26, 2019 at 12:00 PM yary  wrote:
>
> I see that Int/Num error, and also would like an explanation as to why "my 
> Int $y" isn't re-initialized to Any each time through this loop
>
> $ seq 100 | perl6 -ne 'my Int $y += $_; END { print $y; }'
>
> Type check failed in assignment to $y; expected Int but got Num 
> (5050e0)
>
>   in block  at -e line 1
>
>
> $ perl6 --version
>
> This is Rakudo Star version 2019.03.1 built on MoarVM version 2019.03
>
> implementing Perl 6.d.
>
>
> -y
>
>
> On Thu, Sep 26, 2019 at 2:24 PM William Michels via perl6-users 
>  wrote:
>>
>> Thank you, Andy and Joseph!
>>
>>
>> On Thu, Sep 26, 2019 at 8:47 AM Andy Bach  
>> wrote:
>> >
>> > >  Still, it's just "works for me":
>> >
>> > seq 100 | time perl6 -ne 'my $y += $_; END { print $y; }'
>> >
>> > I think that's still the wrong one - your missing the "Int"
>> > $ seq 100 | perl6 -ne 'my Int $y += $_; END { print $y; }'
>> > 5050
>> >
>> > though that works here, admittedly, my p6 is sort old
>> > This is Rakudo version 2018.03 built on MoarVM version 2018.03
>> > implementing Perl 6.c.
>> >
>> > I'm a little puzzled, I'd've thought the loop around the 'my Int $y' would 
>> > redeclare a local $y each time.  Instead it behaves like:
>> > $ time perl6 -e 'my Int $y = 0;for ( 1 .. 100) { $y += $_} ;  say $y; '
>> >
>> > (which is signficantly faster ;-)
>> > 5050
>> > real 0m1.229s
>> > user 0m1.254s
>> > sys 0m0.040s
>> >
>> > )
>> > 
>> > From: Joseph Brenner 
>> > Sent: Wednesday, September 25, 2019 11:13 PM
>> > To: William Michels 
>> > Cc: Marc Chantreux ; Vittore Scolari 
>> > ; Elizabeth Mattijsen ; perl6 
>> > 
>> > Subject: Re: anything faster than say [+] lines?
>> >
>> > Oh, wait.  I tried the wrong one-liner.  Still, it's just "works for me":
>> >
>> > seq 100 | time perl6 -ne 'my $y += $_; END { print $y; }'
>> > 505029.29user 0.06system 0:28.41elapsed 103%CPU
>> > (0avgtext+0avgdata 76196maxresident)k
>> > 63328inputs+0outputs (32major+15588minor)pagefaults 0swaps
>> >
>> >
>> >
>> > On 9/25/19, Joseph Brenner  wrote:
>> > > I just gave that one-liner a try, but I didn't see that error:
>> > >
>> > >> seq 100 | time perl6 -e 'say [+] lines'
>> > > 5050
>> > > 28.70user 0.07system 0:28.29elapsed 101%CPU (0avgtext+0avgdata
>> > > 74188maxresident)k
>> > > 63424inputs+0outputs (32major+15409minor)pagefaults 0swaps
>> > >
>> > >
>> > > perl6 --version
>> > > This is Rakudo Star version 2019.03.1 built on MoarVM version 2019.03
>> > > implementing Perl 6.d.
>> > >
>> > > uname -a
>> > > Linux fandango 4.9.0-8-686 #1 SMP Debian 4.9.144-3 (2019-02-02) i686
>> 

Re: anything faster than say [+] lines?

2019-09-26 Thread Andy Bach
>  Still, it's just "works for me":

seq 100 | time perl6 -ne 'my $y += $_; END { print $y; }'

I think that's still the wrong one - your missing the "Int"
$ seq 100 | perl6 -ne 'my Int $y += $_; END { print $y; }'
5050

though that works here, admittedly, my p6 is sort old
This is Rakudo version 2018.03 built on MoarVM version 2018.03
implementing Perl 6.c.

I'm a little puzzled, I'd've thought the loop around the 'my Int $y' would 
redeclare a local $y each time.  Instead it behaves like:
$ time perl6 -e 'my Int $y = 0;for ( 1 .. 100) { $y += $_} ;  say $y; '

(which is signficantly faster ;-)
5050
real 0m1.229s
user 0m1.254s
sys 0m0.040s

)

From: Joseph Brenner 
Sent: Wednesday, September 25, 2019 11:13 PM
To: William Michels 
Cc: Marc Chantreux ; Vittore Scolari 
; Elizabeth Mattijsen ; perl6 

Subject: Re: anything faster than say [+] lines?

Oh, wait.  I tried the wrong one-liner.  Still, it's just "works for me":

seq 100 | time perl6 -ne 'my $y += $_; END { print $y; }'
505029.29user 0.06system 0:28.41elapsed 103%CPU
(0avgtext+0avgdata 76196maxresident)k
63328inputs+0outputs (32major+15588minor)pagefaults 0swaps



On 9/25/19, Joseph Brenner  wrote:
> I just gave that one-liner a try, but I didn't see that error:
>
>> seq 100 | time perl6 -e 'say [+] lines'
> 5050
> 28.70user 0.07system 0:28.29elapsed 101%CPU (0avgtext+0avgdata
> 74188maxresident)k
> 63424inputs+0outputs (32major+15409minor)pagefaults 0swaps
>
>
> perl6 --version
> This is Rakudo Star version 2019.03.1 built on MoarVM version 2019.03
> implementing Perl 6.d.
>
> uname -a
> Linux fandango 4.9.0-8-686 #1 SMP Debian 4.9.144-3 (2019-02-02) i686
> GNU/Linux
>
>
>
> On 9/24/19, William Michels via perl6-users  wrote:
>> I'm seeing a strange error. I started trying out Marc's original code,
>> then tried to adapt some Perl5-type solutions from SO to see how they
>> performed when re-written as Perl6. One thing I wanted to explicitly
>> test was how restricting to an "Int" type affected performance.
>>
>> However, I found a surprising result: a sequence of one-million Ints
>> throws an error, but a sequence of 999,999 Ints does not:
>>
>>> mbook:~ homedir$ seq 100 | time perl6 -e 'say [+] lines'
>>> 5050
>>> 4.81 real 4.86 user 0.20 sys
>>> mbook:~ homedir$ seq 100 | time perl6 -ne 'my $y += $_; END { print
>>> $y; }'
>>> 50504.88 real 5.06 user 0.19 sys
>>> mbook:~ homedir$ seq 100 | time perl6 -ne 'my Int $y += $_; END {
>>> print $y; }'
>>> Type check failed in assignment to $y; expected Int but got Num
>>> (5050e0)
>>>   in block  at -e line 1
>>> 49504.77 real 4.97 user 0.19 sys
>>> mbook:~ homedir$ seq 99 | time perl6 -ne 'my Int $y += $_; END {
>>> print
>>> $y; }'
>>> 49504.86 real 5.05 user 0.19 sys
>>> mbook:~ homedir$ perl6 -v
>>> This is Rakudo version 2019.07.1 built on MoarVM version 2019.07.1
>>> implementing Perl 6.d.
>>> mbook:~ homedir$
>>
>> Any comments or explanation appreciated,
>>
>> Best Regards, Bill.
>>
>>
>>
>>
>> On Tue, Sep 24, 2019 at 1:59 AM Marc Chantreux  wrote:
>>>
>>> hello,
>>>
>>> > > > > nice ... but when x is ~ 75440 (not always), there is a problem
>>> > > > What is x here?
>>> > > sorry. x is the arg of seq (number of lines).
>>> > That never happens on my laptop
>>>
>>> well.. so it's a problem with my station. nevermind :)
>>>
>>> thanks again for helping
>>> marc
>>
>


Re: core dump

2019-09-03 Thread Andy Bach
On my box, man core shows how to dump core using ctrl-backslash
$ perl
^\Quit (core dumped)

It also gives the example of creating a pipeline for core handling (.c file 
text below):
$ cc -o core_pattern_pipe_test core_pattern_pipe_test.c
   $ su
   Password:
   # echo "|$PWD/core_pattern_pipe_test %p UID=%u GID=%g sig=%s" > \
   /proc/sys/kernel/core_pattern
   # exit
   $ sleep 100
   ^\ # type control-backslash
   Quit (core dumped)
   $ cat core.info
   argc=5
   argc[0]=
   argc[1]=<20575>
   argc[2]=
   argc[3]=
   argc[4]=
   Total bytes in core dump: 282624

I used just
$ perl
^\Quit (core dumped)
$ cat core.info
argc=5
argc[0]=
argc[1]=<3804>
argc[2]=
argc[3]=
argc[4]=
Total bytes in core dump: 602112


  /* core_pattern_pipe_test.c */

   #define _GNU_SOURCE
   #include 
   #include 
   #include 
   #include 
   #include 
   #include 

   #define BUF_SIZE 1024

   int
   main(int argc, char *argv[])
   {
   int tot, j;
   ssize_t nread;
   char buf[BUF_SIZE];
   FILE *fp;
   char cwd[PATH_MAX];

   /* Change our current working directory to that of the
  crashing process */

   snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv[1]);
   chdir(cwd);

   /* Write output to file "core.info" in that directory */

   fp = fopen("core.info", "w+");
   if (fp == NULL)
   exit(EXIT_FAILURE);

   /* Display command-line arguments given to core_pattern
  pipe program */

   fprintf(fp, "argc=%d\n", argc);
   for (j = 0; j < argc; j++)
   fprintf(fp, "argc[%d]=<%s>\n", j, argv[j]);

   /* Count bytes in standard input (the core dump) */

   tot = 0;
   while ((nread = read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
   tot += nread;
   fprintf(fp, "Total bytes in core dump: %d\n", tot);

   fclose(fp);
   exit(EXIT_SUCCESS);
   }


From: ToddAndMargo via perl6-users 
Sent: Friday, August 30, 2019 7:21 PM
To: perl6-users@perl.org 
Subject: Re: core dump

On 8/9/19 3:41 PM, ToddAndMargo via perl6-users wrote:
> Hi All,
>
> Fedora 30
> rakudo-0.2019.03-2.fc30.x86_64
>
> I have a weird question.  I need to simulate a core
> dump under a bash (ulimit) shell.
>
> Any of you guys know who to get Perl to crash with a
> core dump?
>
> I need to prove that core dumps are not
> active on my system.  Or if I am mistaken.
>
>
> Many thanks,
> -T
>

Follow up:

  To trigger a core dump:
  $ kill -s SIGSEGV PID Subsitute your PID
  $ kill -s SIGSEGV $$  Will kill your current shell


Since core dumps have changed significantly under Fedora 30
(systemd), anyone wants my full notes, please ping me
on the subject line and respond on this thread.

-T


Re: while(<>){...} analog?

2019-07-31 Thread Andy Bach
> , but I had to change .split(':') either to .split(":") or

because your -e '  ' quotes are the same, so bash breaks it up into 3 chunks
say .split(
:
)[0, 2, 1, 5].join("\t") for

and perl just gets the first as the "program"


From: William Michels via perl6-users 
Sent: Wednesday, July 31, 2019 4:28 PM
To: Patrick R. Michaud 
Cc: perl6-users 
Subject: Re: while(<>){...} analog?

Hi Patrick, I used both your examples as perl6 one-liners. I'm not
sure why, but I had to change .split(':') either to .split(":") or
.split(/\:/) for both example to work. Maybe it's a command-line
thing? Possibly because I'm on a Mac? Also, to get the second example
to work I change the 'for lines' preamble to 'for lines()' then it's
fine (otherwise perl6 balks with an awesome error: "Function 'lines'
needs parens to avoid gobbling block").

Thanks again for all your help! --Best, Bill.

# test file: six_fruits1.txt
mbook:~ homedir$ cat six_fruits1.txt
apple:banana:carrot:dragonfruit:eggplant:favabean
apricot:basil:cabbage:dill:escarole:fennel
acai:beets:celery:daikon:endive:figs

# First example:
mbook:~ homedir$ perl6 -e 'say .split(":")[0, 2, 1, 5].join("\t") for
lines' six_fruits1.txt
apple carrot banana favabean
apricot cabbage basil fennel
acai celery beets figs
mbook:~ homedir$ perl6 -e 'say .split(/\:/)[0, 2, 1, 5].join("\t") for
lines' six_fruits1.txt
apple carrot banana favabean
apricot cabbage basil fennel
acai celery beets figs

# Second example: note changed 'for lines' to 'for lines()'
mbook:~ homedir$ perl6 -e ' for lines() { say .split(":")[0, 2, 1,
5].join("\t") }' six_fruits1.txt
apple carrot banana favabean
apricot cabbage basil fennel
acai celery beets figs
mbook:~ homedir$ perl6 -e ' for lines() { say .split(/\:/)[0, 2, 1,
5].join("\t") }' six_fruits1.txt
apple carrot banana favabean
apricot cabbage basil fennel
acai celery beets figs


On Mon, Jul 29, 2019 at 12:56 PM Patrick R. Michaud  wrote:
>
> My guesses at Perl 6 versions of the Perl 5 example:
>
>say .split(':')[0, 2, 1, 5].join("\t") for lines;
>
> -or-
>
>for lines { say .split(':')[0, 2, 1, 5].join("\t") }
>
> Pm
>
>
> On Mon, Jul 29, 2019 at 12:49:51PM -0700, William Michels via perl6-users 
> wrote:
> > Hello, Just a short backgrounder to say that this question arose this
> > past weekend at a Perl6 Meetup (Oakland, CA). Specifically we were
> > looking at how to write a Perl6 version of some introductory Perl5
> > code in "Learning Perl", 7th Edition by Tom Phoenix, brian d foy,
> > Randal L. Schwartz:
> >
> > #Perl 5 code below:
> > while (<>) {
> >   chomp;
> >   print join("\t", (split /:/)[0, 2, 1, 5] ), "\n";
> > }
> >
> > https://www.oreilly.com/library/view/learning-perl-7th/9781491954317/ch01.html
> >
> > (Thanks to Joseph Brenner for organizing the Perl6 Meetup).
> >
> >
> >
> >
> >
> >
> > On Mon, Jul 29, 2019 at 2:09 AM Elizabeth Mattijsen  wrote:
> > >
> > > Also, you can make this conditional:  show me all the comment lines of a 
> > > source file:
> > >
> > >
> > > $ perl6 -e '.say if .starts-with('#') for lines' source-file
> > >
> > >
> > > > On 29 Jul 2019, at 10:06, Richard Hainsworth  
> > > > wrote:
> > > >
> > > > Also no need for all the brackets
> > > >
> > > > .say for lines;
> > > >
> > > > This is quite idiomatic Perl 6 and not golfing
> > > >
> > > > On Mon, 29 Jul 2019, 07:13 Joseph Brenner,  wrote:
> > > > > Hmmm. I would expect that to be in the Perl 5 to Perl 6 Migration 
> > > > > Guides, but I do not see it there.
> > > >
> > > > Exactly, I was just looking there, and I ended up playing around with
> > > > the method form of lines, and didn't think to try the function
> > > > form of it.
> > > >
> > > > To summarize, if the goal is to write a "simple_echo" script that
> > > > can work with a file name or with lines on standard input:
> > > >
> > > >simple_echo lines.txt
> > > >cat lines.txt | simple_echo
> > > >
> > > > The perl5 version would probably be:
> > > >
> > > >   #!/usr/bin/env perl
> > > >   while(<>){
> > > >  print;
> > > >   }
> > > >
> > > > The perl6 version would be something like:
> > > >
> > > >   #!/usr/bin/env perl6
> > > >   use v6;
> > > >   for lines() {
> > > >   say $_;
> > > >   }
> > > >
> > > >
> > > > The kind of thing I was playing with was:
> > > >
> > > >   #!/usr/bin/env perl6
> > > >   use v6;
> > > >   my @lines = $*ARGFILES.IO.lines;
> > > >   say @lines;
> > > >
> > > > That works for lines from a file, but not from standard input, and  the
> > > > error message isn't tremendously helpful:
> > > >
> > > >   No such method 'lines' for invocant of type 'IO::Special'
> > > >
> > > >
> > > >
> > > >
> > > > On 7/28/19, Bruce Gray  wrote:
> > > > >
> > > > >
> > > > >> On Jul 28, 2019, at 6:20 PM, Joseph Brenner  
> > > > >> wrote:
> > > > >>
> > > > >> I was just wondering if there's some direct analog in perl6 to the
> > > > >> perl5 construct:
> > > > >>
> > > > >>  while(<>){ ... }
> > > > >>
> > > > >> If I'm 

Re: number of letters question

2018-05-15 Thread Andy Bach
> though from the problem question it sounds a lot more like what todd
wants is

my $input = "abcrd-12.3.4";
my $letters = $input.comb(/<[a..z]>/);
my $numbers = $input.comb(/<[a..z 0..9 .]>/);
say "the string $input has $letters letters and $numbers numbers and
periods.";
Just a note, I had to add a "+" to those assignments

my $letters = +$input.comb(/<[a..z]>/);
my $numbers = +$input.comb(/<[a..z 0..9 .]>/);

or otherwise I got a string of the "combed" chars:
the string abcrd-12.3.4 has a b c r d letters and a b c r d 1 2 . 3 . 4
numbers and periods.

On Tue, May 15, 2018 at 9:10 AM, Timo Paulssen <t...@wakelift.de> wrote:

> I'd suggest combing for the regex instead of combing and then grepping
> with the regex:
>
> say + "abcrd-12.3.4".comb(//);
>
> though from the problem question it sounds a lot more like what todd wants
> is
>
> my $input = "abcrd-12.3.4";
> my $letters = $input.comb(/<[a..z]>/);
> my $numbers = $input.comb(/<[a..z 0..9 .]>/);
> say "the string $input has $letters letters and $numbers numbers and
> periods.";
>
> On 15/05/18 09:57, JJ Merelo wrote:
>
> Well,
> say + "abcrd-12.3.4".comb.grep: //
> will give you that, but
> say + "abcñé-12.3.4".comb.grep: //
> will yield the same result.
> Roman or other kind of numerals are excluded, though...
>
>
> El mar., 15 may. 2018 a las 9:44, ToddAndMargo (<toddandma...@zoho.com>)
> escribió:
>
>> On 05/15/2018 12:37 AM, JJ Merelo wrote:
>> > Hi,
>> >
>> > El mar., 15 may. 2018 a las 9:31, ToddAndMargo (<toddandma...@zoho.com
>> > <mailto:toddandma...@zoho.com>>) escribió:
>> >
>> >  >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo
>> > (<toddandma...@zoho.com <mailto:toddandma...@zoho.com>
>> >  >> <mailto:toddandma...@zoho.com <mailto:toddandma...@zoho.com>>>)
>> > escribió:
>> >  >>
>> >  >> Hi All,
>> >  >>
>> >  >> Do we have one of those sweet functions that will
>> >  >> allow us to look at a string and give us back the
>> >  >> count of how many "letters" and/or "numbers" are
>> >  >> in a string?
>> >  >>
>> >  >> And are decimal points considered numbers or letters?
>> >  >>
>> >  >> Many thanks,
>> >  >> -T
>> >  >>
>> >
>> > On 05/14/2018 11:44 PM, JJ Merelo wrote:
>> >  > IN Perl 6, it's a bit more complicated. Do you want to count
>> > graphemes
>> >  > or codepoints?
>> >  >
>> >
>> > I want to know the number of letters A..Z (ascii 65..90), a..z
>> > (ascii 97..122),
>> >
>> > and the numbers of numbers 0..9 (ascii 48..57) and decimal points
>> > (ascii 46).
>> >
>> >
>> > Once again, that's not so simple. You don't want other kind of numbers?
>> > Would á count as one a and one '?
>> >
>> >
>> > I won't have an weird characters in these stings, such as !@#$^&%(
>> >
>> >
>> > Whoa, whoa, whoa, you calling á and ñ weird?
>> >
>> > Anyway, if that's what you want, just filter those precise graphemes
>> and
>> > count the number of graphemes.
>> >
>> > Cheers
>> >
>> > JJ
>>
>> "abcrd-12.3.4"  would be five letters, six numbers, and one
>> I don't care.
>>
>
>
> --
> JJ
>
>
>


-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: how do I match the next two characters?

2018-01-18 Thread Andy Bach
>The '?' is not necessary ;-)

perl6 -e 'my $x="abcsdd1efg1234xyz"; $x ~~ m/(sd..).*(12..)/; say "$0, $1"'
sdd1, 1234

The "?" is to modify the "*" to be "non-greedy" - that is, it will match
the first chunk of stuff that is followed by whatever is after it (so,
"/*?/" the "?" is certainly unneeded) as opposed to the normal meaning
of "*" which is, "match as much of anything ("excepting newline") as
possible" - so ".*?12" matches up to the first "12" while ".*12" matches as
much as possible up to a last "12"

a

On Thu, Jan 18, 2018 at 7:17 PM, mimosinnet <mimosin...@gmail.com> wrote:

> Thanks for this thread
>
> El Tuesday, 16 de January del 2018 a les 19:28, Todd Chester va escriure:
>
> But I do have to use `.*?` in the middle when matching two things
>>
>> $ perl6 -e 'my $x="abcsdd1efg1234xyz"; $x ~~ m/(sd..).*?(12..)/; say
>> "$0, $1"'
>> sdd1, 1234
>>
>
> The '?' is not necessary ;-)
>
> perl6 -e 'my $x="abcsdd1efg1234xyz"; $x ~~ m/(sd..).*(12..)/; say "$0, $1"'
> sdd1, 1234
>
>
> Cheers!




-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Self invoked anonymous functions with no outer scoped ???

2017-12-08 Thread Andy Bach
I ran into this article
https://medium.com/@kasperpeulen/an-interesting-programming-feature-that-no-language-has-except-php-4de22f9e3964

The feature allows [you] to write *self invoked anonymous functions that
don’t let any scope from the outer function leak in*. The syntax he
proposes involves the *use* keyword, followed by explicit parameters, which
is followed by a block that can use those parameters and return a value.

But I don't quite (er, okay, at all) understand what the point is.  Just
curious if P6 has anything along this sort thing.

-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: <<>> question

2017-10-05 Thread Andy Bach
> is
   <<>>
> synonymous with
   qw[]
?

IIUC - close, it like qqw:
https://docs.perl6.org/language/quoting#index-entry-quote_qqww-quote_
<<_>>-quote_«_»-Word_quoting_with_interpolation_and_quote_protection:_qqww

It's actually synonymous w/ qqww but depending upon your use of quotes w/i
the list elements, it works out the same as qqww ... except for that whole
"allomorph" aspect

> my $a = 42
42
> say qww{"$a b" c}.perl
("42 b", "c")
> say qw{"$a b" c}.perl
("\"\$a", "b\"", "c")
> say qqw{"$a b" c}.perl
("\"42", "b\"", "c")
> say qqww{"$a b" c}.perl
("42 b", "c")
> say <<"$a b" c>>.perl
("42 b", "c")
> say <<$a b c>>.perl
(IntStr.new(42, "42"), "b", "c")
> say qw{$a b c}.perl
("\$a", "b", "c")
> say qqw{$a b c}.perl
("42", "b", "c")
> say qqww{$a b c}.perl
("42", "b", "c")
> say qww{$a b c}.perl
("\$a", "b", "c")


On Wed, Oct 4, 2017 at 10:22 PM, Todd Chester <toddandma...@zoho.com> wrote:

> On 10/04/2017 08:20 PM, Todd Chester wrote:
>
>> So in this context "{$x}" means insert (interpolate) a
>> variable into the list?  I was thinking it meant to
>> insert a variable into a string.  Did saying <<>>
>> automatically tell Perl6 that this was a list
>> and not a sting?
>>
>
>
> is
><<>>
> synonymous with
>qw[]
> ?
>



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: <<>> question

2017-10-04 Thread Andy Bach
> I think maybe I don't understand how <<>> is used in a
and how <<>> differs from a ""

<<>> is quoteword, no commas needed. You get back a list.  "" create a
string, you get back a single thing.

my $z=<<xyz{$x}def>>;
(xyz abc def)

is the same as
my $z=<>;
(xyz abc def)


> my $x = "ab";
ab
> my $z=<>;
(xyz ab def)
> my $y = "xxy $x def";
xxy ab def
> $z.WHAT
(List)
> $y.WHAT
(Str)
> my $q = ["xyz", $x, "def"];
[xyz ab def]
> $q.WHAT
(Array)
> my $r = ("xyz", $x, "def");
(xyz ab def)
> $r.WHAT
(List)



On Wed, Oct 4, 2017 at 2:25 PM, ToddAndMargo <toddandma...@zoho.com> wrote:

>
> On Wed, Oct 4, 2017 at 1:29 PM, ToddAndMargo <toddandma...@zoho.com
>>> <mailto:toddandma...@zoho.com>> wrote:
>>>
>>> On 10/02/2017 01:18 PM, ToddAndMargo wrote:
>>>
>>> Hi All,
>>>
>>> I am writing up a keeper note on <<>> and such.  This example
>>> puzzles me.  Why the space?
>>>
>>>
>>> Example of <<>> (double quote and allow insertion of variables
>>> into strings):
>>>
>>>
>>>  $ perl6 -e 'my $x="abc"; my $y=<<xyz{$x}def>>; say "\$x=$x
>>> \$y=$y";'
>>>  $x=abc $y=xyz abc def
>>>
>>>
>>>
>>> Many thanks,
>>> -T
>>>
>>>
>>>
>>> Hi Guys,
>>>
>>> I am trying to document for myself what the difference is
>>> between "" and <<>>.
>>>
>>> Maybe I should rephrase the  question.  Why are these
>>> two different?  Why the spaces when using <<>>?
>>>
>>> $ perl6 -e 'my $x="abc"; my $y=<<xyz{$x}def>>; say "\$x=$x \$y=$y";'
>>> $x=abc $y=xyz abc def
>>>
>>> $ perl6 -e 'my $x="abc"; my $y="xyz{$x}def"; say "\$x=$x \$y=$y";'
>>> $x=abc $y=xyzabcdef
>>>
>>>
>>> -T
>>>
>>>
>
>
>
> On 10/04/2017 11:45 AM, Andy Bach wrote:
>
>> Why the spaces when using <<>>?
>>
>> in REPL
>>  > my $x="abc"; my $y="xyz{$x}def"; say "\$x=$x \$y=$y"
>> $x=abc $y=xyzabcdef
>>  > $y.WHAT
>> (Str)
>>  > $x.WHAT
>> (Str)
>>  > my $z=<<xyz{$x}def>>;
>> (xyz abc def)
>>  > $z.WHAT
>> (List)
>>
>> <<>> makes a list, the { } make a closure, so you've got 3 things in the
>> list; "xyz", the value of $x ("abc"), and "def"
>>  > $z=<<xyz$xdef>>;
>> ===SORRY!=== Error while compiling:
>> Variable '$xdef' is not declared
>> --> $z=<<xyz⏏$xdef>>;
>>
>>  > $z=<<xyz$x def>>;
>> (xyz abc def)
>>
>
>
> Love that "what" command.
>
> I think maybe I don't understand how <<>> is used in a
> and how <<>> differs from a ""
>



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: <<>> question

2017-10-04 Thread Andy Bach
> It's the same as in perl5, an array interpolated in a string shows its
> elements with spaces in between. Your example has an array stored in $y.

Typo alert - you were printing  $x/@x, not y
perl -e 'my @y=("ab",12,"xx");print "y=@y\n"'
y=ab 12 xx

perl6 -e 'my $y=("ab",12,"xx");print "y=$y\n"'
y=ab 12 xx

in p5, that's the $" (use English; $LIST_SEPARATOR) var that is used to
separate lists when interpolated in a string:
perl  -e 'my @y=("ab",12,"xx"); $" = "|"; print "y=@y\n"'
y=ab|12|xx

perl -e 'use English; my @y=("ab",12,"xx"); $LIST_SEPARATOR = ", "; print
"y=@y\n"'
y=ab, 12, xx

P6 complains
Unsupported use of $" variable; in Perl 6 please use .join() method

so:
perl6 -e 'my $y=("ab",12,"xx"); print "y=", $y.join(", "), "\n"'
perl6 -e 'my @y=("ab",12,"xx");print "y=", @y.join(", "), "\n"'



On Wed, Oct 4, 2017 at 6:02 AM, yary <not@gmail.com> wrote:

> > Hi All,
> > I am writing up a keeper note on <<>> and such.  This example
> > puzzles me.  Why the space?
>
> It's the same as in perl5, an array interpolated in a string shows its
> elements with spaces in between. Your example has an array stored in
> $y.
>
> perl -e 'my @y=("ab",12,"xx");print "y=@x\n"'
> y=ab 12 xx
>
> perl6 -e 'my $y=("ab",12,"xx");print "y=$x\n"'
> y=ab 12 xx
>
>
> -y
>



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: Tip: hash indexing

2017-10-03 Thread Andy Bach
Though this seems to be heading the wrong way but - TIMTOWTDI
my @SmtpIndex =
   qw[ DebugTrace smtp port username password from to Subject Text FileName
];

my @SmtpValues = ["1", "smtps://smtp.zoho.com", "465", 'la...@zoho.com',
"NaYukYukYuk",
'la...@zoho.com', @['cu...@zoho.com','m...@zoho.com'], "Stooges",
"Certainly!", @[""] ];

my %Smtp = zip @SmtpIndex, @SmtpValues;

I guess I could imagine the values coming from a fixed order data file, so
a loop would do the zip with a split of each line but ...


On Tue, Oct 3, 2017 at 1:21 PM, ToddAndMargo <toddandma...@zoho.com> wrote:

> Sweet!I added a reverse print to the pile!
>
> 
> #!/usr/bin/env perl6
>
> #`{
>   Hashes do not print in the order they are created.  it is a Perl 6 thing.
>   To overcome this, create an index of the hash.
> }
>
> my @SmtpIndex =
>qw[ DebugTrace smtp port username password from to Subject Text
> FileName ];
>
> my %Smtp =
>   [ "{ @SmtpIndex[0] }" => "1",
> "{ @SmtpIndex[1] }" => "smtps://smtp.zoho.com",
> "{ @SmtpIndex[2] }" => "465",
> "{ @SmtpIndex[3] }" => 'la...@zoho.com',
> "{ @SmtpIndex[4] }" => "NaYukYukYuk",
> "{ @SmtpIndex[5] }" => 'la...@zoho.com',
> "{ @SmtpIndex[6] }" => @['cu...@zoho.com','m...@zoho.com'],
> "{ @SmtpIndex[7] }" => "Stooges",
> "{ @SmtpIndex[8] }" => "Certainly!",
> "{ @SmtpIndex[9] }" => @[""] ];
>
> sub output(%hash, @index=@SmtpIndex) {
> for @index -> $key {
> printf "%10s = %s\n", $key, %hash{$key};
> }
> print "\n";
> }
>
> sub revoutput(%hash, @index=@SmtpIndex) {
> for reverse ( @index ) -> $key {
> printf "%10s = %s\n", $key, %hash{$key};
> }
> print "\n";
> }
>
>
> my @SmtpValues = %Smtp{@SmtpIndex};
>
> my %Smtp2 = do {
> my $index = 0;
> @SmtpValues.map: { "{ @SmtpIndex[$index++] }" => $_ };
> };
>
> my %Smtp3 = gather for 0..@SmtpIndex.elems-1 {
> take @SmtpIndex[$_] => @SmtpValues[$_].Str;
> };
>
> my %Smtp4 = @SmtpIndex Z=> @SmtpValues;
>
> # These are all equivalent
> # output(%Smtp);
> # output(%Smtp2);
> # output(%Smtp3);
> output(%Smtp4);
>
> # print in reverse
> revoutput(%Smtp4);
> 
>
> $ HashIndexTest.pl6
> DebugTrace = 1
>   smtp = smtps://smtp.zoho.com
>   port = 465
>   username = la...@zoho.com
>   password = NaYukYukYuk
>   from = la...@zoho.com
> to = cu...@zoho.com m...@zoho.com
>Subject = Stooges
>   Text = Certainly!
>   FileName =
>
>   FileName =
>   Text = Certainly!
>Subject = Stooges
> to = cu...@zoho.com m...@zoho.com
>   from = la...@zoho.com
>   password = NaYukYukYuk
>   username = la...@zoho.com
>   port = 465
>   smtp = smtps://smtp.zoho.com
> DebugTrace = 1
>



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: Need append help

2017-09-29 Thread Andy Bach
Hmm
$ perl6 -e 'my $x="abc"; $x [R~]= "yyz"; say $x;'
yyzabc

no space:
$ perl6 -e 'my $x="abc"; $x[R~]= "yyz"; say $x;'
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
--> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
expecting any of:
prefix
term

$ perl6 -v
This is Rakudo version 2016.10-285-gee8ae92 built on MoarVM version
2016.10-55-g20c8591
implementing Perl 6.c.

$ rakudo-star-2017.07/install/bin/perl6 -v
This is Rakudo version 2017.07 built on MoarVM version 2017.07
implementing Perl 6.c.

$ rakudo-star-2017.07/install/bin/perl6 -e 'my $x="abc"; $x [R~]= "yyz";
say $x;'
Potential difficulties:
Useless use of [R~]= in sink context
at -e:1
--> my $x="abc"; $x ⏏[R~]= "yyz"; say $x;
yyzabc

no space
$ rakudo-star-2017.07/install/bin/perl6 -e 'my $x="abc"; $x[R~]= "yyz"; say
$x;'
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
--> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
expecting any of:
prefix
term


On Fri, Sep 29, 2017 at 1:59 PM, ToddAndMargo <toddandma...@zoho.com> wrote:

> On 09/29/2017 11:32 AM, Sean McAfee wrote:
>
>> On Fri, Sep 29, 2017 at 11:27 AM, Brandon Allbery <allber...@gmail.com
>> <mailto:allber...@gmail.com>> wrote:
>>
>> On Fri, Sep 29, 2017 at 2:04 PM, ToddAndMargo <toddandma...@zoho.com
>> <mailto:toddandma...@zoho.com>> wrote:
>>
>>
>> Question:  Is thee a pretty way like the above to do a prepend?
>>
>>
>> No, sorry.
>>
>>
>> Actually, there seems to be:
>>
>>  > my $x = "abc"
>> abc
>>  > $x [R~]= "xyz"
>> xyzabc
>>  > $x
>> xyzabc
>>
>>
> :'(
>
> What am I doing wrong?
>
>
> $ perl6 -e 'my $x="abc"; $x [R~]= "yyz"; say $x;'
> ===SORRY!=== Error while compiling -e
> Missing required term after infix
> at -e:1
> --> my $x="abc"; $x[R~⏏]= "yyz"; say $x;
> expecting any of:
> prefix
> term
>
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: write bytes requires an object with REPR MVMOSHandle

2017-09-29 Thread Andy Bach
close ( $SmtpHandle ); }

Your indenting has done you wrong - you close the file handle inside the
loop for loop, so it closed after the first print.

On Fri, Sep 29, 2017 at 1:49 AM, ToddAndMargo <toddandma...@zoho.com> wrote:

> Hi All,
>
> I am stumped.  This only screws up in the for loop.
>
> This is only the chopped up version
>
> 
> #!/usr/bin/env perl6
>
> my $SmtpIniFileName = $?FILE ~ ".ini";
> my %SmtpIni = [ 'DebugTrace' => "",  #   1 | 0  (-vvv)
> 'smtp'   => "",  #   smtp.zoho.com
> 'port'   => "",  #   465 (ssl), 587 (tls), 25, 80,
> 3535 etc.
> 'username'   => "",  #   Typically the sender's eMail
> address, but not always.
>  #   Blank will default tothe
> sender's eMail address;
> 'password'   => "",  #   User's ($username) password
> 'from'   => "",  #   The sender's eMail address;
> 'to' => @[""],   #   qw [ la...@zoho.com
> cur...@gmail.com ];   # This is an array, not a string; delimit with a
> space
> 'Subject'=> "",  #   Subject of the eMail
> 'Text'   => "",  #   Body (verbage) of the eMail
> 'FileName'   => @[""] ]; #   attachment path and name.
> Leave blank for no attachment
>
>
> sub PrintRed( $Str ) { print color('bold'), color('red'),   "$Str",
> color('reset'); }
> sub PrintGreen  ( $Str ) { print color('bold'), color('green'), "$Str",
> color('reset'); }
> sub PrintBlue   ( $Str ) { print color('bold'), color('blue'),  "$Str",
> color('reset'); }
> sub PrintRedErr ( $Str ) { $*ERR.print: color('bold'), color('red'),
> "$Str", color('reset'); }
>
> sub CreateSmtpIni () {
> my $SmtpHandle = open( $SmtpIniFileName, :rw );  # Read/write,
> create if does not exist
> chmod 0o400, $SmtpIniFileName;   # Read//write to
> root only
> RunNoShell ( "chown root.root $SmtpIniFileName" );
>
> $SmtpHandle.print( "# SmtpIni file for for $IAm\n" );
> $SmtpHandle.print( "#This file must be owned by root.root and
> have a permission of 400\n" );
> $SmtpHandle.print( "#Do not use a space after the = sign.  \n"
> );
> $SmtpHandle.print( "#\n" );
>
> for %SmtpIni.kv -> $key, $value {
> PrintGreen ( "key = <$key>  value =<$value>\n" );
>if( $key eq "to" )   { $SmtpHandle.print( "$key=
> #delimiter is a comma\n" ); }
>elsif ( $key eq "FileName" ) { $SmtpHandle.print( "$key= #delimiter
> is a comma\n" ); }
>else { $SmtpHandle.print( "$key=\n" ); }
> close ( $SmtpHandle ); }
>
> PrintRedErr ( "$SmtpIniFileName was not found.  Recreating a blank
> template.\n" );
> PrintRedErr ( "Please edit this template and try again.  Cowardly
> existing.  Bummer dude.\n\n" );
> exit 2;
> }
>
> CreateSmtpIni();
>
> 
>
> # CheckRaid.pl6
> key =   value =<>
> key =   value =<>
> write bytes requires an object with REPR MVMOSHandle (got VMNull with REPR
> Null)
>   in sub CreateSmtpIni at ./CheckRaid.pl6 line 52
>   in sub GetSmtpIni at ./CheckRaid.pl6 line 62
>   in block  at ./CheckRaid.pl6 line 143
>
> Line 52 is
> else { $SmtpHandle.print( "$key=\n" ); }
>
> # cat CheckRaid.pl6.ini
> # SmtpIni file for for CheckRaid.pl6
> #This file must be owned by root.root and have a permission of 400
> #Do not use a space after the = sign.
> #
> Subject=
>



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: Any "note" without the "say"?

2017-09-18 Thread Andy Bach
> "note" is the same thing as "say", but to the std error:

Er, I was referring more to the P5 behaviour of warn() - w/o a newline, its
output, to stderr, included more info:
$  perl -e 'warn("hi mom")'  > /dev/null
hi mom at -e line 1.

$  perl -e 'warn("hi mom\n")' > /dev/null
hi mom

"note" appears to append a new line and p6 warn appears to always add the
extra info.  Looking at
https://docs.perl6.org/routine/warn

I see warn is doing even more that.

Thanks.

On Fri, Sep 15, 2017 at 3:58 PM, ToddAndMargo <toddandma...@zoho.com> wrote:

> On 09/15/2017 01:48 PM, Andy Bach wrote:
>
>> So "note"
>> $ perl6 -e 'note "hi mom"' > /dev/null
>> hi mom
>>
>> replaces "warn ...\n" or
>>
>> $ perl6 -e 'warn "hi mom\n"' > /dev/null
>> hi mom
>>
>>in block  at -e line 1
>>
>> have I forgotten my p6 newline syntax (again)?
>>
>
>
> Hi Andy,
>
> Oh goody.  I get to help someone for once!
>
> "note" is the same thing as "say", but to the std error:
>
> $ perl6 -e '$*ERR.say: "print to std err";'
> print to std err
>
> $ perl6 -e 'note "print to std err";'
> print to std err
>
> $ perl6 -e 'note "print to std err";' > /dev/null
> print to std err
>
> $ perl6 -e 'note "print ", "to ", "std err";' > /dev/null 2>&1
> 
>
> "2>&1" redirects STDERR to STDOUT.  And, you put it "after"
> the "/dev/null".  It is a "bash" thing.
>
>
> > have I forgotten my p6 newline syntax (again)?
>
> "\n".  It means new line.  Perl takes care of whether or
> not that is a CR-LF or a LF depending on the OS involved.
>
> example:
> $ perl6 -e '$*ERR.print: "print to std err\n";'
> print to std err
>
>
> -T
>
> --
> ~~~
> Serious error.
> All shortcuts have disappeared.
> Screen. Mind. Both are blank.
> ~~~
>



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: Any "note" without the "say"?

2017-09-15 Thread Andy Bach
>
>
> Oh well, neither is "note".  Someone must have
> had a special need for it at one time.
>

> Everyone does at one time :) It's really useful for debugging, but you
generally strip it out of production code.

So "note"
$ perl6 -e 'note "hi mom"' > /dev/null
hi mom

replaces "warn ...\n" or

$ perl6 -e 'warn "hi mom\n"' > /dev/null
hi mom

  in block  at -e line 1

have I forgotten my p6 newline syntax (again)?

On Fri, Sep 15, 2017 at 3:29 PM, Brandon Allbery <allber...@gmail.com>
wrote:

> On Fri, Sep 15, 2017 at 4:02 PM, ToddAndMargo <toddandma...@zoho.com>
> wrote:
>
>> On 09/15/2017 12:52 PM, Brandon Allbery wrote:
>>
>>> On Fri, Sep 15, 2017 at 3:48 PM, ToddAndMargo <toddandma...@zoho.com
>>> <mailto:toddandma...@zoho.com>> wrote:
>>>
>>> Is there a similar "print" to the STDERR for when
>>> you don't want the cr-lf inserted?
>>>
>>> The hard way:
>>> $*ERR.print: "print to std err\n";
>>>
>>>
>>> That's it. It's not really common enough to deserve something shorter.
>>>
>>
>> Thank you for the confirmation.  Searching for
>> something like this brings up a bazillion Perl 5 hits.
>>
>> Oh well, neither is "note".  Someone must have
>> had a special need for it at one time.
>>
>
> Everyone does at one time :) It's really useful for debugging, but you
> generally strip it out of production code.
>
> --
> brandon s allbery kf8nh   sine nomine
> associates
> allber...@gmail.com
> ballb...@sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: Any text editors for programming that support the secondary selection clipboard?

2017-06-20 Thread Andy Bach
On Tue, Jun 20, 2017 at 4:43 PM, ToddAndMargo <toddandma...@zoho.com> wrote:

> Bummer on the VI !  It inserts above the cursor


try
:help insert
a - append after cursor
A - append at end of line
i - insert before cursor
I - insert before first non-blank in the line
o - open a line below cursor
O - open a line above

for pasting see
:help paste

but vim also supports yanking into name buffers, so you can save as many as
you want (well, 26?) and the put from them
:help yank
:help put

vim does everything, you just have to find it. ;->
-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: next

2017-06-19 Thread Andy Bach
On Mon, Jun 19, 2017 at 11:35 AM, Brad Gilbert <b2gi...@gmail.com> wrote:

> Instead of a `continue` block after the loop, there is a `NEXT` phaser
> inside the block
>

ah, thanks (though the term "phaser" (outside of "set on stun", of course)
is new) and that can be block too:
https://docs.perl6.org/language/5to6-nutshell.html#Flow_Control_statements

   my $str = '';
for 1..5 {
next if $_ % 2 == 1;
$str ~= $_;
NEXT {
$str ~= ':'
    }
}



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: next

2017-06-19 Thread Andy Bach
On Fri, Jun 16, 2017 at 11:11 PM, Gabor Szabo <szab...@gmail.com> wrote:

> If the loop has some action and a condition it will jump to  execute
> the action again (increment $i) and check the condition and act
> accordingly doing the next iteration or quitting the loop.
>

Just checking but there are no "continue" blocks for loop control stmts
anymore, P6? Google suggested maybe foreach loops but that was back in 2011.


-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: What to do when a pattern match fails

2017-03-14 Thread Andy Bach
On Mon, Mar 13, 2017 at 8:40 PM, ToddAndMargo <toddandma...@zoho.com> wrote:

> To grab something from the middle:
>
> $ perl6 -e 'my $x="blah(good stuff 123)yuk";
>  $x ~~ m |.*\((.*)\)|;
>  say "$x\n\$0=<$0>";'
>

Just a further refinement - if you want only the stuff between inner parens
e.g.
my $x="blah(good stuff 123)yuk(more yuk)";

use the negated char class of the closing marker, in P5
 $x =~ m |.*\(([^)]*)\)|;
The initial ".*" isn't very helpful as:
 $x =~ m |\(([^)]*)\)|;

matches just as well.  I try to avoid untested matches, see the earlier
msg, but:
   if ( $x =~ m |.*\(([^)]*)\)|  ) {
# we got one
   }
   else {
 # no match
   }

Esp. (again P5) as, if the match fails, $0 et alia will continue to hold
what ever they had from before, e.g.
 my $y="blah(bad stuff abc)yuk(more yuk)";
 $y =~ m |.*\(([^)]*)\)|;  # $0 has "bad stuff abc
 my $x="blah[good stuff 123]yuk";   # wrong brackets
 $x =~ m |.*\(([^)]*)\)|;
# $0 still has "bad stuff abc"
 if ( defined $0 ) {
   # probably not what you wanted.


-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: panda install error

2017-01-14 Thread Andy Bach
On Fri, Jan 13, 2017 at 7:28 PM, ToddAndMargo <toddandma...@zoho.com> wrote:

> # Failed test 'Get file stor.txt success'
> # at t/05-put-get.t line 11
>
> # Failed test 'Put file some.txt success'
> # at t/05-put-get.t line 12
> # Looks like you failed 2 tests of 2
>

get/put test might be ftp connection failures, though.  Configuration
and/or firewall problems.  If the rest all passed, you might just force the
install and see if it works.

Net::FTP guide:
http://www.perlmonks.org/?node_id=190020


-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Building Rakudo 2016-11 in bash on Win10 - worked!

2016-11-28 Thread Andy Bach
32-list/classify-list.t
Missing test file: t/spec/S32-list/cross.t
Missing test file: t/spec/S32-list/deepmap.t
Missing test file: t/spec/S32-list/duckmap.t
Missing test file: t/spec/S32-list/first-end-kv.t
Missing test file: t/spec/S32-list/first-kv.t
Missing test file: t/spec/S32-str/parse-base.t
...

Test Summary Report
---
t/spec/S03-metaops/hyper.rakudo.moar(Wstat: 0
Tests: 402 Failed: 0)
  TODO passed:   115
t/spec/S05-modifier/counted-match.rakudo.moar   (Wstat: 0
Tests: 29 Failed: 0)
  TODO passed:   19-20, 25-27
t/spec/S05-substitution/subst.rakudo.moar   (Wstat: 0
Tests: 179 Failed: 0)
  TODO passed:   63
t/spec/S15-nfg/regex.rakudo.moar(Wstat: 0
Tests: 12 Failed: 0)
  TODO passed:   10
t/spec/S26-documentation/09-configuration.rakudo.moar   (Wstat: 0
Tests: 17 Failed: 0)
  TODO passed:   8-10
t/spec/S32-io/IO-Socket-Async.t (Wstat: 65280
Tests: 2 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 6 tests but ran 2.
t/spec/S32-io/pipe.t(Wstat: 65280
Tests: 10 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 14 tests but ran 10.
t/spec/S32-str/substr.rakudo.moar   (Wstat: 0
Tests: 56 Failed: 0)
  TODO passed:   56
t/spec/integration/advent2012-day15.rakudo.moar (Wstat: 0
Tests: 11 Failed: 0)
  TODO passed:   9
Files=1092, Tests=51347, 2226 wallclock secs (14.34 usr 33.79 sys + 1332.52
cusr 581.81 csys = 1962.46 CPU)
Result: FAIL
make[1]: *** [m-spectest5] Error 1

but install worked
andy@ANDY-HP:~/src/rakudo-star-2016.11$ perl6 -v
This is Rakudo version 2016.11 built on MoarVM version 2016.11
implementing Perl 6.c.

-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: rakudo bug 128427 perl 5 does not build on Darwin platforms with clock_gettime

2016-11-15 Thread Andy Bach
>> so I copied
git_reference/MoarVM/src/platform/posix/time.c

>> to
moar-nom/nqp/MoarVM/src/platform/posix/time.c

>> and now it builds.

On Tue, Nov 15, 2016 at 12:15 PM, Tobias Leich <em...@froggs.de> wrote:

> Hi, if you let raukdo automatically rebuild nqp/moar, then you still were
> on an old revision of moarvm.
> This revision did not contain the latest patch.
>
Yeah, that's why I tried nuking it.  I'd noticed just re-running rakudobrew
build moar did check the repository but didn't rebuild.

> Please rebuild now, as I've updated the git revisions, so latest nqp and
> moarvm get build.
>
Thanks! I'll try at home tonight. I didn't see a "rakudobrew clean" option
- I first tried deleting (after the copy) the
moar-nom/nqp/MoarVM/src/platform/posix/time.o
hoping make would see it missing and rebuild. I then deleted the
install/bin/moar (noticing it was saying "found a install/bin/moar version
xx, using that) and re-re-ran rakudobuild and that one worked.


-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: rakudo bug 128427 perl 5 does not build on Darwin platforms with clock_gettime

2016-11-15 Thread Andy Bach
oar-nom/nqp/MoarVM/src/platform/posix/time.c

On Tue, Nov 15, 2016 at 6:23 AM, <em...@froggs.de> wrote:

> Hi, we addressed it here


Well, I just nuked and built moar-nom here OSX 10.11.6/Xcode 8
15.6.0 Darwin Kernel Version 15.6.0: Wed Nov  2 20:30:56 PDT 2016;
root:xnu-3248.60.11.1.2~2/RELEASE_X86_64 x86_64

and:
moar-nom/nqp/MoarVM/src/platform/posix/time.c

is still the same and the build fails [1]. so I copied
git_reference/MoarVM/src/platform/posix/time.c

to
moar-nom/nqp/MoarVM/src/platform/posix/time.c

and now it builds.  I see about 12-15 warnings but ...

[1]
Configuring native build environment ... OK
probing whether your compiler thinks that it is gcc  YES
probing how your compiler does static inline ... static __inline__
your CPU can read unaligned values for all of int32 int64 num64
probing the size of pointers ... 8
probing C type support for: _Bool, bool  YES: _Bool,bool
probing computed goto support .. YES
probing pthread_yield support .. NO

make: make
 compile: clang -fno-omit-frame-pointer -fno-optimize-sibling-calls -O3
-DNDEBUG -Wno-logical-op-parentheses -D_DARWIN_USE_64_BIT_INODE=1
includes:  -I3rdparty/libuv/include -I3rdparty/libuv/src
-I3rdparty/libatomic_ops/src -I3rdparty/libtommath -I3rdparty/dynasm
-I3rdparty/dyncall/dynload -I3rdparty/dyncall/dyncall
-I3rdparty/dyncall/dyncallback
link: clang  -O3 -DNDEBUG -Wl,-rpath,"/@libdir@"
-Wl,-rpath,"@prefix@/share/perl6/site/lib"
libs: -lpthread

  byte order: little endian

...

/usr/local/bin/perl -MExtUtils::Command -e cp
3rdparty/dyncall/dyncallback/*.h
/Users/afbach/.rakudobrew/moar-nom/install/include/dyncall
dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
  Referenced from:
/Users/afbach/.rakudobrew/moar-nom/install/lib/libmoar.dylib (which was
built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _clock_gettime
  Referenced from:
/Users/afbach/.rakudobrew/moar-nom/install/lib/libmoar.dylib (which was
built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib

Cleaning up ...
/usr/local/bin/perl -MExtUtils::Command -e mkpath gen/moar/stage1/gen
/usr/local/bin/perl tools/build/gen-cat.pl moar src/how/Archetypes.nqp
src/how/RoleToRoleApplier.nqp src/how/NQPConcreteRoleHOW.nqp
src/how/RoleToClassApplier.nqp src/how/NQPCurriedRoleHOW.nqp
src/how/NQPParametricRoleHOW.nqp src/how/NQPClassHOW.nqp
src/how/NQPNativeHOW.nqp src/how/NQPAttribute.nqp src/how/NQPModuleHOW.nqp
src/how/EXPORTHOW.nqp  > gen/moar/stage1/nqpmo.nqp
/Users/afbach/.rakudobrew/moar-nom/install/bin/moar
--libpath=src/vm/moar/stage0 src/vm/moar/stage0/nqp.moarvm --bootstrap
--setting=NULL --no-regex-lib --target=mbc \
--output=gen/moar/stage1/nqpmo.moarvm gen/moar/stage1/nqpmo.nqp
dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
  Referenced from:
/Users/afbach/.rakudobrew/moar-nom/install/lib/libmoar.dylib (which was
built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _clock_gettime
  Referenced from:
/Users/afbach/.rakudobrew/moar-nom/install/lib/libmoar.dylib (which was
built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib

make: *** [gen/moar/stage1/nqpmo.moarvm] Trace/BPT trap: 5
Command failed (status 512): make
Command failed (status 512): /usr/local/bin/perl Configure.pl
--prefix=/Users/afbach/.rakudobrew/moar-nom/install --backends=moar
--make-install --git-protocol=https
--git-reference=/Users/afbach/.rakudobrew/bin/../git_reference --gen-moar
Failed running /usr/local/bin/perl Configure.pl --backends=moar --gen-moar
--git-reference="/Users/afbach/.rakudobrew/bin/../git_reference"
--make-install  at /Users/afbach/.rakudobrew/bin/rakudobrew line 58.
main::run("/usr/local/bin/perl Configure.pl --backends=moar --gen-moar
-"...) called at /Users/afbach/.rakudobrew/bin/rakudobrew line 386
main::build_impl("moar", undef, "") called at
/Users/afbach/.rakudobrew/bin/rakudobrew line 116



-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


rakudo bug 128427 perl 5 does not build on Darwin platforms with clock_gettime

2016-11-14 Thread Andy Bach
Hi,

Turns out this bug was filed for p5 (I thought I was looking at the p6 bug
list) but I saw this exactly today, trying to build, via rakudobrew, on my
mac book. Just checking if this is a known thing or not.

-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk