Re: why not raku ?

2021-11-22 Thread Aureliano Guedes
Clifton, I think the best solution is wrap with C and then use Raku's
NativeCall.

Like this example
<https://github.com/hartenfels/21-Advent-2015/blob/master/cpp/cpptest-extern-c.cpp>

#include 

extern "C"
{
std::vector* intvec_new() { return new std::vector(); }
void intvec_free(std::vector* vec) { delete v; }
// etc. pp.
}


#!/usr/bin/env raku
use NativeCall;

sub holler(Str) is native('cpptest-extern-c') { ... }
holler('Hello World');


But I really don't know if it is the best strategy.
Actually, I really hope to see in some near future the NativeCall working
easy and well with C++ libs.



On Mon, Nov 22, 2021 at 2:50 PM Clifton Wood  wrote:

> Aureliano:
>
> How are you attempting to call xframe functions?
>
> On Mon, Nov 22, 2021 at 11:24 AM Aureliano Guedes <
> guedes.aureli...@gmail.com> wrote:
>
>> Hi Clifton Wood,
>> Here it is.
>> https://andrewshitov.com/2020/01/08/calling-cpp-and-fortran-functions-from-raku-using-the-nativecall-interface/
>>
>> It was, by far, the best example I founded.
>> But as simple as it is, I fail to call functions from xframe
>> <https://github.com/xtensor-stack/xframe> to raku.
>>
>> You'll also find examples here
>> <https://perl6advent.wordpress.com/2015/12/21/day-21-nativecall-backs-and-beyond-c/>
>> which are quite old.
>> And practical implementation in this repo on github
>> <https://github.com/hartenfels/21-Advent-2015/tree/master/cpp>.
>>
>>
>>
>>
>> On Mon, Nov 22, 2021 at 11:49 AM Clifton Wood 
>> wrote:
>>
>>> Aureliano, where was this example for C++? I'd love to take a look at it!
>>>
>>> Raku could really use a dose of Qt.
>>>
>>> On Mon, Nov 22, 2021 at 8:52 AM Salve J Nilsen  wrote:
>>>
>>>> Piper H said:
>>>>
>>>> > Has Larry Wall joined the development team of raku?
>>>>
>>>> He's been part of it since the very beginning. He's also on this list,
>>>> chipping in now and then (last time was in June this year).
>>>>
>>>>
>>>> - Salve
>>>>
>>>> --
>>>> #!/usr/bin/env perl
>>>> sub AUTOLOAD{$AUTOLOAD=~/.*::(\d+)/;seek(DATA,$1,0);print# Salve Joshua
>>>> Nilsen
>>>> getc DATA}$"="'};&{'";@_=unpack("C*",unpack("u*",':50,$'.#<
>>>> s...@foo.no>
>>>> '3!=0"59,6!`%%P\0!1)46%!F.Q`%01,`'."\n"));eval "&{'@_'}";  __END__ is
>>>> near! :)
>>>>
>>>
>>
>> --
>> Aureliano Guedes
>> skype: aureliano.guedes
>> contato:  (11) 94292-6110
>> whatsapp +5511942926110
>>
>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: why not raku ?

2021-11-22 Thread Aureliano Guedes
Hi Clifton Wood,
Here it is.
https://andrewshitov.com/2020/01/08/calling-cpp-and-fortran-functions-from-raku-using-the-nativecall-interface/

It was, by far, the best example I founded.
But as simple as it is, I fail to call functions from xframe
<https://github.com/xtensor-stack/xframe> to raku.

You'll also find examples here
<https://perl6advent.wordpress.com/2015/12/21/day-21-nativecall-backs-and-beyond-c/>
which are quite old.
And practical implementation in this repo on github
<https://github.com/hartenfels/21-Advent-2015/tree/master/cpp>.




On Mon, Nov 22, 2021 at 11:49 AM Clifton Wood 
wrote:

> Aureliano, where was this example for C++? I'd love to take a look at it!
>
> Raku could really use a dose of Qt.
>
> On Mon, Nov 22, 2021 at 8:52 AM Salve J Nilsen  wrote:
>
>> Piper H said:
>>
>> > Has Larry Wall joined the development team of raku?
>>
>> He's been part of it since the very beginning. He's also on this list,
>> chipping in now and then (last time was in June this year).
>>
>>
>> - Salve
>>
>> --
>> #!/usr/bin/env perl
>> sub AUTOLOAD{$AUTOLOAD=~/.*::(\d+)/;seek(DATA,$1,0);print# Salve Joshua
>> Nilsen
>> getc DATA}$"="'};&{'";@_=unpack("C*",unpack("u*",':50,$'.#> >
>> '3!=0"59,6!`%%P\0!1)46%!F.Q`%01,`'."\n"));eval "&{'@_'}";  __END__ is
>> near! :)
>>
>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: why not raku ?

2021-11-22 Thread Aureliano Guedes
;>>
>>>> So now, one can add another factor:
>>>>
>>>> * Almost NO folk want to help develop it. And you can't attract
>>>> them either. Unless they get it. Because then they fall in love
>>>> with it. And so it rolls. For now.
>>>>
>>>> So, for now, it needs more work, as it has always done.
>>>>
>>>> > * raku shines on interpreted langages when people are
>>>> > moving to compiled langages
>>>>
>>>> It's a compiled language, so that's not quite right. Perhaps
>>>> you meant it's dynamically typed rather than statically typed,
>>>> but that's not quite right either.
>>>>
>>>> If one squints, it's an open source alternative to Oracle's
>>>> Truffle/Graal/JVM, but it's wy slower.
>>>>
>>>> > * raku is that rich it's hard to get it in a first view
>>>>
>>>> I'd say it's hard to *ever* get most of it. It's as ambitious
>>>> as Truffle/Graal/JVM, perhaps even more so.
>>>>
>>>> But it should and *will* be easy to get it a little at a time.
>>>>
>>>> But we're not there yet.
>>>>
>>>> There's a fairly obvious way to make it vastly easier.
>>>>
>>>> Which is to create mini languages that aren't Raku
>>>> but showcase selected parts of its talents.
>>>>
>>>> But that will have to wait until RakuAST lands.
>>>>
>>>> And perhaps a language version *after* that.
>>>>
>>>> So perhaps 3-4 years if we're lucky.
>>>>
>>>> > * raku is still way too slow to be taken seriously
>>>> > by a large audience
>>>>
>>>> Yes. For now.
>>>>
>>>> > * js or python developpers are legions on the market
>>>> > now so everyone choose this as an argument
>>>>
>>>> Yes. And ts devs too.
>>>>
>>>> > * we need more packages on raku.land
>>>>
>>>> I don't think that's important. We need better Inlines.
>>>>
>>>> We need to deflate the packages/modules/libs argument.
>>>>
>>>> > * i really think technologies are massively adopted when they are
>>>> >   packaged in main linux distros because lot of people don't want to
>>>> >   bother compiling an interpreter or adding extra repos to do it.
>>>>
>>>> I can see there being an opportunity to create a popular
>>>> package before this decade is out in the form of (a fresh
>>>> repackaging of) NQP as a "Raku Rules" engine / latter
>>>> day PCRE / new alternative to Truffle/Graal/JVM.
>>>>
>>>> --
>>>> love, raiph
>>>>
>>>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: why not raku ?

2021-11-19 Thread Aureliano Guedes
I am still defending that we need a package for data
analysis/science/engineer (like the Perl5 PDL, Python Pandas or R
data.table) and an IDE for streaming programming like jupyter or rstudio.

I'm not proficient in Raku, but  I may help to dev it.
We might take advantage of some C++ packages such as xtensor and xframe.

Why? I should answer: "Why not?".
But data technologies are growing fast and require a lot of new options (in
my experience).
Async, parallelism builtin are goodies to use with data processes.



On Fri, Nov 19, 2021 at 10:04 AM Paul Procacci  wrote:

> Raku is pretty amazing.  I too would use it pretty regularly except it
> doesn't run on Freebsd properly.  Many a times I started a project that
> would have been a great contribution yet always ran into problems and had
> to change back to Perl.
>
> It's definitely a good language. It's just not suited for production.
>
> On Fri, Nov 19, 2021, 4:44 AM Marc Chantreux  wrote:
>
>> hello,
>>
>> > I like ruby and perl
>>
>> so do I but raku is by far my prefered interpreted langage now.
>> I don't raku that much and most of the time, i read the doc more than i
>> actually write code but when it's writen, it's always elegant and
>> concise the way i never seen before.
>>
>> > Maybe perl6 is still not production-ready?
>>
>> Perl6 is now raku.
>>
>> it depends: what do you mean by "production" and "ready"? start with
>> some few non-critical usecases and you'll see raku is production ready
>> enough for lot of things.
>>
>> > but why so few open source projects which were developed by perl6?
>>
>> wow ... interesting question. my cents on it:
>>
>> * raku shines on interpreted langages when people are moving to compiled
>> langages
>> * raku is that rich it's hard to get it in a first view
>> * raku is still way too slow to be taken seriously by a large audience
>> * js or python developpers are legions on the market now so everyone
>>   choose this as an argument
>> * we need more packages on raku.land
>> * i really think technologies are massively adopted when they are
>>   packaged in main linux distros because lot of people don't want to
>>   bother compiling an interpreter or adding extra repos to do it.
>>
>> regards,
>> marc
>>
>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: [naive] hash assingment

2021-07-14 Thread Aureliano Guedes
thank

It is now more clear.
And I like this notation |%a ==> map({.sqrt});
less is more sometimes



On Wed, Jul 14, 2021 at 4:41 PM Daniel Sockwell 
wrote:

> To expand slightly on what Clifton said, the reason that
>
> > %a = %a.map: { .sqrt };
> > # (1 1.4142135623730951 1.7320508075688772 2 2.23606797749979)
>
> does what you mean but
>
> > %a{'column1'} ==> map( { .sqrt } )
> > # (2.23606797749979)
>
> does not is that the method .map maps over *each item* in the Array,
> whereas
> ==> map maps over the Array as *one collection*.  When taking the square
> root,
> an Array needs to be treated as an number, which for Raku means treating
> it as
> a count of how many elements it has (i.e., its length).
>
> So `%a{'column1'} ==> map({.sqrt})` is the same as
> `%a{'column1'}.elems.map({.sqrt})`
>
> If want to map over each item in the Array when using the ==> operator,
> you need to
> slip the items out of the Array before feeding them on.  You can do that
> with either
> of the following (equivalent) lines:
>
> > %a{'column1'}.Slip ==> map({.sqrt});
> > |%a{'column1>'}==> map({.sqrt});
>
> (Also, you may already know this, but when the keys of your hash are
> strings, you
> can write %a instead of %a{'column1'}  )
>
> Hope that helps!
>
> –codesections
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: [naive] hash assingment

2021-07-14 Thread Aureliano Guedes
Yes, it does help.

So, to create a new pair *k*ey/*v*alue on the fly in a hash given another
pair k/v, or even modify it will be a problem, then maybe will better
use an array instead of a hash.

> my @a = [ 1..5, 'a'..'e' ]
[1..5 "a".."e"]
> @a[2] = [@a[0][] ==> map( { .sqrt} )]
> @a[2]
[1 1.4142135623730951 1.7320508075688772 2 2.23606797749979]

On Wed, Jul 14, 2021 at 3:55 PM Clifton Wood  wrote:

> Unfortunately, given this:
>
> my %a = 'column1' => [1...5], 'column2' => ['a'...'e']
>>
>
> column1 and column2 cannot yet be referenced to create column3.
>
> You need to do that on another line:
>
> %a = %a.map: { .sqrt };
>
> Which gives the following:
>
> > %a.gist.say
> # {column1 => [1 2 3 4 5], column2 => [a b c d e], column3 => (1
> 1.4142135623730951 1.7320508075688772 2 2.23606797749979)}
>
> Does this help?
>
> - X
>
> On Wed, Jul 14, 2021 at 2:32 PM Aureliano Guedes <
> guedes.aureli...@gmail.com> wrote:
>
>> Thanks JJ, Marcel, Matthew
>>
>> That's help me a lot to understand how Raku hashes work;
>> Little bit complex compared to Perl5.
>>
>> But now I got another question
>>
>> given
>> my %a = 'column1' => [1...5], 'column2' => ['a'...'e']
>>
>> I want to calculate sqrt and store in column3
>> > %a{'column1'}.map({ .sqrt })
>> (1 1.4142135623730951 1.7320508075688772 2 2.23606797749979)
>> > %a{'column3'} = %a{'column1'}.map({ .sqrt })
>> > %a{'column3'}
>> (1 1.4142135623730951 1.7320508075688772 2 2.23606797749979)
>> > %a.keys
>> (column1 column3 column2)
>>
>> But...
>> > %a{'column1'} ==> map( { .sqrt } )
>> (2.23606797749979)
>>
>> How I access the array's values within the hash?
>>
>>
>> On Wed, Jul 14, 2021 at 2:55 PM Marcel Timmerman 
>> wrote:
>>
>>> On 7/14/21 7:43 PM, Aureliano Guedes wrote:
>>>
>>> Hi all,
>>>
>>> Trying to knowing a little bit more about Raku lang, I decided to write
>>> a simple (as possible) lib to became similar to R/dplyr or Python/Pandas
>>> method to data wrangle.
>>>
>>> So, Raku gives us the possibility to deal with data in a functional way,
>>> given the native pipe operator, which is wonderful for newbies.
>>> > @a = 1..100
>>> > @a ==> map( { .sqrt } )
>>> > @a ==> HYPER( { .sqrt } ) # faster map
>>> Even it is being *too verbose*, is good enough for the first moment to
>>> a data scientist.
>>>
>>> So I'm trying to decide the best way to abstract columns.
>>> First, I decide to use a hash where the key is the column name and the
>>> value is the oriented list ou array.
>>>
>>> > my %a = {'column1' => [1...5], 'column2' => ['a'...'e']}
>>> Potential difficulties:
>>> Useless use of hash composer on right side of hash assignment; did
>>> you mean := instead?
>>> at line 2
>>> --> ⏏
>>> {column1 => [1 2 3 4 5], column2 => [a b c d e]}
>>>
>>> It is a warning, not an error!
>>>
>>> But let's obey the warning.
>>> > my %a = {'column1' := [1...5], 'column2' := ['a'...'e']}
>>> ===SORRY!=== Error while compiling:
>>> Cannot use bind operator with this left-hand side
>>> --> n1' := [1...5], 'column2' := ['a'...'e']⏏}
>>>
>>>
>>> ':=' in the error is meant to replace the assignment so you are binding
>>> directly to the hash.
>>> So write,
>>>
>>> my %a := {'column1' => [1...5], 'column2' => ['a'...'e']}
>>>
>>> Without the binding you could write instead
>>>
>>> my %a = 'column1' => [1...5], 'column2' => ['a'...'e']
>>>
>>> See also https://docs.raku.org/type/Hash and
>>> https://docs.raku.org/routine/:=
>>>
>>>
>>> Now we got an error.
>>>
>>> Someone may explain me why I got this error??
>>>
>>> Thanks in advance
>>>
>>>
>>>
>>>
>>> --
>>> Aureliano Guedes
>>> skype: aureliano.guedes
>>> contato:  (11) 94292-6110
>>> whatsapp +5511942926110
>>>
>>>
>>>
>>
>> --
>> Aureliano Guedes
>> skype: aureliano.guedes
>> contato:  (11) 94292-6110
>> whatsapp +5511942926110
>>
>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: [naive] hash assingment

2021-07-14 Thread Aureliano Guedes
Thanks JJ, Marcel, Matthew

That's help me a lot to understand how Raku hashes work;
Little bit complex compared to Perl5.

But now I got another question

given
my %a = 'column1' => [1...5], 'column2' => ['a'...'e']

I want to calculate sqrt and store in column3
> %a{'column1'}.map({ .sqrt })
(1 1.4142135623730951 1.7320508075688772 2 2.23606797749979)
> %a{'column3'} = %a{'column1'}.map({ .sqrt })
> %a{'column3'}
(1 1.4142135623730951 1.7320508075688772 2 2.23606797749979)
> %a.keys
(column1 column3 column2)

But...
> %a{'column1'} ==> map( { .sqrt } )
(2.23606797749979)

How I access the array's values within the hash?


On Wed, Jul 14, 2021 at 2:55 PM Marcel Timmerman  wrote:

> On 7/14/21 7:43 PM, Aureliano Guedes wrote:
>
> Hi all,
>
> Trying to knowing a little bit more about Raku lang, I decided to write a
> simple (as possible) lib to became similar to R/dplyr or Python/Pandas
> method to data wrangle.
>
> So, Raku gives us the possibility to deal with data in a functional way,
> given the native pipe operator, which is wonderful for newbies.
> > @a = 1..100
> > @a ==> map( { .sqrt } )
> > @a ==> HYPER( { .sqrt } ) # faster map
> Even it is being *too verbose*, is good enough for the first moment to a
> data scientist.
>
> So I'm trying to decide the best way to abstract columns.
> First, I decide to use a hash where the key is the column name and the
> value is the oriented list ou array.
>
> > my %a = {'column1' => [1...5], 'column2' => ['a'...'e']}
> Potential difficulties:
> Useless use of hash composer on right side of hash assignment; did you
> mean := instead?
> at line 2
> --> ⏏
> {column1 => [1 2 3 4 5], column2 => [a b c d e]}
>
> It is a warning, not an error!
>
> But let's obey the warning.
> > my %a = {'column1' := [1...5], 'column2' := ['a'...'e']}
> ===SORRY!=== Error while compiling:
> Cannot use bind operator with this left-hand side
> --> n1' := [1...5], 'column2' := ['a'...'e']⏏}
>
>
> ':=' in the error is meant to replace the assignment so you are binding
> directly to the hash.
> So write,
>
> my %a := {'column1' => [1...5], 'column2' => ['a'...'e']}
>
> Without the binding you could write instead
>
> my %a = 'column1' => [1...5], 'column2' => ['a'...'e']
>
> See also https://docs.raku.org/type/Hash and
> https://docs.raku.org/routine/:=
>
>
> Now we got an error.
>
> Someone may explain me why I got this error??
>
> Thanks in advance
>
>
>
>
> --
> Aureliano Guedes
> skype: aureliano.guedes
> contato:  (11) 94292-6110
> whatsapp +5511942926110
>
>
>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


[naive] hash assingment

2021-07-14 Thread Aureliano Guedes
Hi all,

Trying to knowing a little bit more about Raku lang, I decided to write a
simple (as possible) lib to became similar to R/dplyr or Python/Pandas
method to data wrangle.

So, Raku gives us the possibility to deal with data in a functional way,
given the native pipe operator, which is wonderful for newbies.
> @a = 1..100
> @a ==> map( { .sqrt } )
> @a ==> HYPER( { .sqrt } ) # faster map
Even it is being *too verbose*, is good enough for the first moment to a
data scientist.

So I'm trying to decide the best way to abstract columns.
First, I decide to use a hash where the key is the column name and the
value is the oriented list ou array.

> my %a = {'column1' => [1...5], 'column2' => ['a'...'e']}
Potential difficulties:
Useless use of hash composer on right side of hash assignment; did you
mean := instead?
at line 2
--> ⏏
{column1 => [1 2 3 4 5], column2 => [a b c d e]}

It is a warning, not an error!

But let's obey the warning.
> my %a = {'column1' := [1...5], 'column2' := ['a'...'e']}
===SORRY!=== Error while compiling:
Cannot use bind operator with this left-hand side
--> n1' := [1...5], 'column2' := ['a'...'e']⏏}

Now we got an error.

Someone may explain me why I got this error??

Thanks in advance




-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: classes and objects questions

2020-12-14 Thread Aureliano Guedes
Hi Todd,

I'm a computational biologist and my knowledge is limited to what I need to
do data science and data analysis in my field.

So far, after a few years, I developed a very shy ability in programming
languages. Luckily, having Perl 5 as my first love.
Perhaps, at the time I was able to use Moose to support OO. Then I had to
do a job with Python and I didn't know the language itself at the time.
Perhaps, nowadays I have skills enough to Perl/Python/R also C/C++, but I
still missing skills in Raku, perhaps by the time or perhaps because I have
some language addiction.

But, as far I follow this group, trying to learn something, I saw you doing
some questions. And somehow I notice you have more knowledge than me in
this long waited new-born (after 15y) language.

That's why, as a community-developed language (including docs) I'd like to
suggest to you help to improve the docs.
This way, when I have - with some lucky - free time, I may learn with you
and all others that wrote these docs.

Regards,
acpguedes

PS: Perhaps, sorry for my really bad English

On Mon, Dec 14, 2020 at 7:34 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Hi All,
>
> https://docs.raku.org/language/classtut
>
>   "A tutorial about creating and using classes
>   in Raku"
>
> So far so good.
>
>   "Raku has a rich built-in syntax for defining
>   and using classes."
>
> U. Forgot something did we?  What is a "class"?
>
>
> Next up:
>
>   "A default constructor allows the setting of
>   attributes for the created object:"
>
> U.  Forgot something else, did we?  What is
> an "object"?
>
>
> The "tutorial" leaves "class" and "object" up to
> the reader to guess at from what looks like an
> interesting example.
>
>
> But, again forgetting things, The tutorial also
> leaves the syntax up for guess work as well.  Not
> described are "$.", "$!", ":$", ^$" what are they
> and what are the rules for using them.
>
> Next up:
>
>   my $r = Rectangle.new(
>lower => Point.new(x => 0, y => 0),
>upper => Point.new(x => 10, y => 10));
>
>
> Why are we using ".new"?
>
> Why are we using the syntax for a hash (=>)?
>
> And:
>   $!upper.x
>
> What is the rules and purpose for such?  Why
> the "!" and why the "."?
>
>
> I do realize the documentation is not meant for
> beginners, but rather a refresher for advanced
> users that do not need it, but this link definitely
> said "tutorial" -- fifth word in.
>
> Would some kind soul please fill in the missing
> parts of the "tutorial" for me?
>
> Many thanks,
> -T
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: The ,= operator

2020-12-07 Thread Aureliano Guedes
I didn't understood

> my @fib = 1,1, * + * … *;
[...]
> @fib[1]
1
> @fib[5]
8
> @fib[1..5]
(1 2 3 5 8)


*> @fib[1, 5, 10..15, 20](1 8 (89 144 233 377 610 987) 10946)*
* ^*

Why???



On Mon, Dec 7, 2020 at 2:27 AM William Michels via perl6-users <
perl6-users@perl.org> wrote:

>
>
> On Sun, Nov 29, 2020 at 6:38 PM Ralph Mellor 
> wrote:
>
>> > Zen slicing as a possible way of 'de-containerizing' :
>> > https://docs.raku.org/language/subscripts#index-entry-Zen_slices
>>
>> A zen-slice only affects the single reference it's applied to.
>>
>> And it is a no op when applied to anything other than a `Scalar`.
>>
>> So it'll have no effect when applied directly to an array, list, hash,
>> or other non `Scalar`.
>>
>> Perhaps you're thinking "decontainerizing" does something other
>> than what it does? It's really a very simple operation. An analogy
>> is having a bunch of folk, some of whom always go by their legal
>> name, but others who sometimes go by their nickname. And let's
>> say there's an operation called "use legal name". When applied
>> to a nickname it yields the corresponding legal name. But when
>> applied to a legal name it just yields that name, i.e. it's a no op.
>>
>> That's all that decont does, except the analog to a nickname is
>> a `Scalar`, and the analog to a legal name is anything else.
>>
>> > Even if the ",=" postfix operator were to gain this ability on non-hash
>> > objects, then hash-objects would be special-cased in **not** requiring
>> > a Zen-sliced decontainerized object on the LHS, so people would have
>> > to consider that outcome.
>>
>> I think the focus on `,=`.is really unfortunate, because the real issue is
>> just about what `=` does with a non-`Scalar` on its LHS and a list of
>> values on its RHS. It's really got nothing whatsoever to do with `,`.
>>
>> It just depends on the type of non-`Scalar` on the LHS of `=`.
>>
>> Look what happens without not a comma in sight:
>>
>> my %hash = do for ^1 { %hash }
>> say %hash; # {}
>>
>> If it's a hash,, the only sensible thing to do with a list of values that
>> may
>> each be a pair, or a list of pairs, or an array of pairs, or a hash of
>> pairs,
>> is to flatten and concatenate all the individual pairs into the hash.
>>
>> my @array = do for ^1 { @array }
>> say @array; # (\Array_73652568 = [Array_73652568])
>>
>> But if it's an array, the sensible thing to do is to *not* flatten by
>> default.
>>
>
>
> This topic was a subject of discussion during our (SF_Perl) Raku Meetup
> Group today. We reviewed the three URL references below. One member of our
> Meetup went throught the 2017 Advent Calendar reference extensively
> (hopefully we'll see a post on that). Afterwards, I played a bit with
> indexing constructs. Posting these for posterity's sake:
>
> https://docs.raku.org/language/subscripts#index-entry-Zen_slices
> https://docs.raku.org/language/glossary#index-entry-decont
> https://perl6advent.wordpress.com/2017/12/02/#theoneandonly
>
> user@mbook:~$ raku
> Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2020.10.
> Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d.
> Built on MoarVM version 2020.10.
>
> You may want to `zef install Readline` or `zef install Linenoise` or use
> rlwrap for a line editor
>
> To exit type 'exit' or '^D'
> > my %hash = do for ^1 { %hash }
> {}
> > my %hash2 = do for ^1 { %hash2<> }
> {}
> > my %hash3 = do for ^1 { %hash3<*> }
> Odd number of elements found where hash initializer expected:
> Only saw 1 element
>   in block  at  line 1
>
> > my @array = do for ^1 { @array }
> (\Array_140587615723064 = [Array_140587615723064])
> > my @array2 = do for ^1 { @array2[] }
> (\Array_140587615723904 = [Array_140587615723904])
> > my @array3 = do for ^1 { @array3[*] }
> [()]
>
> Best Regards, Bill.
>
>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Language Design: 'special casing' of split()? (i.e. .split performs concomitant .join? )

2020-10-14 Thread Aureliano Guedes
Oh, thanks, now it makes sense.

On Wed, Oct 14, 2020 at 12:01 PM Brian Duggan  wrote:

> On Wednesday, October 14, Aureliano Guedes wrote:
> > In this point, the unique weirdness I'd like to understand is why in Raku
> > `@nums.log == 2.302585092994046e0`. I don't understand where this value
> > comes from.
>
> This comes from the length of the array; the array is coerced into a
> numeric
> value:
>
>   > my @nums = 1..10
>   [1 2 3 4 5 6 7 8 9 10]
>   > @nums.log
>   2.302585092994046
>   > @nums.Numeric.log
>   2.302585092994046
>   > 10.log
>   2.302585092994046
>
> Brian
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Language Design: 'special casing' of split()? (i.e. .split performs concomitant .join? )

2020-10-14 Thread Aureliano Guedes
I'd like to help with my 2 cents.

Given your comparison with R, sum, and mean are expected to play with a
vector rather than log and sin are expected to play with single numbers.
Then, the expected behavior for numerics types in Raku still the same as in
R. The difference is only that the functions in Raku are designed to one
and only one single function.

#RAKU
> my @nums = 0,1,2,3,4,5,6,7,8,9;
[0 1 2 3 4 5 6 7 8 9]
> @nums.sum
45
> sum(@nums)
45

#R
> library(tidyverse) #import pipe %>%
> nums <- 0:9
> nums
 [1] 0 1 2 3 4 5 6 7 8 9
> sum(nums)
[1] 45
> nums %>% sum()
[1] 45
> nums %>% log
 [1]  -Inf 0.000 0.6931472 1.0986123 1.3862944 1.6094379 1.7917595
 [8] 1.9459101 2.0794415 2.1972246
> log(nums)
 [1]  -Inf 0.000 0.6931472 1.0986123 1.3862944 1.6094379 1.7917595
 [8] 1.9459101 2.0794415 2.1972246


In this point, the unique weirdness I'd like to understand is why in Raku
`@nums.log == 2.302585092994046e0`. I don't understand where this value
comes from.

In the case of strings, pay attention to the size of the array. The infix
`>>` act as expected keeping the vector with the same size, which is the
default behavior of R, since it is functional and vectorization is arguably
its philosophy which handles very well data analysis which is its purpose.

> @monsters>>.split(" ").elems
5
> @monsters.split(" ").elems
7
> my @monsters = << blob 'king kong' mothera fingfangfoom 'foo bar'>>;
[blob king kong mothera fingfangfoom foo bar]
> @monsters.elems
5
> @monsters.split(" ")
(blob king kong mothera fingfangfoom foo bar)
> @monsters.split(" ").elems
7
> @monsters>>.split(" ")
[(blob) (king kong) (mothera) (fingfangfoom) (foo bar)]
> @monsters>>.split(" ").elems
5

The point is, I don't know why Raku is designed the way it is. But is
easier to implement in Raku the use of functional and vectorized paradigms
than in Python which requires an external lib (e.g. Pandas or numpy).

Of course, it might be better if Raku has docs explain the paradigms and
philosophy behind the scenes and very didactic and well-explained docs as
Perl5. Also, coping R, might be too inviting to learners and seniors if we
had online handbooks, wiki-style docs, and cheat sheets as we have in R.

best

On Wed, Oct 14, 2020 at 3:28 AM William Michels via perl6-users <
perl6-users@perl.org> wrote:

> On Mon, Oct 12, 2020 at 10:02 AM Larry Wall  wrote:
> >
> > On Mon, Oct 12, 2020 at 01:14:09PM -0300, Aureliano Guedes wrote:
> > : > This seems pretty convenient and intuitive.  At least, it is possible
> > : > to mimic that behavior in Raku:
> > : >
> > : > List.^find_method('split').wrap: { $^a.map: *.split($^b) }
> > : > List.^find_method('sin').wrap: *.map: *.sin;
> > : >
> > : This is like overwrite the function?
> > : Might be better just implement a new function, I mean, a new verb as is
> > : called in R.
> >
> > In Raku these functions already have names, if you count metaoperators
> as a fancy
> > way to name anonymous functions:
> >
> > say ».split(',');
> > say (0, (π/2, 3 * π/2))».sin;
> >
> > ((a b) (c d))
> > (0 (1 -1))
> >
> > As shown by the ».sin example, unary hypers will distribute over
> > multi-dimensional structures for you, just as an APL or R programmer
> > would expect.  But that behavior is not intuitively obvious to everyone,
> > so the vector-processing paradigm is not the default.  (But we make it
> > really easy to get to when you want it, as you can see.  And arguably
> > the explicit presence of » or >> makes your intent clearer to the naïve
> > reader, who at least has something to look up or ask about if they don't
> > understand it.)
> >
> > Larry
>
> Hi Larry!
>
> First of all, let me thank you for designing the Raku (née Perl6)
> programming language in the first place. I've really enjoyed learning
> a different set of programming paradigms than I was previously
> accustomed to.
>
> With regards to the present topic, what initially 'disunited' me was
> calling split() on an a array and ending up with joined elements. It
> becomes most apparent when one tries to split() on a character that
> isn't present in the array in the first place--in that case, all array
> elements are joined into a single string. It has been explained to me
> that arrays coercible to strings and called with a string-function
> *are* auto-joined with a single space as separator, but it would be
> nice to control this behavior somewhat, e.g. for generating a CSV lin

Re: Language Design: 'special casing' of split()? (i.e. .split performs concomitant .join? )

2020-10-12 Thread Aureliano Guedes
On Mon, Oct 12, 2020 at 10:03 AM Brian Duggan  wrote:

> On Saturday, October 10, William Michels via perl6-users wrote:
> > I can point to the (functional) R-programming language to show what
> happens
> > there. When manipulating "array-like" (i.e. vector) objects in R, you can
> > do nested function calls, or sequential (piped) function calls, and still
> > get the same data structure out at the end. So a 10-element input gives a
> > 10-element output.
>
> This seems pretty convenient and intuitive.  At least, it is possible
> to mimic that behavior in Raku:
>
> List.^find_method('split').wrap: { $^a.map: *.split($^b) }
> List.^find_method('sin').wrap: *.map: *.sin;
>
This is like overwrite the function?
Might be better just implement a new function, I mean, a new verb as is
called in R.


> my @words = ;
> my @nums = 0, π/2, 3 * π/2;
>
> say @words.split(',');
> say @nums.sin;
>
> gives us
>
>   ((a b) (c d))
>   (0 1 -1)
>
> Brian
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: print particular lines question

2020-08-31 Thread Aureliano Guedes
Depends where in your code the $++ is.
It may play as global or as local.

raku -e 'for 1..3 {say $++}; say $++'

On Mon, Aug 31, 2020 at 9:03 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

>
> >  adn
>
> fixed
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: print particular lines question

2020-08-31 Thread Aureliano Guedes
Basically :

$ raku -e 'my $a = 1; say ++$a; say $a'
2
2
$ raku -e 'my $a = 1; say $a++; say $a'
1
2

On Mon, Aug 31, 2020 at 8:36 PM yary  wrote:

> $ by itself is an anonymous variable, putting ++ after starts it at 0 (hmm
> or nil?) and increments up.
>
> By putting the plus plus first, ++$, it will start at 1, thanks to
> pre-increment versus post increment
>
> On Mon, Aug 31, 2020, 4:20 PM ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
>
>> On 2020-08-31 05:53, Brian Duggan wrote:
>> > 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
>> >
>>
>> Hi Bill,
>>
>> Works beatifically! And no bash pipe!
>>
>> $ raku -ne '.say if $++ == 3|2|5' Lines.txt
>> Line 2
>> Line 3
>> Line 5
>>
>> What is `$++`?
>>
>> -T
>>
>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: 2020.07.02 just hit

2020-07-24 Thread Aureliano Guedes
which bug?



On Fri, Jul 24, 2020 at 3:23 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> GetRaku  new update downloaded  2020.07 --> 2020.07.02
>
> Uh Oh.  They must have found a bug.  Wonderful that
> they are on top of things!
>
> :-)
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Raku version of "The top 10 tricks of Perl one-liners" ?!?

2020-07-22 Thread Aureliano Guedes
v command to place the regex in a variable called re,
> >which we can then refer to from the perl script through the %ENV
> >hash. This way is slightly longer, but I find the savings in
> counting
> >backslashes or quotes to be worth it, especially if you need to
> end
> >up embedding strings with more than a single metacharacter.
>
> This is rather Unix-centric on the face of it, since on Windows you'd
> have to use outer "" quoting instead.  But you can certainly use the
> same trick with Raku, provided you spell ENV right:
>
>  env re="'" raku -ne '(say .[0] if .[4] ~~ /<{ %*ENV }>/) given
> .split(":")' /etc/passwd
>
> It probably won't be very efficient though, and doesn't do a thing for
> readability.
> Much easier to use a character name:
>
>  raku -ne '(say .[0] if .[4] ~~ /\c[APOSTROPHE]/) given .split(":")'
> /etc/passwd
>
> You could backport that trick to Perl using \N{} too, I guess.
>
> >Trick #9: BEGIN and END
> >
> >BEGIN { ... } and END { ... } let you put code that gets run
> entirely
> >before or after the loop over the lines.
> >
> >For example, I could sum the values in the second column of a CSV
> >file using:
> >
> >perl -F, -lane '$t += $F[1]; END { print $t }'
>
> Same trick, except you can omit the brackets:
>
>  raku -ne 'my $t += [1] given .split(","); END say $t'
>
> Note the 'my' is required because strict is the default.
>
> >Trick #10: -MRegexp::Common
> >
> >Using -M on the command line tells perl to load the given module
> >before running your code. There are thousands of modules available
> >on CPAN, numerous of them potentially useful in one-liners, but
> >one of my favorite for one-liner use is Regexp::Common, which, as
> >its name suggests, contains regular expressions to match numerous
> >commonly-used pieces of data.
> >
> >The full set of regexes available in Regexp::Common is available
> in
> >its documentation, but here's an example of where I might use it:
> >
> >Neither the ifconfig nor the ip tool that is supposed to replace
> it
> >provide, as far as I know, an easy way of extracting information
> for
> >use by scripts. The ifdata program provides such an interface, but
> >isn't installed everywhere. Using perl and Regexp::Common,
> however,
> >we can do a pretty decent job of extracing an IP from ips output:
> >
> >ip address list eth0 | \
> >  perl -MRegexp::Common -lne 'print $1 if /($RE{net}{IPv4})/'
>
> I don't know if there's anything quite comparable.  And who's to say
> what's "common" anymore...   Certainly we have -M.  But Raku's regex
> and grammars are so much more powerful that these things are likely to
> kept in more specific Grammar modules anyway, or just hand-rolled for
> the purpose on the spot.
>
> >~nelhage Join the discussion Comments ( 7 )
>
> Larry
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Baby steps to create a dataframe structure

2020-07-22 Thread Aureliano Guedes
I liked all answers, make me more motivated to begin

On Wed, Jul 22, 2020 at 9:24 AM Fernando Santagata <
nando.santag...@gmail.com> wrote:

> Since you listed R among the other languages, I guess that you're
> interested in statistical functions too. If not, discard the rest of this
> email :-)
>

Not only, but also.

Actually, recently I prepared a Jupiter Notebook with Raku kernel just to
play with. Then, in another thread, I saw the implementation of the inner
and outer join operation, then I 'm trying to do the left and right join
too.
I also thought to implement other relational operations (functions) to add
columns, transform columns, summarize, filter, arrange, all common in data
wrangle, and data manipulation, I know all these operations s easy doable
in Raku but the Idea is to make it easy as possible as dictated by Hardley
Wickham <https://r4ds.had.co.nz/index.html> and implemented in dplyr
<https://github.com/tidyverse/dplyr>.

The idea is to prepare a comfortable environment to do data analysis,
resume some data in a good plot <https://github.com/tidyverse/ggplot2>, and
etc.

Since Raku deal really nice with rationals and natively deal with async and
concurrency, this language might be wonderous to data analysis and data
science.


> I'm working now on the statistical functions of the GSL: mean, variance,
> standard deviation, etc. Those functions are not based on the GSL
> vector/matrix interface, so that module will not depend on any other Raku
> module.
> The functions provided by the library accept arrays in every native data
> type[¹] available in Raku (int8, uint8, int16, … num32, num64).
> If you're planning to use the fastest approach available, I can split the
> module and publish the raw interface separately from the higher level one,
> so you'll be able to use NativeCall internally and have the minimal set of
> external code.
>
> [¹] libgsl has different functions for each data type.
>
> On Wed, Jul 22, 2020 at 1:42 AM Aureliano Guedes <
> guedes.aureli...@gmail.com> wrote:
>
>> Hi all,
>>
>> I'd like to learn Raku deep enough to build a data structure. I have
>> experience with Perl5, Python, R, and even C/C++, then I get boring
>> feelings to learn something new from the beginning. Also, I prefer learning
>> a new language by applying f to something.
>>
>> Since I work with data analysis and data science, I'd like to try to
>> develop a data structure to dataframe in pure Raku. And if I do a basic but
>> useful thing capable to load a field delimited file (as CSV or TSV) into a
>> dataframe, I'll transform in a package and upload it to GitHub to
>> comparatively enhance the package.
>> What I need is suggestions for how do I start it.
>> - How I define a data structure: an array of arrays?
>> - Given the raku itself (and maybe some already existing packages) what
>> the structures and functions I may use.
>>
>> I got these ideas to start:
>>
>> The dataframe should support columns name to be called as:
>>
>> df.column1
>>
>> and it should return a list of values on this column.
>> Also, when it read the delim file it should check each column type.
>>
>>
>> All suggestions are welcome.
>>
>>
>>
>> --
>> Aureliano Guedes
>> skype: aureliano.guedes
>> contato:  (11) 94292-6110
>> whatsapp +5511942926110
>>
>
>
> --
> Fernando Santagata
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: 2020.07 just hit

2020-07-22 Thread Aureliano Guedes
Nice, Daniel,

But, I admit, sometimes I don't like too much some symbols not too
intuitive to do on the keyboard like  ≡ and ≢

Here, I see a lot of codes with weirdo symbols and I need to search how to
do. Anyway, the operator itself seems nice.

On Wed, Jul 22, 2020 at 12:42 AM  wrote:

> > $ raku --version
> > This is Rakudo version 2020.07 built on MoarVM version 2020.07
> > implementing Raku 6.d.
> > Whats is new??
>
> Release notes are at
> https://github.com/rakudo/rakudo/blob/master/docs/announce/2020.07.md
>
> I'm most excited for new the Unicode operators, ≡ and ≢ (though the
> permutations speedup
> is pretty cool too).
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Baby steps to create a dataframe structure

2020-07-21 Thread Aureliano Guedes
Then, a native call to R may be better cus bring us dataframe an a lot of
statistical functions natively without other R's package.

But the idea is to implement cooperatively those tools.

On Tue, Jul 21, 2020 at 10:33 PM Tom Browder  wrote:

> On Tue, Jul 21, 2020 at 20:00 Warren Pang  wrote:
>
>> I have the same feeling. Perl5 has PDL which we have been using for data
>> analysis. While Raku seems to lack this.
>>
>
> I haven't looked into how it might work, but Raku does have the NativeCall
> interface as well as Inline::Perl5 which may help.
>
> I have had a lot of success with using CPAN's Perl modules with Raku
> programs.
>
> Best regards,
>
> -Tom
>
>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Baby steps to create a dataframe structure

2020-07-21 Thread Aureliano Guedes
Hi all,

I'd like to learn Raku deep enough to build a data structure. I have
experience with Perl5, Python, R, and even C/C++, then I get boring
feelings to learn something new from the beginning. Also, I prefer learning
a new language by applying f to something.

Since I work with data analysis and data science, I'd like to try to
develop a data structure to dataframe in pure Raku. And if I do a basic but
useful thing capable to load a field delimited file (as CSV or TSV) into a
dataframe, I'll transform in a package and upload it to GitHub to
comparatively enhance the package.
What I need is suggestions for how do I start it.
- How I define a data structure: an array of arrays?
- Given the raku itself (and maybe some already existing packages) what the
structures and functions I may use.

I got these ideas to start:

The dataframe should support columns name to be called as:

df.column1

and it should return a list of values on this column.
Also, when it read the delim file it should check each column type.


All suggestions are welcome.



-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: 2020.07 just hit

2020-07-21 Thread Aureliano Guedes
$ raku --version
This is Rakudo version 2020.07 built on MoarVM version 2020.07
implementing Raku 6.d.

Whats is new??


On Tue, Jul 21, 2020 at 6:21 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> GetRaku   new update downloaded  2020.06 --> 2020.07
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: I cannot install any lib with Zef

2020-07-20 Thread Aureliano Guedes
ocate native library
> '/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so':
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
> cannot open shared object file: No such file or directory
> [Digest::SHA256::Native]   in method setup at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 290
> [Digest::SHA256::Native]   in method CALL-ME at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 577
> [Digest::SHA256::Native]   in sub sha256-hex at
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
> (Digest::SHA256::Native) line 19
> [Digest::SHA256::Native]   in sub sha256-hex at
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
> (Digest::SHA256::Native) line 9
> [Digest::SHA256::Native]   in block  at t/04-big.t line 4
> [Digest::SHA256::Native] Cannot locate native library
> '/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so':
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
> cannot open shared object file: No such file or directory
> [Digest::SHA256::Native]   in method setup at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 290
> [Digest::SHA256::Native]   in method CALL-ME at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 577
> [Digest::SHA256::Native]   in sub sha256-hex at
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
> (Digest::SHA256::Native) line 19
> [Digest::SHA256::Native]   in sub sha256-hex at
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
> (Digest::SHA256::Native) line 9
> [Digest::SHA256::Native]   in block  at t/05-many.t line 7
> [Digest::SHA256::Native] An operation first awaited:
> [Digest::SHA256::Native]   in block  at t/06-threads.t line 13
> [Digest::SHA256::Native] Died with the exception:
> [Digest::SHA256::Native] Cannot locate native library
> '/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so':
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
> cannot open shared object file: No such file or directory
> [Digest::SHA256::Native]   in method setup at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 290
> [Digest::SHA256::Native]   in method CALL-ME at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 577
> [Digest::SHA256::Native]   in sub sha256-hex at
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
> (Digest::SHA256::Native) line 19
> [Digest::SHA256::Native]   in sub sha256-hex at
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
> (Digest::SHA256::Native) line 9
> [Digest::SHA256::Native]   in block  at t/06-threads.t line 10
> ===> Testing [FAIL]: Digest::SHA256::Native:ver<0.03>
> [Digest::SHA256::Native] Failed to get passing tests, but continuing with
> --force-test
> ===> Installing: Digest::SHA256::Native:ver<0.03>
> ===> Install [FAIL] for Digest::SHA256::Native:ver<0.03>: Failed to open
> file
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
> No such file or directory
> Failed to open file
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
> No such file or directory
>


On Mon, Jul 20, 2020 at 1:10 PM JJ Merelo  wrote:

>
>
> El lun., 20 jul. 2020 a las 18:03, Aureliano Guedes (<
> guedes.aureli...@gmail.com>) escribió:
>
>> Hi all,
>>
>> I'm trying to figure out why I cannot install any package with zef.
>>
>> $ raku --version
>> This is Rakudo version 2020.06 built on MoarVM version 2020.06
>> implementing Raku 6.d.
>>
>> zef install Acme::Insult::Lala
>> ===SORRY!===
>> No candidate found for 'zef' that match your criteria.
>> Did you perhaps mean one of these?
>>   Distribution | Author(ity) | Version
>&

Re: doing an inner join via cross-product

2020-07-20 Thread Aureliano Guedes
With a dataframe data structure and some adjusts and some functions
modifications it could be doing like:

data1 .# perhaps the space after . is intentional to bring the idea of
pipes replace f(x) with x . f() <https://github.com/tidyverse/magrittr>
 left_join(data2, by={ x = columname_on_data1, y = columname_on_data2}

by calling the column on the join will be performed as a variable.

I found a module that implements the dataframe data structure in Perl5 but
I didn't find it to Raku.
But, I'm thinking in learn Raku better by implementing a DataFrame data
structure (as R and Pandas-Python) and some relational function or grammar
(as R tidyverse/dplyr <https://github.com/tidyverse/dplyr>) to manipulate
data.

What are the variations of this grep to left, right, and outer joins?

On Sun, Jul 19, 2020 at 5:42 PM Darren Duncan 
wrote:

> This reminds me of my 2009 Set::Relation Perl module, which works to help
> you do
> SQL features like this in your application, but will soon be superseded by
> another module that also has a Raku version. -- Darren Duncan
>
> On 2020-07-19 1:02 p.m., Joseph Brenner wrote:
> > I was thinking about the cross-product operator the other day,
> > and I was wondering if there might be a convenient way of
> > filtering the resulting cartesian product to do something like a
> > database inner join:
> >
> >  my @level  = ( godzilla => 9 ,gremlin => 3, hanuman => 5 );
> >  my @origin = ( godzilla => 'jp',  tingler => 'us',  hanuman => 'il'
> );
> >
> >  my @results = ( @level X @origin ).grep({ $_[0].keys eq $_[1].keys
> });
> >  say @results;  # ((godzilla => 6 godzilla => jp) (hanuman => 5
> > hanuman => il))
> >
> > That's easy enough, though the resulting data structure isn't very neat.
> > I started looking for ways to rearrange it:
> >
> >  my %joined;
> >  for @results -> $row {
> >  say "row: ", $row;  # e.g. row: (godzilla => 9 godzilla
> => jp)
> >  say $row.map({ .keys });# e.g. ((godzilla) (godzilla))
> >  say $row.map({ .values });  # e.g. ((9) (jp))
> >
> >  my $monster =| $row[0].keys;  # e.g. godzilla
> >  my @attributes =| $row.map({ .values });  # e.g. [9 jp]
> >  %joined{ $monster } = @attributes;
> >  }
> >  say %joined;  # {godzilla => [9 jp], hanuman => [5 il]}
> >
> > I can do it more compactly, but it risks getting unreadable:
> >
> >  my %joined2 =| @results.map({ $_[0].keys => .map({ .values }).flat
> });
> >
> > In any case, the %joined structure feels more perlish, for
> > example it's easier to use it to generate reports:
> >
> >  for %joined.keys -> $key {
> >  printf "%12s: level: %-2d origin: %3s\n", $key, %joined{ $key
> }.flat;
> >  }
> >  # hanuman: level: 5  origin:  il
> >  #godzilla: level: 9  origin:  jp
> >
> > Is there some neater way of doing this that I'm missing?
> >
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


I cannot install any lib with Zef

2020-07-20 Thread Aureliano Guedes
Hi all,

I'm trying to figure out why I cannot install any package with zef.

$ raku --version
This is Rakudo version 2020.06 built on MoarVM version 2020.06
implementing Raku 6.d.

zef install Acme::Insult::Lala
===SORRY!===
No candidate found for 'zef' that match your criteria.
Did you perhaps mean one of these?
  Distribution | Author(ity) | Version
   | |
   | |
   | |
   | |

I tried to install another package from https://modules.raku.org/ and I get
nothing.


I'm using Ubuntu 18.04.


Any suggestions?

Thanks in advance
-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: perl streaming framework

2020-07-14 Thread Aureliano Guedes
I'm really sad about the conceptions of programming with non-functional
languages. Truly better an R as a reference than a OO in data analysis.

On Wed, Jul 15, 2020 at 12:13 AM William Michels 
wrote:

> Hi Warren,
>
> The topic you raise is an interesting one. When I've previously
> searched for 'streaming' and 'Python' I often see articles on
> Iterables such as the following:
>
> [1] "Data streaming in Python: generators, iterators, iterables"
>
> https://rare-technologies.com/data-streaming-in-python-generators-iterators-iterables/
>
> [2] "Python Basics: Iteration, Iterables, Iterators, and Looping"
>
> https://towardsdatascience.com/python-basics-iteration-and-looping-6ca63b30835c
>
> From the first URL, there is an introductory quote regarding Lazy
> Evaluation. Well, Raku does Lazy Evaluation, so no problem there:
>
> "There are tools and concepts in computing that are very powerful but
> potentially confusing even to advanced users. One such concept is data
> streaming (aka lazy evaluation), which can be realized neatly and
> natively in Python."
>
> From the second URL, you will find a discussion on Iterators:
> "An iterator is an object representing a stream of data. You can
> create an iterator object by applying the iter() built-in function to
> an iterable."
>
> So maybe we should be looking for articles on Iterators in Raku? Well
> as luck would have it, there are two recent blog posts on the subject:
>
> https://datakinds.github.io/2020/06/24/python-s-itertools-in-pure-raku
> https://datakinds.github.io/2020/06/25/explaining-raku-using-itertools
>
> And if you want to search further, you can also take a look at this
> series of four Raku (Perl6) blog posts--which has been recently
> updated--but stretches all the way back to 2018:
>
> https://0racle.info/articles/pick_and_choose_part_n
>
> HTH, Bill.
>
> W. Michels, Ph.D.
>
>
>
>
>
>
> On Tue, Jul 14, 2020 at 5:43 PM Warren Pang  wrote:
> >
> > Thank you all very much.
> >
> > I have tried to search "perl discussion" and it brings me to perl6's
> list page.
> > Yes for data analysis we primarily use classic perl5, which is smart
> enough especially the regex matching.
> > There are "spark streaming", "flink streaming", "storm streaming", and a
> lot of others, but they don't support perl language well.
> > So I expect the community, either perl6 or perl5, can make that a
> framework.
> > We can't lose the capability in big data, cloud computing, AI, ML,
> streaming, these are the main features of current internet.
> > Everyone today writes CGI with perl? NO.
> >
> > Thanks.
> >
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: perl streaming framework

2020-07-14 Thread Aureliano Guedes
I already mentioned it here.
Since Raku supports truly well functional programming.

To data analysis might be better something like
https://www.tidyverse.org/ implemented
in R to approximate a natural language.




On Tue, Jul 14, 2020 at 11:03 AM Brad Gilbert  wrote:

> If you really want a streaming framework for Perl, the mailing list for
> Raku users might not be the best place to ask.
> (Raku used to be known as Perl6, and we haven't done anything to change
> the name of this mailing list.)
>
> Raku has a very similar syntax to Perl. (It used to be called Perl6 after
> all.)
> But it is different enough that it would take experience Perl programmers
> a while to get used to.
> (It might actually be easier for Perl novices to get used to it.)
>
> It would probably be a better idea to go to a place that Perl programmers
> frequent.
> PerlMonks might be a good starting place.
>
> On Tue, Jul 14, 2020 at 3:55 AM Warren Pang  wrote:
>
>> Hello
>>
>> We are already using perl PDL and something similar.
>> The streaming framework is mainly used for real time data analysis.
>> Tyler from Apache Beam project has wrote a great book about streaming
>> system:
>> http://streamingsystems.net/
>> So I have interest to know if there is the perl implementation for that.
>>
>> Thank you.
>>
>>
>>
>> On Tue, Jul 14, 2020 at 3:39 PM Shlomi Fish 
>> wrote:
>>
>>> Hi Warren!
>>>
>>> Please reply to list.
>>>
>>> On Tue, 14 Jul 2020 10:34:57 +0800
>>> Warren Pang  wrote:
>>>
>>> > Hi
>>> >
>>> > Does perl have a stream computing framework?
>>> > I know Java/python have many, such as spark, flink, beam etc.
>>> > But I am looking for a perl alternative, since most of our team members
>>> > have been using perl for data analysis.
>>> >
>>>
>>> 1. Do you want one for Raku which was formerly known as "Perl 6" (see
>>> https://en.wikipedia.org/wiki/Raku_(programming_language) ) or for
>>> "perl 5"?
>>>
>>> 2. What do you mean by "stream computing framework"? Is there a
>>> wikipedia/etc.
>>> page for them?
>>>
>>> 3. Can you link to some examples?
>>>
>>> 4. Do you mean something like http://pdl.perl.org/ (or numpy for
>>> python)?
>>>
>>>
>>> > Thank you.
>>>
>>>
>>>
>>> --
>>>
>>> Shlomi Fish   https://www.shlomifish.org/
>>> Why I Love Perl - https://shlom.in/joy-of-perl
>>>
>>> The reason the Messiah has not come yet, is because Chuck Norris keeps
>>> finding
>>> faults in God’s plan for his coming.
>>> — https://www.shlomifish.org/humour/bits/facts/Chuck-Norris/
>>>
>>> Please reply to list if it's a mailing list post -
>>> https://shlom.in/reply .
>>>
>>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


root cubic

2020-07-09 Thread Aureliano Guedes
Hi all,

A quick question.

This is expected?

raku -e 'say 9 ** (1/3)'
2.080083823051904


Why do I'm asking this?
I know about the computational floating problem and I also know that the
Raku deal with rational whenever it is possible and store numbers as
expressions (actually I don't know if there are more details). That's why
0.2 + 0.1 == 0.3 in Raku returns True whilst in other languages like
Python, Perl5, and Ruby return False.

Then, I was just playing around and I'd like to check if it is expected.

Thanks


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: why so different

2020-06-22 Thread Aureliano Guedes
Thanks again.

I'm trying to get proficiency in Raku by converting some Python programs
mine in Raku.

On Mon, Jun 22, 2020 at 6:41 PM Tobias Boege  wrote:

> On Mon, 22 Jun 2020, Aureliano Guedes wrote:
> > Thank you for the clarification.
> >
> > There is a method to set Rat precision at the scope of the program to
> apply
> > to all *.Rat() cases?
> >
>
> I don't know, based on a quick search in the documentation, of any global
> setting. The hacky solution would be to wrap the method like this:
>
>   say pi.Rat.nude;  # OUTPUT: (355 113)
>
>   Num.^find_method('Rat').wrap: -> |c {
>   # Make the default argument 1e-20
>   callwith |(|c, 1e-20 if c.elems ≤ 1)
>   };
>
>   say pi.Rat.nude;  # OUTPUT: (245850922 78256779)
>
> This program has three parts. First, we print pi.Rat.nude for comparison.
> The nude method returns numerator and denominator of a Rat as a list.
> The last part is just looking at pi.Rat.nude again to confirm that the
> change in the middle has worked and increased the default precision.
>
> You said you are relatively new to Raku, so let me explain the middle part.
> Raku has a special syntax for calling metamethods (i.e. doing
> introspection)
> on an object or type, which is the .^ operator. I use it to access an
> object
> representation of the Rat method on the Num type. I can wrap some code of
> my liking around this method via its wrap method.
>
> The `-> |c { … }` syntax creates an anonymous code block that wraps around
> the Num.Rat method and it accepts all arguments that may be passed as a
> Capture [1] in the variable c. If that Capture does not have a first
> parameter, i.e. the precision is not specified, I sneak in my 1e-20.
> Afterwards, the `callwith |(…)` part unpacks the (modified) captured
> arguments and calls the original method that I am wrapping [2].
>
> Effectively, I pass a precision of 1e-20 whenever the caller did not pass
> a precision. You can see that the wrapping takes effect immediately in
> the last line of the above program.
>
> Ideally, this could be turned into a module that hides the questionable
> means behind a dynamic $*RAT-PRECISION variable or so. That is, unless
> someone comes up with an even better solution.
>
> Best,
> Tobias
>
> [1] https://docs.raku.org/type/Capture
> [2] https://docs.raku.org/routine/wrap
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: why so different

2020-06-22 Thread Aureliano Guedes
Thank you for the clarification.

There is a method to set Rat precision at the scope of the program to apply
to all *.Rat() cases?



On Mon, Jun 22, 2020 at 5:57 PM Tobias Boege  wrote:

> On Mon, 22 Jun 2020, Aureliano Guedes wrote:
> > Hi all,
> >
> > First, I'm naive in Raku. Then let's go to my question.
> >
> > I'm trying to figure out why we got so different results here:
> >
> > > e.Rat()**(pi.Rat()*i)
> > -0.9902-1.3942922582021257e-07i
> > > e**(pi*i)
> > -1+1.2246467991473532e-16i
> > > e.Rat()**(pi.Rat()*i) == e**(pi*i)
> > False
> >
> > I understand the Num actually have the traditional behavior which leads
> > this:
> > 0.1.Num() + 0.2.Num() != 0.3.Num()
> >
> > And Rat is awesome cos deal nice to the real world.
> >
> > Anyway, I do not expect so different results between Rat and Num.
> >
>
> First, e and π are not rational numbers, so Num (IEEE 754 double)
> and Rat (pair of bigint numerator and denominator) both will be only
> approximations.
>
> The literals e and pi in Raku are typed as Num and when you call the
> Rat method on them, you get a Rat back with the *default* precision
> of 1e-6 [1]. That is a lot less precise than the Nums you started
> with, hence the difference. Try supplying a large enough precision:
>
>   > e.Rat(1e-200)**(pi.Rat(1e-200)*i)
>   -1+1.2246467991473532e-16i
>
> This is better than a default .Rat() but notice that you cannot get
> past the limited precision in the source Nums, which is ca. 1e-16.
>
> Best,
> Tobias
>
> [1] https://docs.raku.org/routine/Rat
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


why so different

2020-06-22 Thread Aureliano Guedes
Hi all,

First, I'm naive in Raku. Then let's go to my question.

I'm trying to figure out why we got so different results here:

> e.Rat()**(pi.Rat()*i)
-0.9902-1.3942922582021257e-07i
> e**(pi*i)
-1+1.2246467991473532e-16i
> e.Rat()**(pi.Rat()*i) == e**(pi*i)
False

I understand the Num actually have the traditional behavior which leads
this:
0.1.Num() + 0.2.Num() != 0.3.Num()

And Rat is awesome cos deal nice to the real world.

Anyway, I do not expect so different results between Rat and Num.

Thanks,
Aureliano Guedes


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: just curious to know

2020-06-14 Thread Aureliano Guedes
r since perl 6.0 was
> announced, I waited, like many, indefinitely.  At last perl 6.0 has just
> started from its starting block and is also in the race.  I am happy about
> that.
>
>
>
> Perl 5.0 was generally termed to be good at CGI scripting, system
> administration, web scraping, strong regex, processing text files etc.,
>
>
>
> I want to know what perl 6 is so special in.  When perl 5.0 was there,
> there did not exist any other language to do the same things easily as perl
> 5.0 did. Similarly, in which areas perl 6 is special?  I am unable to know
> it from google search, as much information is not available.
>
>
>
> Further, if concurrency and parallelism are the special things in perl 6,
> then Rust and Go (so special in both concurrency and parallelism) are
> already spreading its wings over the information technology field.  Both
> are statically typed and compiled languages and there would be more
> "welcome gesture" for these languages in the field.
>
>
>
> To put my question simply, where is the space for perl 6 in today's
> technology?
>
> Please enlighten me (any body from user group) on this.
>
>
>
> Thank you,
>
>
>
> Regards,
>
> Radhakrishnan
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: bash "."?

2020-05-13 Thread Aureliano Guedes
I didn't understand well your question, but "." in bash usually means "the
local directory".

On Wed, May 13, 2020 at 11:37 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Hi All,
>
> Do we have anything like Bash's "." statement where
> we can read in a bunch of values from a .cfg file?
> (I think it is called "include", but I am not sure.)
>
> . /etc/sysconfig/network-scripts/ifcfg-br0
>
> which populates these (and other) variables
>
> DEVICE=br0
> TYPE=Bridge
> ONBOOT=yes
> USERCTL=yes
> DELAY=0
> NM_CONTROLLED=yes
> BOOTPROTO=none
> PREFIX=24
> ...
>
> Many thanks,
> -T
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: perl6 vs ruby

2020-03-05 Thread Aureliano Guedes
I have another question for you. Maybe it must be better done in another
thread...
But, there is a way to compile Raku code in a binary capable to run in a
system without a Raku installation?

On Thu, Mar 5, 2020 at 6:17 AM Elizabeth Mattijsen  wrote:

> Well, internally many parts still have Perl 6 in them.  Renaming those
> is...  an interesting task.
>
> Online, most resources have been renamed, but some still need to be done.
> This mailing list being one of them.  Unfortunately, it is part of the
> crumbling Perl infrastructure, so it's unclear what would be the best
> course forward on this.
>
> > On 5 Mar 2020, at 10:09, Wyatt Chun  wrote:
> >
> > Hi
> >
> > Is perl6 totall renamed to raku?
> >
> > regards
> >
> > On Wed, Mar 4, 2020 at 4:15 AM Fields, Christopher J <
> cjfie...@illinois.edu> wrote:
> > A few people had started a port of some BioPerl code to Perl6 a while
> ago; I tested this recently and it still passed tests.
> >
> > https://github.com/cjfields/bioperl6
> >
> > It should be renamed to bioraku!
> >
> > Chris
> >
> > Sent from my iPhone
> >
> >> On Mar 3, 2020, at 11:41 AM, Parrot Raiser <1parr...@gmail.com> wrote:
> >>
> >> 
> >>> we use ruby for Biological data analysis. I wish perl6 should have got
> that capability.
> >>
> >> Would you like to give us a sample problem,, to see if someone can
> >> show a potential solution?
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: variable as subroutine?

2020-02-12 Thread Aureliano Guedes
Thank for sharing, I'll watch right now

On Wed, Feb 12, 2020 at 4:28 PM William Michels 
wrote:

>
>
> On Wed, Feb 12, 2020 at 8:12 AM Aureliano Guedes <
> guedes.aureli...@gmail.com> wrote:
>
>>
>>
>> On Wed, Feb 12, 2020 at 1:09 PM Andy Bach 
>> 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 
>>> *Sent:* Tuesday, February 11, 2020 7:00 PM
>>> *To:* Andy Bach ; perl6-users <
>>> 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 
>>> 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 
>>> *Sent:* Tuesday, February 11, 2020 6:36 PM
>>> *To:* Andy Bach 
>>> *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 

Re: variable as subroutine?

2020-02-12 Thread Aureliano Guedes
On Wed, Feb 12, 2020 at 1:09 PM Andy Bach 
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.

> --
> *From:* Aureliano Guedes 
> *Sent:* Tuesday, February 11, 2020 7:00 PM
> *To:* Andy Bach ; perl6-users <
> 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 
> 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 
> *Sent:* Tuesday, February 11, 2020 6:36 PM
> *To:* Andy Bach 
> *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 
> 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 &foo = * **2;
> { ... }
> > foo(4);
> 16
> > my &c = * **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 subrouti

Re: Metamethods: WHERE

2020-02-12 Thread Aureliano Guedes
Thank you. It really helps.

Then I go further to understand and I find interesting.
The same applies to int 3.
> 3.WHERE
94821123453912
As expected, is different from str 3
> "3".WHERE
139904951827592
But the same to $a.
> my $a = 3;
3

I suppose that the constant 3 is created only when called. AFAIK the Raku
store the $b from your example as a math expression (eager evaluation?).
That might explain why your $b has a different memory location.

Your answer was very helpful.
Thanks again


On Wed, Feb 12, 2020 at 11:29 AM Patrick R. Michaud 
wrote:

> On Wed, Feb 12, 2020 at 10:27:20AM -0300, Aureliano Guedes wrote:
> > So, I'd like to find a way to test if two variables are bound or not,
> > especially concerning their memory address.
> >
> > If the address is not fixed for a lifetime, I must be able to test it in
> > just one cycle.
> > > $a.WHERE == $b.WHERE   # I expected FALSE
> > True
> >
> > To a bound variable, I expect the same address, but to an unbounded
> > variable, this garbage collector behavior seams assing to the same memory
> > location two unbounded variables with the same value. It is right? Must
> > reduce memory usage but is a quiet weirdo.
>
> I don't know that it's "weirdo" that two variables containing the same
> (constant, immutable) value end up at the same address.  It's just the
> compiler treating constants as proper objects and being smart about memory
> allocation.
>
> In particular:
>
> > my $a = 3; say $a.WHERE
> 94659198947472
> > $a = 4; say $a.WHERE
> 94659198947432
> > $a = 3; say $a.WHERE
> 94659198947472
>
> What's likely happened is that the compiler has created an Int
> representing the constant "3", and keeps track of that for future
> compilations.  Whenever the compiler encounters another "3", rather than
> build a new Int object in memory it re-uses the Int it already established
> if it can.
>
> So, with
>
> > my $b = 3; say $b.WHERE
> 94659198947472
>
> The compiler lets $b use the same constant 3 object that was created the
> first time it was encountered, even though $a coincidentally also uses it.
>
> > $b = 6 div 2;  say $b; say $b.WHERE
> 3
> 139719166700504
>
> The compiler has gone ahead and used "6 div 2" to produce a new Int
> object, which has the same value as the constant 3 but is in a different
> memory location.  If we then do
>
> > $b = 3; say $b.WHERE
> 94659198947472
>
> you can see that the constant "3" Int is still hanging around to be used
> wherever it's later mentioned in the code.
>
> Hope this helps,
>
> Pm
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Metamethods: WHERE

2020-02-12 Thread Aureliano Guedes
Thanks for the tip!

This might be useful to data analysis tools.

On Wed, Feb 12, 2020 at 11:01 AM Brad Gilbert  wrote:

> If you want to find out if two variables are bound to the same data, there
> is an operator for that
>
> my $a = 3;
> my $b = 3;
> say $a =:= $b; # False
>
> my $c := $b;
> say $b =:= $c; # True
>
> On Wed, Feb 12, 2020 at 7:27 AM Aureliano Guedes <
> guedes.aureli...@gmail.com> wrote:
>
>> Thank you.
>>
>> So, I'd like to find a way to test if two variables are bound or not,
>> especially concerning their memory address.
>>
>> If the address is not fixed for a lifetime, I must be able to test it in
>> just one cycle.
>> > $a.WHERE == $b.WHERE   # I expected FALSE
>> True
>>
>> To a bound variable, I expect the same address, but to an unbounded
>> variable, this garbage collector behavior seams assing to the same memory
>> location two unbounded variables with the same value. It is right? Must
>> reduce memory usage but is a quiet weirdo.
>>
>> On Wed, Feb 12, 2020 at 10:13 AM Elizabeth Mattijsen 
>> wrote:
>>
>>>
>>>
>>> > On 12 Feb 2020, at 13:44, Aureliano Guedes 
>>> wrote:
>>> >
>>> > What "WHERE" should return?
>>> >
>>> > I was trying to find a method to return the memory address of some
>>> data.
>>> > Then I find the WHERE statement.
>>> > https://rosettacode.org/wiki/Address_of_a_variable#Perl_6
>>> > https://docs.perl6.org/language/mop#WHERE
>>>
>>> Please note that the memory address is *NOT* fixed for the lifetime of
>>> an object.  Garbage collection may move it to another memory location at
>>> *any* time.  I've therefore adapted the documentation of .WHERE to:
>>>
>>> Returns an C representing the memory address of the object.  Please
>>> note
>>> that in the Rakudo implementation of Raku, and possibly other
>>> implementations,
>>> the memory location of an object is B fixed for the lifetime of the
>>> object.  So it has limited use for applications, and is intended as a
>>> debugging
>>> tool only.
>>>
>>> https://github.com/Raku/doc/commit/3e6270d197
>>
>>
>>
>> --
>> Aureliano Guedes
>> skype: aureliano.guedes
>> contato:  (11) 94292-6110
>> whatsapp +5511942926110
>>
>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Metamethods: WHERE

2020-02-12 Thread Aureliano Guedes
Thank you.

So, I'd like to find a way to test if two variables are bound or not,
especially concerning their memory address.

If the address is not fixed for a lifetime, I must be able to test it in
just one cycle.
> $a.WHERE == $b.WHERE   # I expected FALSE
True

To a bound variable, I expect the same address, but to an unbounded
variable, this garbage collector behavior seams assing to the same memory
location two unbounded variables with the same value. It is right? Must
reduce memory usage but is a quiet weirdo.

On Wed, Feb 12, 2020 at 10:13 AM Elizabeth Mattijsen  wrote:

>
>
> > On 12 Feb 2020, at 13:44, Aureliano Guedes 
> wrote:
> >
> > What "WHERE" should return?
> >
> > I was trying to find a method to return the memory address of some data.
> > Then I find the WHERE statement.
> > https://rosettacode.org/wiki/Address_of_a_variable#Perl_6
> > https://docs.perl6.org/language/mop#WHERE
>
> Please note that the memory address is *NOT* fixed for the lifetime of an
> object.  Garbage collection may move it to another memory location at *any*
> time.  I've therefore adapted the documentation of .WHERE to:
>
> Returns an C representing the memory address of the object.  Please
> note
> that in the Rakudo implementation of Raku, and possibly other
> implementations,
> the memory location of an object is B fixed for the lifetime of the
> object.  So it has limited use for applications, and is intended as a
> debugging
> tool only.
>
> https://github.com/Raku/doc/commit/3e6270d197



-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Metamethods: WHERE

2020-02-12 Thread Aureliano Guedes
What "WHERE" should return?

I was trying to find a method to return the memory address of some data.
Then I find the WHERE statement.
https://rosettacode.org/wiki/Address_of_a_variable#Perl_6
https://docs.perl6.org/language/mop#WHERE

Then I tested it.

I created $a, $b and $c, where $c is binded to $b as I show below.
The point is, I expected $c and $b returns the same address, and it returns
as expected, but $a has the same $b value it also returns the same value
when used WHERE.

What I'm doing wrong?

> my $a = 3;
3
> my $b = 3;
3
> my $c := $b;
3
> $a = 4;
4
> $b = 4;
4
> $c
4
> $c = 5
5
> $b
5
> $a.WHERE
94576802723392
> $b.WHERE
94576802723352
> $c.WHERE
94576802723352
> $b = 4 # back to same $a value
4
> $c
4
> $a.WHERE
94576802723392
> $c.WHERE
94576802723392
> $b.WHERE
94576802723392



-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: variable as subroutine?

2020-02-11 Thread Aureliano Guedes
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 
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 
> *Sent:* Tuesday, February 11, 2020 6:36 PM
> *To:* Andy Bach 
> *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 
> 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 &foo = * **2;
> { ... }
> > foo(4);
> 16
> > my &c = * **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 &ident = {$_};
> my &sq = {$_ * $_};
> sub trinar( &test, &true, &false, *@values ) { @values.map( -> $v {
> &test($v) ?? &true($v) !! &false($v) } ) };
> trinar( *.is-prime, &sq,&ident, ^30 ).say
>
> Enjoy. ;)
>
> On Tue, 11 Feb 2020 at 15:22, Andy Bach 
> wrote:
>
> I have a few less related questions
> >> those are 3 ways to write the same sub:
>
> sub foo ($x) { $x * $x }
> my &foo = -> $x { $x * $x }
> my &foo = * * *;
>
> > A Note on Marc's comment:
> my &foo = * * *
> is not the same as:
> my &foo = -> $x { $x * $x }
> it is the same  as:
> my &foo = -> $x, $y { $x * $y }
>
> Okay, "* * *" - how does that work?  How is it different than
> -> $x { $x * $x }
> ?  I

Re: perl6 with XS

2020-02-03 Thread Aureliano Guedes
Also, this is amazing:
https://docs.raku.org/language/nativecall#sub_nativecast



On Mon, Feb 3, 2020 at 8:32 AM Aureliano Guedes 
wrote:

> This is nice.
> Sorry for my ignorance but what is the advantage in use CArray instead of
> a usual raku array?
> https://docs.raku.org/language/nativecall#CArray_methods
>
>
>
> On Mon, Feb 3, 2020 at 12:41 AM Darren Duncan 
> wrote:
>
>> Raku has the Native Call interface
>> https://docs.raku.org/language/nativecall
>> which is what you use instead. -- Darren Duncan
>>
>> On 2020-02-02 6:36 p.m., wes park wrote:
>> > HI
>> >
>> > In perl5 we can use the underline C library for example JSON C with XS
>> interface.
>> > In perl6 how can we implement it?
>> >
>> > Thanks
>> > Wes
>>
>
>
> --
> Aureliano Guedes
> skype: aureliano.guedes
> contato:  (11) 94292-6110
> whatsapp +5511942926110
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: perl6 with XS

2020-02-03 Thread Aureliano Guedes
This is nice.
Sorry for my ignorance but what is the advantage in use CArray instead of a
usual raku array?
https://docs.raku.org/language/nativecall#CArray_methods



On Mon, Feb 3, 2020 at 12:41 AM Darren Duncan 
wrote:

> Raku has the Native Call interface
> https://docs.raku.org/language/nativecall
> which is what you use instead. -- Darren Duncan
>
> On 2020-02-02 6:36 p.m., wes park wrote:
> > HI
> >
> > In perl5 we can use the underline C library for example JSON C with XS
> interface.
> > In perl6 how can we implement it?
> >
> > Thanks
> > Wes
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: My keeper on hashes

2020-01-15 Thread Aureliano Guedes
Thanks ToddAndMargo

Perhaps I have some questions to help improve the docs (I think):

1- You told about arrays of hashes, in Perl5 the opposite (hashes of
arrays) is quite fuzzy. Then, in Raku, how do I deal with hashes of arrays?

2 - "[...]say %h:p;   # note: no comma between the a and the b[...]",
that is interesting because using comma or semi-coma I had different
behavior.

perl6 -e 'my %h = a => "x", b=>"r", c=>"z"; say %h:p'
perl6 -e 'my %h = a => "x", b=>"r", c=>"z"; say %h:p'
perl6 -e 'my %h = a => "x", b=>"r", c=>"z"; say %h:p'

Sure, you notice I used "perl6" instead "raku". I'm not updated.



On Wed, Jan 15, 2020 at 10:28 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> >> On Wed, Jan 15, 2020 at 6:00 PM ToddAndMargo via perl6-users
> >> mailto:perl6-users@perl.org>> wrote:
> >>
> >> A recent addition to my hashes keeper:
> >>
> >>
> >>  Confining hashes:
> >>  Note: as of 2020-01-15, confining only works with Str.
> >>And you must confine the entire hash, not each member
> >>
> >> my Str %h = A => "a"
> >> {A => a}
> >>
> >> my int %h = A => 123
> >> native value types for hashes not yet implemented. Sorry.
> >>
>
> On 2020-01-15 18:27, yary wrote:
> > Capital I in Int, to not use native type
> >
> >> my Int %h = A => 123
> >
> > {A => 123}
> >
> >
> > -y
>
> Hi Yary,
>
> Updated and awesome!  Thank you!
>
> Is Int
>
> https://docs.raku.org/type/Int
> Int objects store integral numbers of arbitrary size
>
> one of those "Magic" variables that is unbounded, meaning
> I can have a 1024 bit integer if I choose?
>
> -T
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Bug to report: cardinal called an integer

2020-01-13 Thread Aureliano Guedes
ToddAndMargo, this should handle any kind of columns separated data (or any
table). If some column (commonly separated with a constant character as
"\t", ";", "|", )  has different types (char, text, int, boolean, ...)
in a single column, then it should be treated as a character, but if it has
only float (in all rows/lines) then the parser checks all rows for a same
column (in this example case all them are float) and assign the column as
float contain column.
Example:

NAME(long char);NICK(char);AGE(natural/positive integer);HEIGHT(float
m);WEIGHT(float kg)

John Lovegood;JoL;23;1.80;85.283

Marry Lockheart;Marry_L;35;1.68;63,125

You may see that the first line must be a header, all lines have 5 fields
separated by ";" and each field has a unique type (the specifications not
aways be declared on the data or file).


Paul Proacci, thank you for a lot. I agree with you. Then, float, integer,
boolean and char are the most commons and probably better to assign. But
persist the question, which is the best strategy to define with which type
assign some column?

On Mon, Jan 13, 2020 at 11:28 PM Paul Procacci  wrote:

> >> what is the best strategy?
>
> My general rule of thumb:
>
> If you control the value then you can pick whatever data type that has the
> largest number of bits to hold your largest value.[1]
> If you don't control the value, stick with an Int (or Uint).
>
> If you stick with Int you can later modify it to use more tailor made type
> as necessary, but Int is always going to be the safest bet.
>
> Hope this helps you.
>
> [1] I never use unsigned variants of integers where arithmetic may be
> involved do to overflow and use variants of signed integers instead
> whenever possible.
>
> On Mon, Jan 13, 2020 at 11:09 PM Aureliano Guedes <
> guedes.aureli...@gmail.com> wrote:
>
>> About the Raku typing, suppose I'll write a library to deal with data
>> frames/tables (as PDL - Perl(5) Data Language), something like
>> Pandas-Python or R.
>> After reading the file (csv; tsv ) I'd like that some routine
>> identifies the best type to fix each column (especially in cases like Unit,
>> unit, int, ) what is the best strategy?
>>
>> On Mon, Jan 13, 2020 at 10:51 PM ToddAndMargo via perl6-users <
>> perl6-users@perl.org> wrote:
>>
>>> >> On Mon, Jan 13, 2020 at 9:51 PM ToddAndMargo via perl6-users
>>> >> mailto:perl6-users@perl.org>> wrote:
>>> >>
>>> >> On 2020-01-13 18:46, ToddAndMargo via perl6-users wrote:
>>> >>  > On 2020-01-13 17:13, ToddAndMargo via perl6-users wrote:
>>> >>  >> And, no one is telling me percisely what the difference
>>> >>  >> between UInt and uint is other than one is a subset of
>>> >>  >> Int and the other is a native type.  They act exactly
>>> >>  >> the same.
>>> >>  >
>>> >>  > Hi All,
>>> >>  >
>>> >>  > Off line, Paul told me what the difference is
>>> >>  > between a UInt and a uint.
>>> >>  >
>>> >>  > uint is constrained:
>>> >>  >
>>> >>  >  p6 'my uint $c = 0x0; $c = $c +| 0x1;'
>>> >>  >  Cannot unbox 65 bit wide bigint into native integer
>>> >>  >   in block  at -e line 1
>>> >>  >
>>> >>  > UInt uses magic Larry Wall powder to remove the constraints
>>> >>  > from the variable.  (Same powder he uses to create nils.)
>>> >>  >
>>> >>  >  p6 'my UInt $c = 0x0; $c = $c +|
>>> >>  > 0x1F;
>>> say
>>> >> $c'
>>> >>  >
>>> 862718293348820473429344482784628181556388621521298319395315527974911
>>> >>  >
>>> >>  > Other than the constrains, they act exactly the same.
>>> >>  > Oh, and they are both (generic programming term) unsigned
>>> integers
>>> >>  > (cardinals)
>>> >>  >
>>> >>  > :-)
>>> >>  >
>>> >>  > -T
>>> >>
>>> >>
>>> >> And good luck, all you who told me to read the
>>> >> documentation, trying to find the constraints
>>> >> explanation in the documentation:
>>&g

Re: Bug to report: cardinal called an integer

2020-01-13 Thread Aureliano Guedes
About the Raku typing, suppose I'll write a library to deal with data
frames/tables (as PDL - Perl(5) Data Language), something like
Pandas-Python or R.
After reading the file (csv; tsv ) I'd like that some routine
identifies the best type to fix each column (especially in cases like Unit,
unit, int, ) what is the best strategy?

On Mon, Jan 13, 2020 at 10:51 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> >> On Mon, Jan 13, 2020 at 9:51 PM ToddAndMargo via perl6-users
> >> mailto:perl6-users@perl.org>> wrote:
> >>
> >> On 2020-01-13 18:46, ToddAndMargo via perl6-users wrote:
> >>  > On 2020-01-13 17:13, ToddAndMargo via perl6-users wrote:
> >>  >> And, no one is telling me percisely what the difference
> >>  >> between UInt and uint is other than one is a subset of
> >>  >> Int and the other is a native type.  They act exactly
> >>  >> the same.
> >>  >
> >>  > Hi All,
> >>  >
> >>  > Off line, Paul told me what the difference is
> >>  > between a UInt and a uint.
> >>  >
> >>  > uint is constrained:
> >>  >
> >>  >  p6 'my uint $c = 0x0; $c = $c +| 0x1;'
> >>  >  Cannot unbox 65 bit wide bigint into native integer
> >>  >   in block  at -e line 1
> >>  >
> >>  > UInt uses magic Larry Wall powder to remove the constraints
> >>  > from the variable.  (Same powder he uses to create nils.)
> >>  >
> >>  >  p6 'my UInt $c = 0x0; $c = $c +|
> >>  > 0x1F; say
> >> $c'
> >>  >
> 862718293348820473429344482784628181556388621521298319395315527974911
> >>  >
> >>  > Other than the constrains, they act exactly the same.
> >>  > Oh, and they are both (generic programming term) unsigned
> integers
> >>  > (cardinals)
> >>  >
> >>  > :-)
> >>  >
> >>  > -T
> >>
> >>
> >> And good luck, all you who told me to read the
> >> documentation, trying to find the constraints
> >> explanation in the documentation:
> >>
> >> https://docs.raku.org/type/UInt
> >>
> >> Have fun!
> >>
> >> But it does say "The UInt is defined as a subset of Int:"
> >> and Int is definitely constrained.
> >>
>
> On 2020-01-13 19:13, Paul Procacci wrote:
> >  >> trying to find the constraints explanation in the documentation:
> >
> > https://docs.raku.org/language/nativetypes
> >
> > "Raku offers a set of /native/ types with a fixed, and known,
> > representation in memory"
> > and
> > "However, these types do not necessarily have the size that is required
> > by the NativeCall <https://docs.raku.org/language/nativecall> interface
> > (e.g., Raku's |int| can be 8 bytes but C's |int| is only 4 bytes)"
> >
> > Took me all of 30 seconds to find.  Obviously that page has much more
> > information to offer than just those couple of sentences, but ALL native
> > types are constrained by a certain number of bits.
>
>
> Hi Paul,
>
> For those of you who were no privy to Paul and my
> offline discussion, he must have wrote me 10
> times trying to explain things to me before
> I got it.  He is a real mensch.
>
> 30 seconds!  Yikes!  I never found it.
>
> https://docs.raku.org/type/UInt
> should have stated that directly, but did not.
>
> And to add injury,
>
> https://docs.raku.org/language/nativetypes
>  "Raku offers a set of /native/ types with a fixed,
>  and known, representation in memory"
>
> Did not state who they were.  Sort of like when I
> want the  salt, I always reach for the pepper!
>
> The state of the documentation drives me  ...
>
>  AAHH! 
>
> -T
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Variable character class

2019-09-07 Thread Aureliano Guedes
Why does it dont return ordered for neither of those lists?
I mean:

my $u = "24680";
my @s = $u.comb.unique;
say @s ; # [2 4 6 8 0]

sub matching_chars(Str $a, Str $b) {
   my @c = $a.comb.unique;
   my @d = $b.comb.unique;
   return ~[@c (&) @d];
}

say matching_chars("24680", "1234567890"); # says 2 0 8 4

On Mon, Sep 2, 2019 at 1:20 AM William Michels via perl6-users <
perl6-users@perl.org> wrote:

> Thanks Simon, good point. I ran into the same trouble as others trying
> to get the answer via regex, and switched over to sets as an
> alternative. I'll confess I completely missed that Yary's Perl5 code
> returned the substring "8420" present in his test "19584203" string,
> and that was the answer he was going for.
>
> Simon and Eirik, I still think there might be some value in calling
> the .unique method on $chars.comb as in "$chars.comb.unique". But I
> haven't had the opportunity to check code efficiency  +/-  the
> ".unique" method call.
>
> For those interested in using Sets as a solution, you can stringifying
> the 'return' line (below). Still working on using "join()" to
> concatenate!
>
> sub matching_chars(Str $a, Str $b) {
>my @c = $a.comb.unique;
>my @d = $b.comb.unique;
>#return (~[@c (&) @d]).^name;
>return ~[@c (&) @d];
> }
>
> say matching_chars("24680", "19584203"); # says 2 0 8 4
> say matching_chars('+\/\]\[', 'Apple ][+//e'); # says [ + ] /
> say matching_chars("Lorem ipsum dolor sit amet, consectetuer
> adipiscing elit.", "abcdef"); # says c a d e
>
>
> HTH, Bill.
>
> PS. Simon, thanks for all the great Youtube videos you've done from
> LondonPM!
>
> https://youtu.be/yt8SrZ_V_50
> https://youtu.be/9M1xZQ0_Skw
>
>
>
>
>
>
>
>
> On Sun, Sep 1, 2019 at 9:59 AM Simon Proctor 
> wrote:
> >
> > Using a set would be good but it doesn't give you the matching string
> from the original (which is what I thought was required) otherwise Sets
> would be my first thought.
> >
> > On Sun, 1 Sep 2019, 17:57 William Michels, 
> wrote:
> >>
> >> Hi Yary and Paul and Simon,
> >>
> >> I ran into the same difficulties as Yary with repeated characters, so
> >> I tried the .unique method. Then after a while, I realized that
> >> problems like this might best be treated as "Set" problems in Perl6.
> >> Note the Set Intersection operator "(&)" below:
> >>
> >> sub matching_chars(Str $a, Str $b) {
> >>my @c = $a.comb.unique;
> >>my @d = $b.comb.unique;
> >>#say @c; say @d;
> >>return @c (&) @d;
> >> }
> >>
> >> say matching_chars("24680", "19584203"); #RETURNS set(0 2 4 8)
> >> say matching_chars('+\/\]\[', 'Apple ][+//e'); #RETURNS set(+ / [ ])
> >>
> >>
> >> https://docs.perl6.org/routine/Set
> >> https://docs.perl6.org/language/operators#infix_(&),_infix_∩
> >>
> >> HTH, Bill.
> >>
> >>
> >> On Sat, Aug 31, 2019 at 8:59 PM Paul Procacci 
> wrote:
> >> >
> >> > I'm not entirely sure if this is the correct answer, but if you
> define your own custom character class
> >> > with a 'regex' object, you can use that in the grouping.
> >> >
> >> > sub matching_chars(Str $chars_to_match, Str $_) {
> >> > my regex x { $chars_to_match ** 1 };
> >> > m/<[]>/;
> >> > }
> >> >
> >> > The above worked for me in the very small testing I did.
> >> >
> >> > ~Paul
> >> >
> >> > On Sat, Aug 31, 2019 at 9:54 PM yary  wrote:
> >> >>
> >> >> I found something easy in Perl 5 that's puzzling me in Perl 6-
> specifying a character class via a variable.
> >> >>
> >> >> Perl 5:
> >> >> sub matching_chars {
> >> >>   (my $chars_to_match, local $_) = @_;
> >> >>   /([$chars_to_match]+)/
> >> >> }
> >> >>
> >> >> say matching_chars('24680', '19584203'); # says 8420
> >> >> say matching_chars('+\/\]\[', 'Apple ][+//e'); # says ][+//
> >> >>
> >> >> Perl 6:
> >> >> sub matching_chars(Str $chars_to_match, Str $_) {
> >> >> # warnings, treats as string not variable
> >> >> m/<[$chars_to_match]>/;
> >> >> }
> >> >>
> >> >> How do I get Perl 6 to interpret a variable in the contents of a
> character class?
> >> >> From http://docs.perl6.org/language/regexes#Regex_interpolation I'd
> think that  Rakudo would use the literal contents of $chars_to_match,
> instead it's using the literal chars "$ c h a r s _ t o _ m a t c h" and
> warning about repeated c, underscore, etc.
> >> >>
> >> >> -y
> >> >
> >> >
> >> >
> >> > --
> >> > __
> >> >
> >> > :(){ :|:& };:
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-18 Thread Aureliano Guedes
Even being another language, Perl6 should be inheriting Perl5's regexes or
even improving it not making it uglier and harder.

Or I'm seeing how to use it in an easy way. Also, dunno if there is some
GOOD documentation to Perl6 regexes.

On Sun, Aug 18, 2019 at 12:56 PM Brad Gilbert  wrote:

> The Perl6 regex system was simplified.
> Instead you use the rest of Perl6 to implement those features.
> Both inside and outside of the regexes.
> (Which means there are fewer esoteric features that are rarely used, and
> often forgotten or never learned.)
>
> It might be best to just store the position at the end of the regex.
>
> use v6
> my $test = "  foo bar";
> my $pos = 0;
>
> $test ~~ m /^\s+  {$pos = $/.pos}/;
> $test ~~ m :pos($pos) /foo\s+  {$pos = $/.pos}/;
> $test ~~ m :pos($pos) /willnotmatch  {$pos = $/.pos}/;
> $test ~~ m :pos($pos) /bar   {$pos = $/.pos}/;
>
> say $/.pos; # yields "13"
>
> If you want something a bit closer:
>
> In here `\G` translates to `:pos($/.pos // $pos)` and `/c` translates to
> `{let $pos = $/.pos}`.
>
> use v6
> my $test = "  foo bar";
> my $pos = 0;
>
>
> $test ~~ m /^\s+/;
> $test ~~ m :pos($/.pos // $pos) /foo\s+/;
> $test ~~ m :pos($/.pos // $pos) /{let $pos = $/.pos} willnotmatch/;
> $test ~~ m :pos($/.pos // $pos) /bar/;
>
> say $pos; # yields "13"
>
> You could combine ($/.pos // $pos) into a function:
>
> use v6
> my $test = "  foo bar";
> my $pos = 0;
>
> sub pos () { OUTERS::<$/>.pos // $pos } # may defeat optimizations
>
> $test ~~ m /^\s+/;
> $test ~~ m :pos(pos) /foo\s+/;
> $test ~~ m :pos(pos) /{let $pos = $/.pos} willnotmatch/;
> $test ~~ m :pos(pos) /bar/;
>
> say $pos; # yields "13"
>
> Note that in Perl6 regexes are code.
> (They can have parameters and lexical variables.)
>
> Personally I would just combine them into a grammar.
>
> grammar FooBar {
> token TOP {
> $ = \s+
> 
> [
> || 
> || 
> ]
> }
>
> token foo { foo \s+ }
> token willnotmatch { willnotmatch }
> token bar { bar }
> }
>
> The || is to get the Perl5 semantics of trying them in order. It would
> actually be better to use |.
>
> Anyway the result is structured.
>
> say FooBar.parse($test);
> 「  foo bar」
>  space => 「  」
>  foo => 「foo 」
>  bar => 「bar」
>
> You could get the same structure out of a single regex as well.
>
> $test ~~ m {
> ^
> $ = \s+
> $ = [foo \s+]
> [
> | $ = willnotmatch
> | $ = bar
> ]
> }
>
> I'm not sure if you want to include the space(s) after `foo` into
> `$/`.
> But to keep it the same as the original I used `[]` to group `foo` and
> `\s+`.
>
> On Sun, Aug 18, 2019 at 9:48 AM Raymond Dresens 
> wrote:
>
>> Hello,
>>
>> In the past few days I've been converting some "incremental
>> parsing"-regex code from perl 5 to perl 6 (I haven't not touched grammars,
>> yet...)
>>
>> In Perl 5 I often used the /g and /c modifiers so that the following
>> snippet of code doesn't die:
>>
>> # perl5
>>
>> my $test = "  foo bar";
>>
>> die unless $test =~ /^\s+/g;
>> die unless $test =~ /\Gfoo\s+/g;
>> die if $test =~ /\Gwillnotmatch/gc; # ...what is the equivalent
>> of the 'c' modifier in Perl 6?
>> die unless $test =~ /\Gbar/g;
>>
>> say pos $test; # yields "13"
>>
>> I managed to translate such code in Perl 6, by using the "m:p/.../"
>> regex,
>>
>> When I anticipate an unsuccessful match then I must temporarily store
>> $/.pos and provide it to the next regex (e.g. "m:p($P)//"), so it seems,
>>
>> That works but it riddles my current solutions with "$P = $/.pos;"
>> assignments.
>>
>> Is there a way to retain this match like in Perl 5?
>>
>> Is there a better way in general?
>>
>> ... perhaps it's time to look into grammars? ;)
>>
>> Thanks!
>>
>> Regards,
>>
>> Raymond Dresens.
>>
>>
>>
>>
>>
>>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110