Re: can't make from a S/// ?
hello William, > method col:sym ($/) { make $/.subst(/'""'/, '"', :global).Str } which is just a longuest version of the line Ralph wrote. i'm inclined to think that this is easier to read: method col:sym ($/) { .make ~S:g/'""'/"/ } > The following line seems to work just fine, with-or-without the call to > .Str at the end both works but if you don't use ~ or .Str, a match is returned. I noticed after i replied to Ralph. Thanks for helping, regards
Raku and Datasciences
hello people, > 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 still excited about this idea and my offer to test/feedback/document remains open. A first step should be to start with examples of pure Raku code. Once we are confident about the fact it's the state of art of the langage, we can merge it into https://github.com/Raku/examples/tree/master/categories I started it by using a turorial made by a colleage (in french, sorry) about "exploring facts about the titanic demography with python" https://www.youtube.com/watch?v=FNDWAybVPcc which is a good example: * simple grammar * simple data manipulations * interesting facts to work on simpler enough to explore Raku concepts and asking myself a lot of questions like "is it possible that a grammar can Supply objects or beging lazy". so could something inspired like that grammar grammar CSV { rule TOP { * } token line { * %% ',' \n } proto token col {*} token col:sym { <-[\n",]>* } token col:sym { '"' ~ '"' [<( [ '""' | <-[\n"]> ]* )>] } } which is basically used that way: my @data = CSV.parse( actions => CSV_as_table.new, "quoted.csv".IO.slurp ).made; my \col = %( $_ Z=> ^$_ with @data.shift.List ); be used this way to take avantage of lazyness: my @top5 = do { .use_headers; .head(5) } with onfly CSV, "quoted.csv".IO; # IO stops tor read at line 6 regards, marc
Re: can't make from a S/// ?
> > Marc wrote: > i'm inclined to think that this is easier to read: > method col:sym ($/) { .make ~S:g/'""'/"/ } > That's not working for me. I'm on Moar (2021.06). This Is what I get back (first error below, note the "grammar CSV" line is the first line of the script, and method col:sym is on line 20): No such method 'make' for invocant of type 'Any'. Did you mean any of these: 'Map', 'map', 'max', 'raku'? in method col:sym at - line 20 Best Regards, Bill. On Sat, Nov 20, 2021 at 12:22 AM Marc Chantreux wrote: > hello William, > > > method col:sym ($/) { make $/.subst(/'""'/, '"', :global).Str } > > which is just a longuest version of the line Ralph wrote. i'm inclined > to think that this is easier to read: > > method col:sym ($/) { .make ~S:g/'""'/"/ } > > > The following line seems to work just fine, with-or-without the call to > > .Str at the end > > both works but if you don't use ~ or .Str, a match is returned. I > noticed after i replied to Ralph. > > Thanks for helping, > regards >
Re: can't make from a S/// ?
helllo William, > > Marc wrote: > > i'm inclined to think that this is easier to read: > > method col:sym ($/) { .make ~S:g/'""'/"/ } > That's not working for me. I'm on Moar (2021.06). works for me with: Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2021.09. Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d. Built on MoarVM version 2021.09. > This Is what I get back (first error below, note the "grammar CSV" line is > the first line of the script, and method col:sym is on line 20): the whole grammar and action is: grammar CSV { rule TOP {* } token line { * %% ',' \n } proto token col {*} token col:sym { <-[\n",]>* } token col:sym { '"' ~ '"' [<( [ '""' | <-[\n"]> ]* )>] } } class CSV_as_table { method TOP ($/) { make $/.map: *.made } method line ($/) { make $/.map: *.made } method col:sym ($/) { make ~$/ } method col:sym ($_) { .make: ~S:g/'""'/"/ } } regards marc
Re: can't make from a S/// ?
On Sat, Nov 20, 2021 at 9:03 PM Marc Chantreux wrote: > > > method col:sym ($/) { .make ~S:g/'""'/"/ } > > That's not working for me. I'm on Moar (2021.06). > > works for me with: > method col:sym ($_) { .make: ~S:g/'""'/"/ } > Yeah, you got it wrong the first time. To explicate, the key difference is differently named parameters: ($/) vs ($_). Eirik
Re: can't make from a S/// ?
> On Sat, Nov 20, 2021 at 9:03 PM Marc Chantreux wrote: > > > > method col:sym ($/) { .make ~S:g/'""'/"/ } > > > That's not working for me. I'm on Moar (2021.06). > > works for me with: > > method col:sym ($_) { .make: ~S:g/'""'/"/ } > Yeah, you got it wrong the first time. To explicate, the key difference > is differently named parameters: ($/) vs ($_). Ohh ... sorry i didn't spot the problem because the relation between $_ and the use of .make was too obvious to me. thank you for noticing! regards marc