Re: pint: Elizabeth, sort list???
Hi Marc, This works: ==> sort({ | map { +$_ // $_ }, .split: /\d+/, :v }) ==> say() As the documentation says here https://docs.raku.org/routine/%3D%3D%26gt%3B The precedence is very loose so you will need to use parentheses to assign the result On Thu, Mar 7, 2024 at 8:37 AM Marc Chantreux wrote: > hello, > > > How would you write that expression using the feed operator? > > I tried > > < afoo12 afoo2 > > ==> {.sort: { | map { +$_ // $_ }, .split: /\d+/, :v }} > ==> {map } > > and the error message is really interesting > > Only routine calls or variables that can '.append' may > appear on either side of feed operators. > > on the other hand: I really don't understand why ==> even exists > as method call syntax works well. > > < afoo12 afoo2 > > .sort( { | map { +$_ // $_ }, .split: /\d+/, :v } ) > .map() > > what I would love instead is something closer than the haskell's $ > operator with a very low priority so it could be possible to be > parenthesis free. > > as example. I would like > > 1..10 ==> map * * 2 ==> say > > to be a joyful version of > > (1..10).map(* * 2).say > > regards > > -- > Marc Chantreux > Pôle CESAR (Calcul et services avancés à la recherche) > Université de Strasbourg > 14 rue René Descartes, > BP 80010, 67084 STRASBOURG CEDEX > 03.68.85.60.79 > > -- Fernando Santagata
Re: Marketing / PR / Branding
Hi Richard, Where is the Raku/Problem-solvers discussion about PR? Is it at https://github.com/Raku/problem-solving ? If so, which sub-category? (I can't find a Marketing/PR/Branding section) On Tue, Oct 31, 2023 at 2:26 PM Richard Hainsworth wrote: > Hi, > > I just posted a new discussion in the Raku/Problem-solvers discussion > about the subject. > > The idea is to brain storm about where to go with Raku marketing / PR / > branding. So if you have some ideas / point of view, please contribute. > > Regards, > > Richard, aka finanalyst > > -- Fernando Santagata
Re: Undefine mixed data
Hi, I don't know if I understood your question correctly; I tried two alternative ways to assign Nil using the REPL: [0] > my ($a, @b, %c, ) ((Any) [] {} (Callable)) [1] > [$a, @b, %c, ] »=» Nil [(Any) [] {} (Any)] [2] > say "{$a.^name} {@b.^name} {%c.^name} {^name}" Any Array Hash Callable [2] > [$a, @b, %c, ].map: { $_ = Nil } ((Any) (Any) (Any) (Any)) [3] > say "{$a.^name} {@b.^name} {%c.^name} {^name}" Any Array Hash Callable On Tue, Mar 14, 2023 at 4:42 AM rir wrote: > > undefine seen at: > , line 1 > Will be removed with release v6.e! > Please use another way: assign a Nil; for Arrays/Hashes, assign Empty > or () instead. > > Will that deprecation require a conditional and two assignments > for mixed data? > > [$a, @a, $b, %c, $c, ].map: { .}; > > [$a, @a, $b, %c, $c, ].map( > { $_ = $_ ~~ (Associative,Positional).any ?? Empty !! Nil }); > -- Fernando Santagata
Re: JPEG meta-data timestamps
Actually there's a Raku module: https://raku.land/cpan:FRITH/Image::Libexif It's a thin-layer interface to the libexif, but it works. On Sat, Oct 8, 2022 at 10:21 PM rir wrote: > Are there any Raku modules for extracting meta-data from > JPEG files? I have looked but not found. > > At this point, I just want to extract dates to re-timestamp > the files. Later, I might use the fix in the pictures to > map to personally defined places. > > Rob > > > > > > > -- Fernando Santagata
Re: steps of a path
Hello, you can get around the immutability problem: raku -e '"/var/log/messages".IO.map: -> $_ is copy {repeat {.put} while ! ($_ .= parent ~~ "/") }' On Mon, Sep 5, 2022 at 8:55 AM Marc Chantreux wrote: > hello William, > > On Sat, Sep 03, 2022 at 04:27:04PM -0700, William Michels wrote: > > Hi Marc, There's also this conversation from March 2021 on the mailing > list: > > https://www.nntp.perl.org/group/perl.perl6.users/2021/03/msg9857.html > > [Matthew's answer looks very interesting]. > > Interesting as it can provide a relative short solution with no advanced > concept. I tried this line but got an immutability problem. I tried > multiple work around with no success for the moment. > > <<. raku -e 'lines.IO.map: {repeat {.put} while not .=parent ~~ "/" }' > /var/log/messages > > thank you > > -- > Marc Chantreux > Pôle de Calcul et Services Avancés à la Recherche (CESAR) > http://annuaire.unistra.fr/p/20200 > -- Fernando Santagata
Re: Inconsistencies with "with" chained to "for"
Hi Vadim, Thank you! I opened issue #5049. On Sun, Aug 28, 2022 at 12:56 AM Vadim Belman wrote: > > Looks like it worth a bug report. I was probably stumbling upon this too > for a couple of times. > > Best regards, > Vadim Belman > > > On Aug 27, 2022, at 2:24 AM, Fernando Santagata < > nando.santag...@gmail.com> wrote: > > > > Hello, > > I noticed this behavior: > > > > [0] > my @a = > > [a b c d e] > > [1] > .say with $_ for @a > > () > > [2] > .say if .defined for @a > > a > > b > > c > > d > > e > > [3] > (.say with $_) for @a > > a > > b > > c > > d > > e > > [4] > (.say if .defined) for @a > > a > > b > > c > > d > > e > > > > Apparently in this case "with" works only as a statement modifier while > "if" works both ways. > > Is this a known behavior with well understood reasons, or should I open > an issue? > > > > -- > > Fernando Santagata > > -- Fernando Santagata
Inconsistencies with "with" chained to "for"
Hello, I noticed this behavior: [0] > my @a = [a b c d e] [1] > .say with $_ for @a () [2] > .say if .defined for @a a b c d e [3] > (.say with $_) for @a a b c d e [4] > (.say if .defined) for @a a b c d e Apparently in this case "with" works only as a statement modifier while "if" works both ways. Is this a known behavior with well understood reasons, or should I open an issue? -- Fernando Santagata
Re: I can't 'zef uninstall' old versions of modules anymore
On Tue, Aug 9, 2022 at 2:13 PM Elizabeth Mattijsen wrote: > > On 9 Aug 2022, at 13:53, Fernando Santagata > wrote: > > > > Hello, > > > > I'm trying to uninstall old versions of some modules; it looks like it's > working but in reality it isn't. For example, but it's not limited to just > this module: > > > > $ zef list --installed|grep CBOR > > ===> Found via /opt/rakudo-pkg/share/perl6/core > > ===> Found via /home/nando/.raku > > CBOR::Simple:ver<0.1.1>:auth:api<0> > > CBOR::Simple:ver<0.1.2>:auth > > > > $ zef uninstall 'CBOR::Simple:ver<0.1.1>:auth:api<0>' > > ===> Uninstalled from /home/nando/.raku > > CBOR::Simple:ver<0.1.1>:auth:api<0> > > What does > > raku -e 'use CBOR::Simple:ver<0.1.1>:auth:api<0>' > > say after you've done this? Does it still load, or does it give an error? > $ raku -e 'use CBOR::Simple:ver<0.1.1>:auth:api<0>' ===SORRY!=== Error while compiling -e Could not open /home/nando/.raku/sources/983E0FAFB758220B170D33A30493A316F0805F75. Failed to stat file: no such file or directory at -e:1 You're right, the listing is incorrect. Besides, trying to uninstall the module doesn't return any error. > It started when I was using Rakudo v2022.06, but I hoped that upgrading > to the next version would solve the problem. Alas, no luck. > > Did you create an issue for it? If not, how would anybody be able to know > of your problem? > I thought it was a local problem and I wanted to investigate it further, but so far had no chance to do it, so I tried and see if it was a known issue. I've just submitted an issue. -- Fernando Santagata
I can't 'zef uninstall' old versions of modules anymore
Hello, I'm trying to uninstall old versions of some modules; it looks like it's working but in reality it isn't. For example, but it's not limited to just this module: $ zef list --installed|grep CBOR ===> Found via /opt/rakudo-pkg/share/perl6/core ===> Found via /home/nando/.raku CBOR::Simple:ver<0.1.1>:auth:api<0> CBOR::Simple:ver<0.1.2>:auth $ zef uninstall 'CBOR::Simple:ver<0.1.1>:auth:api<0>' ===> Uninstalled from /home/nando/.raku CBOR::Simple:ver<0.1.1>:auth:api<0> $ zef list --installed|grep CBOR ===> Found via /opt/rakudo-pkg/share/perl6/core ===> Found via /home/nando/.raku CBOR::Simple:ver<0.1.1>:auth:api<0> CBOR::Simple:ver<0.1.2>:auth $ raku --version Welcome to Rakudo™ v2022.07. Implementing the Raku® Programming Language v6.d. Built on MoarVM version 2022.07. $ zef --version v0.13.8 It started when I was using Rakudo v2022.06, but I hoped that upgrading to the next version would solve the problem. Alas, no luck. All I can say is that when I install a new Rakudo version I always run cleanup-precomp . I don't know whether this might alter the local zef DB so that I can't uninstall modules anymore. Has anyone had the same problem? -- Fernando Santagata
Re: Is this zef or me: Inconsistent Ecosystem response
Hi Richard, I tried 'zef search Raku::Pod::Render' and I can only see versions from v2.1 through v3.7.3. If your last version is v3.7.5 there's something missing for sure. On Wed, Jun 29, 2022 at 2:50 PM Richard Hainsworth wrote: > Hi, > > zef appears to be giving inconsistent results. > > I have updated several of my modules. But when I try the github actions to > test an update a module that depends on one updated, it does not recognise > the most recent module, only a version I changed some time ago. > > I have a module called Raku::Pod::Render the latest version is v3.7.5 > > When I use `zef info "Raku::Pod::Render" ` on my local machine, I get > > zef info "Raku::Pod::Render" > > ===> Updating fez mirror: http://360.zef.pm/ > ===> Updated fez mirror: http://360.zef.pm/ > ===> Updating p6c mirror: > https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json > ===> Updating cpan mirror: > https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json > ===> Updated p6c mirror: > https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json > ===> Updated cpan mirror: > https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json > - Info for: Raku::Pod::Render > - Identity: Raku::Pod::Render:ver<3.7.5>:auth > - Recommended By: Zef::Repository::Ecosystems > - Installed: Yes > Description: A generic Pod6 Renderer with custom Pod::Blocks, FormatCodes > for one or more files using templates, provides HTML and MarkDown. > License: Artistic-2.0 > Source-url: git://github.com/finanalyst/raku-pod-render.git > Provides: 12 modules > Support: > # bugtracker:https://github.com/finanalyst/raku-pod-render/issues > # source:https://github.com/finanalyst/raku-pod-render.git > # email:richard@hainsworth.wales > Depends: 14 items > > I have another module called Raku-Pod-Extraction, which "depends on" > Raku::Pod::Render:v<3.7.5+> > > My github workflow file is > > name: "Raku" > on: [ push, pull_request ] > jobs: > raku: > strategy: > matrix: > os: > - ubuntu-latest > raku-version: > - 'latest' > runs-on: ${{ matrix.os }} > steps: > - name: Checkout > uses: actions/checkout@v2 > - uses: Raku/setup-raku@v1 > with: > raku-version: ${{ matrix.raku-version }} > - name: Check zef info > run: zef info "Raku::Pod::Render" > - name: Install Dependencies > run: zef install --/test --test-depends --deps-only . > - name: Install App::Prove6 > run: zef install --/test App::Prove6 > - name: Run Tests > run: prove6 -I. t > > > As you can see, I run the zef info line for Raku::Pod::Render. I am > getting the following response (this happens after I used exactly the same > command locally) > > Run zef info "Raku::Pod::Render" > ===> Updating fez mirror: https://360.zef.pm/ > - Info for: Raku::Pod::Render > - Identity: Raku::Pod::Render:ver<3.7.3>:auth > - Recommended By: Zef::Repository::Ecosystems > - Installed: No > ===> Updated fez mirror: https://360.zef.pm/ > Description: A generic Pod6 Renderer with custom Pod::Blocks, FormatCodes > for one or more files using templates, provides HTML and MarkDown. > ===> Updating rea mirror: > https://raw.githubusercontent.com/Raku/REA/main/META.json > License: Artistic-2.0 > ===> Updated rea mirror: > https://raw.githubusercontent.com/Raku/REA/main/META.json > Source-url: > https://raw.githubusercontent.com/raku/REA/main/archive/R/Raku%3A%3APod%3A%3ARender/Raku%3A%3APod%3A%3ARender%3Aver%3C3.7.3%3E%3Aauth%3Cgithub%3Afinanalyst%3E.tar.gz > Provides: 12 modules > Support: > # source:https://github.com/finanalyst/raku-pod-render.git > # bugtracker:https://github.com/finanalyst/raku-pod-render/issues > # email:richard@hainsworth.wales > Depends: 14 items > > > Furthermore, another user raised an issue in the github repo of > Raku::Pod::Render and seems to have had the same problem installing > Raku::Pod::Render > > The Raku::Pod::Render:ver<3.7.3> has an error in it, which I fixed. But > now the Ecosystem appears to be acting inconsistently. > -- Fernando Santagata
Re: continuous testing
Hi Richard, this is a link to the GitHub official documentation: https://docs.github.com/en/actions You can also copy a configuration from another project and adapt it to your needs. For example this one installs some C libraries, some module dependencies and runs the tests: https://github.com/frithnanth/raku-Math-Libgsl-Interpolation/blob/master/.github/workflows/test.yml On Fri, Dec 31, 2021 at 5:56 PM Richard Hainsworth wrote: > Fernando, > > Thanks. > > Any link / blog / article about how to set up GitHub action up for Raku? > > Regards, > > Richard > On 31/12/2021 16:52, Fernando Santagata wrote: > > Hi Richard, > apparently Travis CI has discontinued its free open source plan. > I switched to GitHub actions; don't know what's available on other > platforms. > > On Fri, Dec 31, 2021 at 5:43 PM Richard Hainsworth > wrote: > >> I noticed that the .travis files have been removed from some >> distributions. >> >> Also a .circleci file exists in the Raku Docs repo. >> >> Is there a preferred / recommended / list of continuous testing >> environments? >> >> Is there a preferred / rapid way to handle Raku modules? >> >> Regards, >> >> Richard >> >> > > -- > Fernando Santagata > > -- Fernando Santagata
Re: continuous testing
Hi Richard, apparently Travis CI has discontinued its free open source plan. I switched to GitHub actions; don't know what's available on other platforms. On Fri, Dec 31, 2021 at 5:43 PM Richard Hainsworth wrote: > I noticed that the .travis files have been removed from some distributions. > > Also a .circleci file exists in the Raku Docs repo. > > Is there a preferred / recommended / list of continuous testing > environments? > > Is there a preferred / rapid way to handle Raku modules? > > Regards, > > Richard > > -- Fernando Santagata
Re: What're native (i.e. high-machine-performance) hybrid development options with Raku?
I can add that the NativeCall interface works exceptionally well, even allowing one to pass a Raku sub, closure, or anonymous block as a callback into a C function. For example: https://raku.land/cpan:FRITH/Spreadsheet::Libxlsxio On Wed, Sep 29, 2021 at 11:14 AM Simon Proctor wrote: > I'm sure there are people who will be able to give some more information > than me but I will say you can do worse than reading the documentation on > NativeCall. > > https://docs.raku.org/language/nativecall > > I've played about with it a bit and it really is quite simple to get > started with. Generally you can directly map to a C/C++ call and then wrap > that in a nicer interface if you want to. > > Some example modules already using it: > > https://raku.land/cpan:MARTIMM/Gnome::Gtk3 > https://raku.land/cpan:TIMOTIMO/SDL2::Raw > https://raku.land/github:JJ/SDL2 > https://raku.land/github:hartenfels/Text::Markdown::Discount > > (There's a bunch more too). > > Good luck :) > > > > On Wed, 29 Sept 2021 at 08:49, YueCompl via perl6-users < > perl6-us...@perl.org> wrote: > >> Also asked at >> https://www.reddit.com/r/rakulang/comments/pxqaxi/whats_native_ie_highmachineperformance_hybrid >> >> >> Greetings! >> >> u/raiph is really a great evangelist, months ago, he swept away my >> (wrong) assumption that Raku must be mostly old school PERL, and keep >> impressing me with fantasies already done by Raku. Recently being [compiler >> in minutes](https://www.youtube.com/watch?v=rxaB6m_sQKk). >> >> I'm considering seriously the realworld adoption of Raku in my work, so >> I'd like to ask this. >> >> My current (private) framework facilitates the writing of high >> performance tensor components in C++, those get assembled to computation >> networks with Python scripting at runtime, then run mostly in C++ code but >> occasionally call back to script code. There had been even older workflows >> with Boost, but I started with Pybind11 a few years ago, with the approach >> pretty much described in [this SO answer]( >> https://stackoverflow.com/a/50125447/6394508). >> >> As our business develops, more and more expressiveness is demanded, >> Python magic methods way of language tweaking becomes a limiting factor >> gradually. We are currently using a custom scripting language I implemented >> fresh new, atop Haskell/GHC, with script-assemblable >> high-machine-performance components writable in the `IO` and `STM` monad. I >> share many of Raku's design ideas in implementing that PL, but failed to >> discover that before u/raiph caught my attention to Raku. >> >> Apparently Raku is more mature and feature rich than my current piece, >> especially in syntax customization, that we demand heavily. >> >> But I'm not clear by far, what's the approach for Raku code with native >> parts get developed with good ergonomics? >> >> The native parts is not expected to be C/C++, but some PL with moderate >> raw machine performance, and ergonomics is very important, so manual memory >> management is a deal breaker for us. For example, Go's machine performance >> is acceptable by us, but Rust is not due to memory management burden (even >> though much more principled than C). >> >> The scripting part cries for flexibility and clean-ness in >> syntax/semantics, toward purity of business concerns, ideally no computer >> implementation concerns should surface to the scripting grammar, machine >> performance in scripting is not sensitive at all, since it is just to build >> one variant of the business program, the "real" run of the program should >> mostly consist of compiled native code. Though calling script parts back, >> meanwhile the high-performance run, is also desirable in a small number of >> scenarios. >> >> That said but Julia's approach - LLVM based JIT from scripting, is not >> affordable by us, we have no expertise in machine code generation, even the >> simpler IR manipulation. >> >> Also debuggability in the native code part is crucial, C++ served us well >> in this regard, VSCode etc. can attach to a Python process and set >> breakpoints on the C++ code, then step through the suspicious code path. >> >> Haskell is far from on par w.r.t. stepping debuggers, but bugs are >> interestingly less with it, for unutterable reasons. >> >> Best regards, >> Compl >> >> > > -- > Simon Proctor > Cognoscite aliquid novum cotidie > > http://www.khanate.co.uk/ > -- Fernando Santagata
Re: (sigils are awesome, they say ...) Re: pairs of separators from a string
On Sun, Aug 22, 2021 at 2:58 PM Marc Chantreux wrote: > so of course i tried > > my (@a, @b) = { .[0,2…∞], .[1,3…∞] }.(q.comb); > > because i have two lists and two containers. this doesn't work. > which means @ and $ combines with = to define how things are stored > but i don't understand how for the moment. > Try: > my (@a, @b) := { .[0,2…∞], .[1,3…∞] }.(q.comb);say @a;say @b (A B C D) (A B C D) In this case the binding operator ':=' makes the difference. When one uses the assignment operator '=', the right side value is interpreted as an array of two elements, each one is a list of four elements: [(A B C D) (A B C D)]. When one binds, each array is bound to one list. -- Fernando Santagata
Re: How do a pe-salt an array inside an object?
Hi, for your last question, let's use again what Norman showed you earlier: > class AA { has Str @.I is rw } (AA) > my $CC = AA.new(I => [Str, Str, 'two', Str, 'four']) AA.new(I => Array[Str].new(Str, Str, "two", Str, "four")) > say $CC.I[0] (Str) > say $CC.I[2] two > say $CC.I[4] four In this case undefined values are initialized by their own base class. Since @.I was declared as a Str array, then Norman used the base class 'Str' as initialization value. On Tue, Jul 6, 2021 at 10:42 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > >> On Tue, Jul 6, 2021 at 9:39 AM ToddAndMargo via perl6-users > >> I am confused. > >> > >> What I am after it pre-salting $CC.I with > >> $CC.[0] = "abc" > >> $CC.[1] = "def" > >> > >> with the ".new" functions when I create $CC > >> > >> -T > > On 7/6/21 12:52 AM, Fernando Santagata wrote: > > Hello, > > > > I think that that was exactly what Norman was trying to show. Probably > > you've been mislead by the first value they assigned in their example: > > > > my $CC = AA.new( I => [Str,"abc"] ); > > > > > > Here the 'Str' is the "empty" or "undefined" value, since the array was > > declared as a Str array. > > > > Try this: > > > > > class AA { has Str @.I is rw } > > (AA) > > > my $aa = AA.new: I => ['a','b'] > > AA.new(I => Array[Str].new("a", "b")) > > > say $aa.I[0] > > a > > > say $aa.I[1] > > b > > > > or this > > > > > my $bb = AA.new: I => 'a' > > AA.new(I => Array[Str].new("a")) > > > $bb.I[0] > > a > > > > Hi Fernando, > > Thank you! Now I understand the syntax better. > > $ p6 'class AA { has Str @.I is rw; }; >my $CC = AA.new( I => ["abc","def"] ); >say $CC.I[1];' > def > > > Follow up question. Since Raku allows me to assign > elements to an array in non sequential order: > > $ p6 'my @x; @x[4]=44; say @x;' > [(Any) (Any) (Any) (Any) 44] > > How to I modify > my $CC = AA.new( I => ["abc","def"] ); > such that I can place values in non sequential order? > > For example, I wanted to pre-salt > $CC.I[4] = "four" > $CC.I[2] = "two" > > Many thanks, > -T > > > > > -- Fernando Santagata
Re: How do a pe-salt an array inside an object?
Hello, I think that that was exactly what Norman was trying to show. Probably you've been mislead by the first value they assigned in their example: my $CC = AA.new( I => [Str,"abc"] ); > Here the 'Str' is the "empty" or "undefined" value, since the array was declared as a Str array. Try this: > class AA { has Str @.I is rw } (AA) > my $aa = AA.new: I => ['a','b'] AA.new(I => Array[Str].new("a", "b")) > say $aa.I[0] a > say $aa.I[1] b or this > my $bb = AA.new: I => 'a' AA.new(I => Array[Str].new("a")) > $bb.I[0] a On Tue, Jul 6, 2021 at 9:39 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > >> On Tue, 6 Jul 2021 at 10:55, ToddAndMargo via perl6-users > >> mailto:perl6-us...@perl.org>> wrote: > >> > >> Hi All, > >> > >> On creation, I would like to salt some of the > >> values inside an object when the variable > >> inside is an array: > >> > >> > >> First a concept test: > >> $ p6 'class AA { has Str @.I is rw; }; my $CC= AA.new; $CC.I[1] = > >> "def"; > >> say $CC.I[1];' > >> > >> def > >> > >> > >> Now for the pre-salt test > >> $ p6 'class AA { has Str @.I is rw; }; my $CC = AA.new( I[1] => > >> "abc" ); > >> say $CC.I[1];' > >> > >> ===SORRY!=== Error while compiling -e > >> Undeclared name: > >> I used at line 1 > >> > >> > >> What am I doing wrong? > >> > >> Many thanks, > >> -T > > On 7/5/21 10:45 PM, Norman Gaywood wrote: > > $ raku > > Welcome to 퐑퐚퐤퐮퐝퐨™ v2021.06. > > Implementing the 퐑퐚퐤퐮™ programming language v6.d. > > Built on MoarVM version 2021.06. > > > > To exit type 'exit' or '^D' > > > class AA { has Str @.I is rw; }; > > (AA) > > > my $CC = AA.new( I => [Str,"abc"] ); > > AA.new(I => Array[Str].new(Str, "abc")) > > > say $CC.I; > > [(Str) abc] > > > say $CC.I[1]; > > abc > > > $CC.I[0] = "zyz"; > > zyz > > > say $CC.I; > > [zyz abc] > > > > > > > Hi Norman, > > I am confused. > > What I am after it pre-salting $CC.I with > $CC.[0] = "abc" > $CC.[1] = "def" > > with the ".new" functions when I create $CC > > -T > > -- Fernando Santagata
Re: File::Find using a junction with exclude
It can be done without the EVAL: > any('a', 'b', 'c').raku.substr(4, *-1).split(',').elems 3 On Mon, May 24, 2021 at 1:07 PM Daniel Sockwell wrote: > > But .EVAL is evil, right? > > Indeed! And > any('a', 'b', 'c').raku.substr(3).EVAL.elems; > arguably deserves _extra_ evil points for using the .EVAL method which, > unlike the > EVAL sub, doesn't even warn about how dangerous it is (even though it > probably should). > -- Fernando Santagata
Re: Correct enum incantation?
On Wed, May 5, 2021 at 6:00 PM William Michels via perl6-users < perl6-us...@perl.org> wrote: > Hello, > > I've been reading over an interesting Answer on StackOverflow by wamba: > > https://stackoverflow.com/a/67324175/7270649 > > I started trying to explore enums on my own and quickly realized that > method calls on enums are different from simple key/value pairs. For enums, > calling a `.key` or `.value` or `.kv` method won't work. Instead one must > use something like `.^enum_values` or `.^enum_value_list`. > Probably you need the new and shiny compiler ;) > $*RAKU.compiler.version v2021.04 > Month.keys (oct dec aug jun mar apr feb nov jul may sep jan) > Month.values (11 6 9 2 5 7 3 12 8 4 10 1) > .say for Month.kv nov 11 jul 7 sep 9 jan 1 oct 10 mar 3 jun 6 apr 4 aug 8 dec 12 feb 2 may 5 -- Fernando Santagata
Re: Comparing Int and Num
Hi, I see in the include file that mpz_t is defined as follow: typedef __mpz_struct mpz_t[1]; and in turn __mpz_struct is: typedef struct { int _mp_alloc; int _mp_size; mp_limb_t *_mp_d; } __mpz_struct; with mp_lib_t defined in three different ways, according to the value of a macro, defined at compile time. I wrote a C program which outputs the value of sizeof(mp_limb_t). In my case (Ubuntu Linux) that value is 8, so mp_limb_t definition is: typedef unsigned long int mp_limb_t; On the Raku side, the mpz_t definition would be: class mpz_t is repr('CStruct') is export { has int32 _mp_alloc; has int32 _mp_size; has CArray[uint64] _mp_d; } I don't know the library at all, so I guessed that _mp_d would be an array. If it's more useful to consider it just a pointer, declare it as Pointer[uint64]. As you can see it's very easy and intuitive. The documentation ( https://docs.raku.org/language/nativecall) is very useful. If you need more examples, look at the code of some of the modules that use the NativeCall interface (https://modules.raku.org/t/NATIVECALL). I've been using the NativeCall interface in many modules, see for example this interface to the interpolation section of the GNU Scientific Library https://github.com/frithnanth/raku-Math-Libgsl-Interpolation/blob/master/lib/Math/Libgsl/Raw/Interpolation.rakumod On Sun, May 2, 2021 at 1:30 PM sisyphus wrote: > On Wed, Apr 28, 2021 at 5:38 PM Fernando Santagata < > nando.santag...@gmail.com> wrote: > >> , >> If you've found the Perl XS interface easy to work with, give Raku's >> NativeCall a try, you will find it amazing. Since you already know the C >> libraries, I guess you can cook an interface in no time. >> >> > Thanks for the pointer, Fernando. > I did take a look at "NativeCall". > The basics are pretty straightforward, and worked well enough on my > Windows 7 box: > > ### > use NativeCall; > sub mpfr_get_default_prec() returns int32 is native('libmpfr-6') { * } > say "# ", mpfr_get_default_prec(); > > sub __gmpf_get_default_prec() returns int32 is native('libgmp-10') { * } > say "# ", __gmpf_get_default_prec(); > > # Correctly outputs: > # 53 > # 64 > ### > > The tricky bit is that nearly all of the gmp library functions want to > take either an mpz_t, mpq_t, mpn_t or mpf_t argument, but NativeCall knows > nothing about these types. > Similarly most of the mpfr library functions take an mpfr_t argument, > which is also a type that's unknown to NativeCall. > > I guess it might be achievable via passing pointers and/or structs, both > of which are documented in the NativeCall docs. > However, I haven't knuckled down to working my way through it - and I'm > not even sure that it's do-able. > > It would be much easier (and much more likely to happen ;-) if there was > some publicly available demo code to light the way to accessing the gmp (or > mpfr) library functions using raku's NativeCall capacity. > > Cheers, > Rob > -- Fernando Santagata
Re: Comparing Int and Num
Hi, If you've found the Perl XS interface easy to work with, give Raku's NativeCall a try, you will find it amazing. Since you already know the C libraries, I guess you can cook an interface in no time. On Wed, Apr 28, 2021 at 7:09 AM sisyphus wrote: > > > On Tue, Apr 27, 2021 at 12:23 AM sisyphus wrote: > > >> (I guess I could just use Inline::Perl5 ... not exactly my preferred >> option ... but a viable alternative, I would think.) >> >> > The following sort of works, but not in a very meaningful way. > All it really does is show that perl is seeing the 3 raku variables ($n, > $r1 and $r2) as being a 53-bit (double precision) representation of 0.1. > > use Math::GMPq:from ":mpq"; > > -- > my $n = 1e-1; > say "# ", Rmpq_get_str(Math::GMPq::new($n), 10); > > my Rat $r1 = 0.1; > say "# ", Rmpq_get_str(Math::GMPq::new($r1), 10); > > my Rat $r2 = 1/10; > ; > say "# ", Rmpq_get_str(Math::GMPq::new($r2), 10); > > # Wanted: > # 3602879701896397/36028797018963968 > # 1/10 > # 1/10 > > # Got: > # 3602879701896397/36028797018963968 > # 3602879701896397/36028797018963968 > # 3602879701896397/36028797018963968 > > =finish > use Devel::Peek:from; > # Shows that perl sees $n, $r1, and $r2 > # as being the double 0.1: > Devel::Peek::Dump($n); > Devel::Peek::Dump($r1); > Devel::Peek::Dump($r2); > > -- > > Cheers, > Rob > -- Fernando Santagata
Re: 'CALL-ME' Math problem?
On Tue, Mar 2, 2021 at 4:08 PM Matthew Stuckwisch wrote: > But why do that when you can add a CALL-ME to the number classes that does > multiplication? > > Int.^add_fallback( > {$^i.defined && $^m eq 'CALL-ME'}, > -> $, $ { * * * } > ); > > say 5(4); # 20 > say 5(5)² # 625… oops! but say 5(5²) # 125 ok > On Tue, Mar 2, 2021, 09:08 Daniel Sockwell > wrote: > >> Kevin Pye wrote: >> > Just because mathematics allows an implied multiplication doesn't mean >> Raku does -- in fact I can't >> > think of any programming language which does. >> >> As a (potentially) interesting side note, while Raku doesn't provide >> implied multiplication, it _is_ >> one of the few programming languages that would let you implement >> something very similar yourself: >>sub infix:«\c[INVISIBLE TIMES]» { $^a × $^b } >> >> This would let you write `say 60÷5(7−5)` (with an invisible character >> between the `5` and the `(` ) >> and get the expected result. >> >> Doing so would, of course, be a very bad idea. But still, you _could_. >> >> Source: >> >> https://perl6advent.wordpress.com/2017/12/01/the-grinch-of-perl-6-a-practical-guide-to-ruining-christmas/ >> > -- Fernando Santagata
Re: A nextsame question
Thank you Vadim, your explanation makes a lot of sense! On Tue, Jan 19, 2021 at 5:23 PM Vadim Belman wrote: > Hello, > > By "never returns" it's not meant that nextsame redispatches to the next > sub and skips the current stack frame. It only means that no statements > following nextsame will be executed. It's the same semantics as with > return. So, the best way to consider nextsame would be to think of it as of > 'return next-candidate(...)'. > > I would say that this is the semantics which cares about the caller. If > you put yourself in the shoes of your code user, imagine that you > introspect the multi in question with 'cando' which gives you the candidate > returning a List. It'd be very confusing to get an Int instead! > > Aside of this, the practice of returning so different values for rather > similar arguments doesn't look good for me. > > Best regards, > Vadim Belman > > On Jan 19, 2021, at 11:07 AM, Fernando Santagata < > nando.santag...@gmail.com> wrote: > > Hello, > I'm trying to understand how nextsame works. > > Apparently I started from the wrong assumptions: I thought that once the > first matched sub in the chain called nextsame, the arguments were matched > against the following subs regardless of the return value. > It seems that while the return value is not taken in account during the > match process, it is checked once the sub return its value and it generates > an error if the two candidates in the chain have different return types. > > The documentation ( > https://docs.raku.org/language/functions#index-entry-dispatch_nextsame) > reads: > > nextsame calls the next matching candidate with the same arguments that >> were used for the current candidate and never returns. >> > > and doesn't mention the return value. > > proto test(Str $a, |) {*} > multi test($a, Str $b --> List) { > nextsame if $b ~~ /\d+/; # if the second string contains a number > return $a, $b > } > multi test($a, Int() $b --> Int) { return $b } # coerces the second > argument to Int > > say test('hello', 1); # output: 1 > say test('hello', 'goodbye'); # output: (hello goodbye) > say test('hello', '1'); # error: Type check failed for return > value; expected List but got Int (1) > > Here I expected that in the third call, after the first multi matched, the > nextsame triggered a match on the second multi, regardless of the return > value. Instead apparently the match is triggered, but then the return value > of the first multi (List) is expected from the second multi (which returns > an Int). > > I don't know if this is the desired behavior; if so probably it deserves > to be documented. > > -- > Fernando Santagata > > > -- Fernando Santagata
A nextsame question
Hello, I'm trying to understand how nextsame works. Apparently I started from the wrong assumptions: I thought that once the first matched sub in the chain called nextsame, the arguments were matched against the following subs regardless of the return value. It seems that while the return value is not taken in account during the match process, it is checked once the sub return its value and it generates an error if the two candidates in the chain have different return types. The documentation ( https://docs.raku.org/language/functions#index-entry-dispatch_nextsame) reads: nextsame calls the next matching candidate with the same arguments that > were used for the current candidate and never returns. > and doesn't mention the return value. proto test(Str $a, |) {*} multi test($a, Str $b --> List) { nextsame if $b ~~ /\d+/; # if the second string contains a number return $a, $b } multi test($a, Int() $b --> Int) { return $b } # coerces the second argument to Int say test('hello', 1); # output: 1 say test('hello', 'goodbye'); # output: (hello goodbye) say test('hello', '1'); # error: Type check failed for return value; expected List but got Int (1) Here I expected that in the third call, after the first multi matched, the nextsame triggered a match on the second multi, regardless of the return value. Instead apparently the match is triggered, but then the return value of the first multi (List) is expected from the second multi (which returns an Int). I don't know if this is the desired behavior; if so probably it deserves to be documented. -- Fernando Santagata
Re: Nativecall - Callee filled static character array - CArray [repost]
Hello, Maybe the behavior you're seeing is related to this bug: https://github.com/rakudo/rakudo/issues/3633 For what I was concerned, Raku 2020.10 solved the problem, but since the issue was reopened right after I closed it, I imagine the problem is still lingering. Perhaps you can add some remarks to that issue; your example code might help to clarify the problem. On Mon, Jan 4, 2021 at 2:41 AM Paul Procacci wrote: > This is a repost from an improperly worded email. > That previous email thread divulged into things it shouldn't have to which > I'm partially to blame. > This isn't Windows specific - the problem occurs across platforms. > > This is simply about the proper way to define an *inline* array of items > in a Raku CStruct definition. It's also about the retrieval of those > stored values. > The type of items aren't relevant. char[n], int[n], int16[n], etc ... it > doesn't matter one bit. > > Given the following C structure: > > typedef struct T { >> char a[260]; >> int32_t b; >> } T; >> > > and given the following C function body: > > void setTest(T *t){ >> (void)memset(t->a, 'T', 260); >> t->b = 1; >> } >> > > I presumed this would be defined as follows in Raku[1]: > > class T is repr('CStruct') { >> HAS int8 @.a[260] is CArray; >> has int32 $.b; >> }; >> >> sub setTest(T) is native('./test.so') { * }; >> > > and invoked as such: > > my T $t .= new; >> setTest($t); >> > > While the value of the member 'b' gets set to 1 as expected, I cannot > inspect the values that should be stored at the memory location referenced > by member 'a[0]..a[n]'. > > Conversely, the following C program snippet that utilizes the same C > function provides the output one would expect: > > extern void setTest(T *); >> >> T t; >> >> int main(void) >> { >> setTest(); >> printf("%c\n%d\n", t.a[0], t.b); >> _exit(0); >> } >> > > So the questions are: > > 1) How does one define an *inline* array of whatever size in Raku (size > doesn't matter) > 2) How does one retrieve the values stored in that defined array after the > callee populates it. > > Thanks, > ~Paul > > [1] - test.so is the shared object that I created for testing. > -- > __ > > :(){ :|:& };: > -- Fernando Santagata
Re: Nativecall - Help with converting wchar_t CArray to something printable
; >> my uint32 $CStrElems = $CStr.elems; >> # say $CStrElems; >> >> loop (my $i = 0; $i < $CStrElems - 2 ; $i += 2) { >> if $CStr[ $i ] == 0 && $CStr[ $i + 1 ] == 0 { last; } >> >>if $i == $CStrElems - 4 { >> $Msg = "$SubName ERROR:" ~ " C Strings are required to be >> terminated with a nul\n\n" ~ >> " Returning an empty string\n" ~ >> " Cowardly existing\n"; >> exit; >>} >> >># print $CStr[ $i ] ~ "," ~ $CStr[ $i + 1 ] ~ ", "; >>$RakuStr ~= chr( $CStr[ $i ] ); >> } >> # say ""; >> >> # say "$RakuStr"; >> return $RakuStr; >> } >> >> >> > > -- > __ > > :(){ :|:& };: > -- Fernando Santagata
Re: spurt and array question
Oh, now I see: you were asking that question in another thread. <<>> is equivalent to qq:ww:v as mentioned here: https://docs.raku.org/syntax/%3C%3C%20%3E%3E#index-entry-%3Aval_%28quoting_adverb%29 and as stated here: https://docs.raku.org/language/quoting the adverb :ww splits the string into words using whitespace characters as separators. Now, being "\n" a whitespace character, your string <> was split in three parts ("aaa", "bbb", "ccc") with no whitespace characters in them. On Sun, Nov 15, 2020 at 12:25 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-11-14 13:39, Fernando Santagata wrote: > > What do you mean by putting the \n in the variable? > > $ p6 'my @x = <>; for @x {"$_".print};' > aaabbbccc > > Why are the \n's not being resolved in the above? > > Why do I have to add an \n to the print line? > > $ p6 'my @x = <>; for @x {"$_\n".print};' > aaa > bbb > ccc > > Oh I see, because they are not actually in the cell: > > $ p6 'my @x = <>; dd @x' > Array @x = ["aaa", "bbb", "ccc"] > -- Fernando Santagata
Re: spurt and array question
On Sat, Nov 14, 2020 at 9:02 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > > Maybe this is what you want: > > > > my @a = 1,2,3; > > spurt('test', @a.join("\n") ~ "\n"); # join doesn't add the last "\n" > > > > Or the equivalent > > > > 'test'.IO.spurt: @a.join("\n") ~ "\n"; > > That is the way around the issue. > > But my question is why can I not put the \n in the variable? > What do you mean by putting the \n in the variable? Is it anything like this? [¹] my @a = "1\n", "2\n", "3\n"; 'test'.IO.spurt(@a); or this? my @a = ; 'test'.IO.spurt(@a »~» "\n"); [¹] Mind that the array is first converted into a string and its elements are joined together with an interleaving space -- Fernando Santagata
Re: spurt and array question
On Sat, Nov 14, 2020 at 8:07 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-11-14 06:00, Brad Gilbert wrote: > > The purpose of `spurt` is to: > > 1. open a NEW file to write to > > 2. print a single string > > 3. close the file > > > > If you are calling `spurt` more than once on a given file, you are doing > > it wrong. > > You are forgetting that spurt comes with an `:append` option. > Maybe this is what you want: my @a = 1,2,3; spurt('test', @a.join("\n") ~ "\n"); # join doesn't add the last "\n" Or the equivalent 'test'.IO.spurt: @a.join("\n") ~ "\n"; -- Fernando Santagata
Re: New type Stash for Block is not a mixin type
It seems that Rakudo 2020.09 solved the regression problem! On Sat, Sep 26, 2020 at 10:01 AM Fernando Santagata < nando.santag...@gmail.com> wrote: > Thank you, I'll see if I can concoct a self-contained example in order to > open an issue. > > On Thu, Sep 24, 2020, 20:13 Elizabeth Mattijsen wrote: > >> Feels like a regression worthy of a Rakudo issue >> >> > On 24 Sep 2020, at 20:26, Fernando Santagata >> wrote: >> > >> > Hello, >> > >> > Since I upgraded to the last Rakudo I'am having a weird problem. I have >> a module like this: >> > >> > unit class Class1; >> > etc. >> > >> > Then a second module: >> > >> > unit class Class2; >> > use Class1; >> > etc. >> > >> > In a program I need both modules, so it begins with two lines: >> > >> > use Class1; >> > use Class2; >> > etc. >> > >> > At this point if I run the program I get this error: >> > >> > New type Stash for Block is not a mixin type >> > >> > pointing to the line of code that uses Class2. If I remove the "use >> Class1" line, that program works fine. >> > But it bugs me, because I don't understand that behavior. >> > >> > Any hint? >> > The whole thing worked fine using version 2020.07. >> > >> > -- >> > Fernando Santagata >> > -- Fernando Santagata
Re: New type Stash for Block is not a mixin type
Thank you, I'll see if I can concoct a self-contained example in order to open an issue. On Thu, Sep 24, 2020, 20:13 Elizabeth Mattijsen wrote: > Feels like a regression worthy of a Rakudo issue > > > On 24 Sep 2020, at 20:26, Fernando Santagata > wrote: > > > > Hello, > > > > Since I upgraded to the last Rakudo I'am having a weird problem. I have > a module like this: > > > > unit class Class1; > > etc. > > > > Then a second module: > > > > unit class Class2; > > use Class1; > > etc. > > > > In a program I need both modules, so it begins with two lines: > > > > use Class1; > > use Class2; > > etc. > > > > At this point if I run the program I get this error: > > > > New type Stash for Block is not a mixin type > > > > pointing to the line of code that uses Class2. If I remove the "use > Class1" line, that program works fine. > > But it bugs me, because I don't understand that behavior. > > > > Any hint? > > The whole thing worked fine using version 2020.07. > > > > -- > > Fernando Santagata >
New type Stash for Block is not a mixin type
Hello, Since I upgraded to the last Rakudo I'am having a weird problem. I have a module like this: unit class Class1; etc. Then a second module: unit class Class2; use Class1; etc. In a program I need both modules, so it begins with two lines: use Class1; use Class2; etc. At this point if I run the program I get this error: New type Stash for Block is not a mixin type pointing to the line of code that uses Class2. If I remove the "use Class1" line, that program works fine. But it bugs me, because I don't understand that behavior. Any hint? The whole thing worked fine using version 2020.07. -- Fernando Santagata
Re: pod6 and markdown
Thank you both for your replies! On Wed, Sep 2, 2020 at 9:49 AM Richard Hainsworth wrote: > The raku compiler allows for what you want. It is the Pod render module > that has to do this work. SO > > I've just re-written Pod::To::HTML. It's in Raku::Pod::Render (Note the > Raku at the beginning, I also wrote another module with almost the same > name that doesn't do this). > > The legacy Pod::To::HTML (which is Pod::To::HTML:auth ) > does all of the HTML rendering hardcoded. Essentially, I took out all > the output-specific and put it into templates. > > So, now you can put something like '=Figure' (or '=MyWonderfulBlock') > into your pod6 file, and define a template as 'figure' (or > 'mywonderfulblock') with custom output formating, eg. ' width="100px">') and it will work. > > Also, you can create your own Format Codes, so F could > be made to embed font-awesome icons into pod6 files. > > Also, the Raku::Pod::Render distribution has a GUI tool called > Extractor.raku that will take any pm6 file and extract the Pod6 and > format it into README.md or .html files. > > Sorry for shameless ad > > On 02/09/2020 03:02, Vadim Belman wrote: > > Unfortunately, neither rendered constraints nor image insertions are > implemented yet. Or it is so up to my knowledge, at least. I miss these > features too sometimes. > > > > Best regards, > > Vadim Belman > > > >> On Aug 31, 2020, at 6:56 AM, Fernando Santagata < > nando.santag...@gmail.com> wrote: > >> > >> Hello *, > >> > >> I was wondering whether there's a way to tell that a section of pod6 > should be rendered only by a specific renderer. > >> > >> My problem is that I want to show a figure in a README.md and I'm using > App::MI6, which builds the README.md file from the pod6 documentation in > the module file. > >> > >> As far as I can tell, there's no specific pod6 formatter for a figure; > so far I 've beeninserting raw markdown lines in the pod6 documentation, > such as "![description](file.svg)", but it's ugly and it would show when > other renderers will be used on the same pod6 file. > >> > >> Is there a way to restrict some text to just one renderer, or to insert > a figure or picture in a pod6 file? > >> > >> -- > >> Fernando Santagata > -- Fernando Santagata
pod6 and markdown
Hello *, I was wondering whether there's a way to tell that a section of pod6 should be rendered only by a specific renderer. My problem is that I want to show a figure in a README.md and I'm using App::MI6, which builds the README.md file from the pod6 documentation in the module file. As far as I can tell, there's no specific pod6 formatter for a figure; so far I 've beeninserting raw markdown lines in the pod6 documentation, such as "![description](file.svg)", but it's ugly and it would show when other renderers will be used on the same pod6 file. Is there a way to restrict some text to just one renderer, or to insert a figure or picture in a pod6 file? -- Fernando Santagata
Re: zef: too many files in ~/.raku/short
Hi Timo, Thanks for your reply. I solved the problem cleaning the directory and reinstalling all the modules. In the future I will keep the thing monitored, so should it happen again I'll be able to dig deeper into it. On Sat, Aug 8, 2020, 19:16 Timo Paulssen wrote: > Hi Fernando, > > do you happen to have the exact error message? The simplest search through > the zef source didn't find anything related, so perhaps it was actually > "too many open files" caused by a too-low limit on open file descriptors? > > `ulimit -a` on my system gives me `Maximum number of open file descriptors > (-n) 1048576` because i have set it to "a very high value" at some point in > the past in /etc/security/limits.conf, but some systems have it at an > obnoxiously low number. > > Obviously we don't want zef to open billions of file descriptors just to > go through a directory or something, so tracking that down further could be > interesting if that is the case. > > HTH > - Timo > On 01/08/2020 22:46, Fernando Santagata wrote: > > Hello, > > I found out that on my system at a certain point zef was unable to read > the content of ~/.raku/short and because of that to install any other > module. > According to zef there were too many files in that directory and indeed > there were a lot of subdirectories. > > I don't know what happened, because I try to keep my installation lean and > I uninstall old versions of all the modules that I update. > > Is it possible that zef failed to update that directory content when, I > don't know, a module fails to install or something like that, leaving > behind unused directories? > Has that happened to anyone else? > > -- > Fernando Santagata > >
Re: zef: too many files in ~/.raku/short
Also regarding zef, I noticed that ~/.zef/store stores a "git clone" of all the previous versions of every installed module, even when one explicitly uninstalls the old versions of them. Is there a zef command that I'm unaware of to clean up that directory? On Sat, Aug 1, 2020 at 10:46 PM Fernando Santagata < nando.santag...@gmail.com> wrote: > Hello, > > I found out that on my system at a certain point zef was unable to read > the content of ~/.raku/short and because of that to install any other > module. > According to zef there were too many files in that directory and indeed > there were a lot of subdirectories. > > I don't know what happened, because I try to keep my installation lean and > I uninstall old versions of all the modules that I update. > > Is it possible that zef failed to update that directory content when, I > don't know, a module fails to install or something like that, leaving > behind unused directories? > Has that happened to anyone else? > > -- > Fernando Santagata > -- Fernando Santagata
zef: too many files in ~/.raku/short
Hello, I found out that on my system at a certain point zef was unable to read the content of ~/.raku/short and because of that to install any other module. According to zef there were too many files in that directory and indeed there were a lot of subdirectories. I don't know what happened, because I try to keep my installation lean and I uninstall old versions of all the modules that I update. Is it possible that zef failed to update that directory content when, I don't know, a module fails to install or something like that, leaving behind unused directories? Has that happened to anyone else? -- Fernando Santagata
DBIish tries to hijack NativeLibs?
Hello, I was trying to reinstall NativeLibs when I noticed this: $ zef install --force-install --/test NativeLibs ===> Searching for: NativeLibs ===> Updating cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json ===> Updating p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json ===> Updated p6c mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/p6c1.json ===> Updated cpan mirror: https://raw.githubusercontent.com/ugexe/Perl6-ecosystems/master/cpan1.json ===> Installing: DBIish:ver<0.6.1> ^^ Why does zef try to install DBIish instead? This works fine, the only difference is that I'm specifying the module's version: zef install --force-install --/test 'NativeLibs:ver<0.0.7>' Any explanation for this unusual behavior? (BTW, right now DBIish fails to install, but I guess you know, since the test on Travis-CI fails.) -- Fernando Santagata
Re: Baby steps to create a dataframe structure
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 :-) 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 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
Re: Baby steps to create a dataframe structure
Here https://www.gnu.org/software/gsl/ I see this note: The bottom line for commercial users: > GSL can be used internally ("in-house") without restriction, but only > redistributed in other software that is under the GNU GPL. > So yes, the license restricts the use to GNU GPL software; no other restriction that I noticed. On Wed, Jul 22, 2020 at 2:03 PM Tom Browder wrote: > On Wed, Jul 22, 2020 at 06:51 JJ Merelo wrote: > >> The Raku wrapper for GSL is ready, specifically all matrix operations, >> check it out. It's extremely fast, and could be the foundation for these >> data frames. >> > > Depending on your use of the GSL, as I recall the license restricts > commercial use. > > Best regards, > > -Tom > -- Fernando Santagata
Re: perl streaming framework
…or maybe something like Pandas https://pandas.pydata.org/ ? BTW, it would be nice to build something like that for Raku. (Shameless plug: I'm working on a Raku interface to the GNU Scientific Library (see: https://modules.raku.org/search/?q=Math%3A%3ALibgsl). The next modules in my queue are all about statistics, so it might be easy to build a framework like Pandas using those) On Tue, Jul 14, 2020 at 10:01 AM 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 > . > -- Fernando Santagata
Re: proto and multi
On Mon, Jun 29, 2020 at 8:22 PM Richard Hainsworth wrote: > a) I don't understand why the white space matters, but clearly it does. So > the token is '{*}' and not braces around a Whatever-star. > For an explanation see the thread "Playing with protos and phasers" that I started here three days ago. b) Removing the space yields the following response. > in string > Cannot resolve caller handle(NewClass:D: List:D); none of these signatures > match: > (NewClass: Str $s, *%_) > (NewClass: Positional @s, *%_) > in method handle at test.raku line 15 > in block at test.raku line 30 > > Not sure why the List:D is not being matched to Positional. Is the List:D > refering to the |c signature capture ?? > > Since 'in string' was printed, one of the methods was reached. Confused. > > c) Writing out all the code in each method is what I already have. But I'm > looking for ways to factor out common code. > > Regards > On 29/06/2020 18:44, Fernando Santagata wrote: > > After deleting the spaces as suggested, there's a "Positional" too many. > I guess you can rewrite that method declaration as > > multi method handle(@s) > > or > > multi method handle(Positional $s) > > and adjust the method's body. > > On Mon, Jun 29, 2020 at 7:37 PM yary wrote: > >> It looks like you have spaces in the token { * } can you try it without, >> using this {*} instead? >> >> On Mon, Jun 29, 2020, 1:29 PM Richard Hainsworth >> wrote: >> >>> I have several multi methods. >>> >>> All of them have the same first statement, then differ depending on the >>> signature. >>> >>> proto seems to be a way to factor out the common statement, and there is >>> a phrase in the Documentation that * can affect the dispatch, viz: >>> >>> "You can give the proto a function body, and place the {*} where you >>> want the dispatch to be done. This can be useful when you have a "hole" in >>> your routine that gives it different behavior depending on the arguments >>> given:" >>> >>> The docs give and example proto, but unfortunately, not how this works >>> with other multi's. >>> >>> So I tried this: >>> >>> class NewClass { >>> has $.debug is rw = False; >>> has $.value is rw = 'Initial value'; >>> >>> proto method handle( |c ) { >>> note "value is $.value" if $.debug; >>> { * }} >>> multi method handle(Str $s) { >>> $.value = $s; >>> say 'in string'} >>> multi method handle(Positional @s) { >>> $.value = @s[0]; >>> say 'in positional'} >>> } >>> my NewClass $x .= new; >>> $x.handle('hello world');$x.handle();$x.debug = >>> True;$x.handle('hello world');$x.handle(); >>> >>> #raku test.raku >>> #value is Initial value >>> #value is Initial value >>> >>> I am wondering how to use proto and {*} >>> >>> > > -- > Fernando Santagata > > -- Fernando Santagata
Re: proto and multi
After deleting the spaces as suggested, there's a "Positional" too many. I guess you can rewrite that method declaration as multi method handle(@s) or multi method handle(Positional $s) and adjust the method's body. On Mon, Jun 29, 2020 at 7:37 PM yary wrote: > It looks like you have spaces in the token { * } can you try it without, > using this {*} instead? > > On Mon, Jun 29, 2020, 1:29 PM Richard Hainsworth > wrote: > >> I have several multi methods. >> >> All of them have the same first statement, then differ depending on the >> signature. >> >> proto seems to be a way to factor out the common statement, and there is >> a phrase in the Documentation that * can affect the dispatch, viz: >> >> "You can give the proto a function body, and place the {*} where you >> want the dispatch to be done. This can be useful when you have a "hole" in >> your routine that gives it different behavior depending on the arguments >> given:" >> >> The docs give and example proto, but unfortunately, not how this works >> with other multi's. >> >> So I tried this: >> >> class NewClass { >> has $.debug is rw = False; >> has $.value is rw = 'Initial value'; >> >> proto method handle( |c ) { >> note "value is $.value" if $.debug; >> { * }} >> multi method handle(Str $s) { >> $.value = $s; >> say 'in string'} >> multi method handle(Positional @s) { >> $.value = @s[0]; >> say 'in positional'} >> } >> my NewClass $x .= new; >> $x.handle('hello world');$x.handle();$x.debug = >> True;$x.handle('hello world');$x.handle(); >> >> #raku test.raku >> #value is Initial value >> #value is Initial value >> >> I am wondering how to use proto and {*} >> >> -- Fernando Santagata
Re: Playing with protos and phasers
On Thu, Jun 25, 2020 at 8:10 PM Brad Gilbert wrote: > {*} is specially handled by the compiler as a term. > Thank you! I guess that handling is peculiar to proto, and maybe it's worth documenting it. -- Fernando Santagata
Playing with protos and phasers
Hi *, I was trying to see if one can delegate phasers to a proto, like this: proto sub foo(|) { ENTER { say 'In' } LEAVE { say 'Out' } {*} } multi sub foo(Int $a) { $a } multi sub foo(Str $a) { $a } say foo(1); say foo('hello'); Yes indeed, it outputs: In Out 1 In Out hello But at first it didn't work, because I added a space on both sides of the '*': proto sub foo(|) { ENTER { say 'In' } LEAVE { say 'Out' } { * } } It outputs: In Out * In Out * If I add a return: proto sub foo(|) { ENTER { say 'In' } LEAVE { say 'Out' } return { * } } it outputs: In Out -> ;; $_? is raw = OUTER::<$_> { #`(Block|94038346387904) ... } In Out -> ;; $_? is raw = OUTER::<$_> { #`(Block|94038346388120) ... } Why are spaces significant in this case? If this behavior is intentional, can this be a trap worth being documented? -- Fernando Santagata
Re: I need help finding a class for a method
On Mon, Jun 8, 2020 at 2:11 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-06-08 04:32, Fernando Santagata wrote: > > On Mon, Jun 8, 2020 at 1:20 PM ToddAndMargo via perl6-users > > mailto:perl6-us...@perl.org>> wrote: > > > > On 2020-06-08 03:38, Fernando Santagata wrote: > > > …and line 3: > > > > > > unit module Informative; > > > > 3: unit module Informative; > > > > Does not look like a class to me. What am I missing? > > > > It's a namespace declaration, see: > > > > > https://docs.raku.org/language/syntax#index-entry-declarator_unit-declarator_module-declarator_package-Package,_Module,_Class,_Role,_and_Grammar_declaration > > > > That's the reason why the class name is Informative::Informing and not > > just Informing. > > Hi Fernando, > > I see: > > Several packages may be declared in a single file. > However, you can declare a unit package at the start > of the file (preceded only by comments or use > statements), and the rest of the file will be taken > as being the body of the package. In this case, the > curly braces are not required. > > unit module M; > # ... stuff goes here instead of in {}'s > > I thought methods had to be part of classes? Or > how the above relates to the methods in the module. > > I am confused. Methods are just subroutines which take an implicit first argument: the object they are operating on. All the methods in the module you mentioned are methods of the Informative::Informing class. You can check it by matching the '{' at the beginning of the class declaration with the corresponding '}'; method show() is inside the class. OTOH there's a "sub inform" in the "Informative" namespace which is not inside a class and is indeed a simple sub, even if it has been localized in that namespace. You can call that sub without prepending its namespace, since it has been declared as "is export." -- Fernando Santagata
Re: I need help finding a class for a method
On Mon, Jun 8, 2020 at 1:20 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-06-08 03:38, Fernando Santagata wrote: > > …and line 3: > > > > unit module Informative; > > > > > 3: unit module Informative; > > Does not look like a class to me. What am I missing? > It's a namespace declaration, see: https://docs.raku.org/language/syntax#index-entry-declarator_unit-declarator_module-declarator_package-Package,_Module,_Class,_Role,_and_Grammar_declaration That's the reason why the class name is Informative::Informing and not just Informing. -- Fernando Santagata
Re: I need help finding a class for a method
…and line 3: unit module Informative; On Mon, Jun 8, 2020 at 12:35 PM Richard Hainsworth wrote: > Look at line 10 > > class Informing { > > > On 08/06/2020 11:31, ToddAndMargo via perl6-users wrote: > > Hi All, > > Over on > > https://github.com/finanalyst/p6-inform/blob/master/lib/Informative.pm6 > > Line 144: > > method show( > Str $str?, > Int :$timer, > Bool :$show-countdown > ) { > > where is the class that is linked to that method? > > Many thanks, > -T > > -- Fernando Santagata
Re: question about the multi in method
On Mon, Jun 8, 2020 at 10:15 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-06-08 00:48, Fernando Santagata wrote: > > On Mon, Jun 8, 2020 at 9:12 AM ToddAndMargo via perl6-users > > mailto:perl6-us...@perl.org>> wrote: > > > > On 2020-06-07 22:39, Peter Pentchev wrote: > >> I addressed this in my original e-mail: the documentation is > > currently: > >> 1. a reference manual > > > > Targets at what audience? > > > > I think that that point has been stressed countless times: you > > probably want a User Manual, not a Reference. The online Reference is > > well written and it's what most people need. To learn more about Raku > > please refer to the numerous books on the topic: > > > > https://perl6book.com/ https://raku.org/resources/ > > User Manual and Reference Manual are synonyms. Or > as the Raku web site calls it: Documentation. > As far as I remember there were times when manuals were printed on real paper and the Reference Manual was a dry thing used - well - as a reference, while the User Manual addressed task-based topics. For example, the User Manual would address the task of how to compile, link, and run a simple program, while the Reference Manual would list all the possible command line switches. -- Fernando Santagata
Re: question about the multi in method
On Mon, Jun 8, 2020 at 9:12 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-06-07 22:39, Peter Pentchev wrote: > > I addressed this in my original e-mail: the documentation is currently: > > 1. a reference manual > > Targets at what audience? > I think that that point has been stressed countless times: you probably want a User Manual, not a Reference. The online Reference is well written and it's what most people need. To learn more about Raku please refer to the numerous books on the topic: https://perl6book.com/ https://raku.org/resources/ -- Fernando Santagata
Re: I reproduced one of the errors!
On Wed, Jun 3, 2020 at 10:07 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Is there a way to write a methods as I would write > a sub and avoiding the class thing? > I re-read the whole thread, but I still fail to understand what a "method as a sub, avoiding the class thing" is. Yet, I'm trying a mind-reading trick: when you say "method" perhaps you mean a sub you can call using a method call syntax. If that's the case, then one may write something like this: sub f($x) { $x² } 6. # output: 36 Did the trick work? -- Fernando Santagata
Re: Raku -npe command line usage
On Fri, May 8, 2020 at 6:10 PM Fernando Santagata wrote: > raku -e'lines() ==> grep(/^WARN/) ==> sort() ==> reduce({$^a ~ "\n" ~ > $^b}) ==> say()' sample.log > and the reduce call can be written more compactly: reduce({"$^a\n$^b"}) -- Fernando Santagata
Re: Raku -npe command line usage
raku -e'.say for lines() ==> grep(/^WARN/) ==> sort' sample.log is not very satisfying because for the "for" which breaks the flow. OTOH this raku -e'lines().grep(/^WARN/).sort».say' sample.log doesn't use the feed operator and this raku -e'lines() ==> grep(/^WARN/) ==> sort() ==> say()' sample.log outputs a list on one line, not each line on its own. This one works, but it feels awkward: raku -e'lines() ==> grep(/^WARN/) ==> sort() ==> reduce({$^a ~ "\n" ~ $^b}) ==> say()' sample.log On Fri, May 8, 2020 at 5:49 PM yary wrote: > All good ideas so far, in the "more than one way to do it" spirit, can use > "state" instead of "my", since state only initializes 1st time it's hit. > > raku -ne 'state @i;@i.push($_) if .starts-with(q[WARN]); END .say for > @i.sort' sample.log > > Or adapting Brad's answer with the feed operator for fun > > raku -e 'for lines() ==> grep /^WARN/ ==> sort() {.say}' sample.log > > Now, I didn't want to use 'map' in there, because of a habit of only using > 'map' when I want the return values. When looping for side-effects only, > like saying each value in a list, I want to use 'for'. UnFORtunately though > I cannot find anything as clean looking as > > raku -e 'lines() ==> grep /^WARN/ ==> sort() ==> map *.say' sample.log > > reading entirely L-to-R which does NOT use map... ideas? > > -y > > > On Fri, May 8, 2020 at 10:10 AM William Michels via perl6-users < > perl6-us...@perl.org> wrote: > > > > On Fri, May 8, 2020 at 5:16 AM WFB wrote: > > > > > > Hi, > > > > > > I am trying to write an one-liner to go through all lines in a logfile > and look for an certain key word, store the line and sort them before > printing them out. > > > > > > My approach was: > > > raku -ne "BEGIN {my @i }; @i.push($_); if $_ ~~ /^WARN/; END { > @i.sort.say }" > > > That does not work because @i does not exist in the if clause. I tried > our @i as well with no luck. > > > > > > How can I store data that can be accessed in the END phaser? Or is > there another way to archive it? TIMTOWTDI^^ > > > > > > One hint I found was the variable $ and @ respectively. But those > variables are created for each line new... > > > > > > > > > I did not found a help or examples for -npe except raku -h. Is there > more helpful stuff somewhere in doc.raku.org? If so I could'nt find it. > > > > > > Thanks, > > > Wolfgang > > > > Hi Wolfgang, > > > > This is a first attempt at doing what you want: I'm sure it can be > > shortened. Since one of your requirements is doing a sort on filtered > > values stored in an array, I abandoned use of the "-ne" one-liner > > flag, using "-e" and "for lines()" instead. I also used grep instead > > of smart-matching: > > > > perl6 -e 'my @i; for lines() {if .grep(/^WARN/) -> ($s) > > {@i.push($s)};}; .say for @i.sort;' > > > > Note: the "-> ($s)" section where I store grepped matches comes from a > > Jonathan Worthington answer found here (thanks Jonathan!): > > > > > stackoverflow.com/questions/58982745/raku-one-line-expression-to-capture-group-from-string > > > > I certainly would be interested to learn if there's a phaser solution > > to this problem (and I also have a sneaking suspicion that Supply > > might be useful here... ). > > > > HTH, Bill. > -- Fernando Santagata
Re: Is LibraryMake still current?
Sorry for the necroposting, but I found out a new way to build a native code library to be used by a Raku module. Using Distribution::Builder::MakeFromJSON one can configure the native library building by adding some sections to the META6.json file, without using LibraryMake and its Build.pm file. 'zef build' works flawlessly and so does Mi6, which OTOH can't deal with LibraryMake. HTH On Sat, Dec 21, 2019 at 7:41 PM Fernando Santagata < nando.santag...@gmail.com> wrote: > Hello, > > What can I use to help building native code for a Raku module? > Is LibraryMake still the preferred method or there's something else to use > nowadays? > > Thanks! > > -- > Fernando Santagata > -- Fernando Santagata
Re: Is LibraryMake still current?
…and the App::Mi6 author just released an updated version that deals well with the new naming scheme! Thank you! On Mon, Dec 23, 2019 at 4:51 PM Fernando Santagata < nando.santag...@gmail.com> wrote: > I hope that zef tests a distribution using both .t and .rakutest > extensions, because there is no --verbose option to let one see what's > happening. > > BTW I raised one issue on App::Mi6, because its dist.ini file doesn't > allow a module to end with .rakumod, and one on App:prove6, because the > prove6 program doesn't test files ending with .rakutest. > > On Mon, Dec 23, 2019 at 3:47 PM Elizabeth Mattijsen > wrote: > >> >> https://github.com/perl6/problem-solving/blob/master/solutions/language/Path-to-Raku.md#extensions >> >> > On 23 Dec 2019, at 15:28, Parrot Raiser <1parr...@gmail.com> wrote: >> > >> > With the name change to Raku, has anyone considered a naming suffix >> > policy for modules? I don't have a problem with .pm6, and I don't >> > want to cause an outbreak of bikeshedding, but some might consider it >> > inconsistent. >> > >> > As an aside, I deplore the practice of identifying the language of a >> > directly executable program in the top level. It means that any change >> > to the language used means lying to the world, (which destroys the >> > point) or hunting down and changing every script or other caller to >> > reflect the new situation. >> > > > -- > Fernando Santagata > -- Fernando Santagata
Re: Is LibraryMake still current?
It seems that the problem I was having with prove6 was due to zef not realizing there is a new version of the module. On Mon, Dec 23, 2019 at 4:51 PM Fernando Santagata < nando.santag...@gmail.com> wrote: > I hope that zef tests a distribution using both .t and .rakutest > extensions, because there is no --verbose option to let one see what's > happening. > > BTW I raised one issue on App::Mi6, because its dist.ini file doesn't > allow a module to end with .rakumod, and one on App:prove6, because the > prove6 program doesn't test files ending with .rakutest. > > On Mon, Dec 23, 2019 at 3:47 PM Elizabeth Mattijsen > wrote: > >> >> https://github.com/perl6/problem-solving/blob/master/solutions/language/Path-to-Raku.md#extensions >> >> > On 23 Dec 2019, at 15:28, Parrot Raiser <1parr...@gmail.com> wrote: >> > >> > With the name change to Raku, has anyone considered a naming suffix >> > policy for modules? I don't have a problem with .pm6, and I don't >> > want to cause an outbreak of bikeshedding, but some might consider it >> > inconsistent. >> > >> > As an aside, I deplore the practice of identifying the language of a >> > directly executable program in the top level. It means that any change >> > to the language used means lying to the world, (which destroys the >> > point) or hunting down and changing every script or other caller to >> > reflect the new situation. >> > > > -- > Fernando Santagata > -- Fernando Santagata
Re: Is LibraryMake still current?
I hope that zef tests a distribution using both .t and .rakutest extensions, because there is no --verbose option to let one see what's happening. BTW I raised one issue on App::Mi6, because its dist.ini file doesn't allow a module to end with .rakumod, and one on App:prove6, because the prove6 program doesn't test files ending with .rakutest. On Mon, Dec 23, 2019 at 3:47 PM Elizabeth Mattijsen wrote: > > https://github.com/perl6/problem-solving/blob/master/solutions/language/Path-to-Raku.md#extensions > > > On 23 Dec 2019, at 15:28, Parrot Raiser <1parr...@gmail.com> wrote: > > > > With the name change to Raku, has anyone considered a naming suffix > > policy for modules? I don't have a problem with .pm6, and I don't > > want to cause an outbreak of bikeshedding, but some might consider it > > inconsistent. > > > > As an aside, I deplore the practice of identifying the language of a > > directly executable program in the top level. It means that any change > > to the language used means lying to the world, (which destroys the > > point) or hunting down and changing every script or other caller to > > reflect the new situation. > -- Fernando Santagata
Re: Is LibraryMake still current?
Hi David, Thank you for replying! LibraryMake looked ancient to me for its use of a .pm file, instead of a .pm6, so I asked if there was anything newer. The quantity of Raku modules is not remotely comparable to Perl's, yet there's something new each week and I may have failed to notice something useful! Happy holidays! On Mon, Dec 23, 2019 at 3:28 AM David Warring wrote: > Hi Fernando, > I'm still in the habit of using LibraryMake. E.g. for > https://github.com/p6-xml/LibXML-raku released in this last few months. > Regards, > David > > On Sun, Dec 22, 2019 at 7:47 AM Fernando Santagata < > nando.santag...@gmail.com> wrote: > >> Hello, >> >> What can I use to help building native code for a Raku module? >> Is LibraryMake still the preferred method or there's something else to use >> nowadays? >> >> Thanks! >> >> -- >> Fernando Santagata >> > -- Fernando Santagata
Is LibraryMake still current?
Hello, What can I use to help building native code for a Raku module? Is LibraryMake still the preferred method or there's something else to use nowadays? Thanks! -- Fernando Santagata
Re: modules and subsets
On Fri, Dec 13, 2019 at 6:48 AM Todd Chester via perl6-users < perl6-us...@perl.org> wrote: > On 2019-12-12 00:22, Fernando Santagata wrote: > > On Thu, Dec 12, 2019 at 3:46 AM Todd Chester > <mailto:toddandma...@zoho.com>> wrote: > > Can I export any other variable and constants the same way: > > my $pi = 4.13 is export; > > -T > Not like that. A "my" variable cannot be exported and the syntax is slightly wrong. Try: our $pi is export = 4.13; -- Fernando Santagata
Re: modules and subsets
On Thu, Dec 12, 2019 at 3:46 AM Todd Chester wrote: > On 2019-12-11 10:22, Fernando Santagata wrote: > > File test.pm6 > > > > unit module test; > > subset PosInt of Int is export where * > 0; > > > > > > File test.p6 > > > > use lib '.'; > > use test; > > sub mytest(PosInt $a) { say $a } > > mytest(1); # output: 1 > > mytest(-1);# output Constraint type check failed in binding to > > parameter '$a'; expected test::PosInt but got Int (-1) > > Hi Fernando, > > What response do you get back with? > > perl6 -c test.pl6 > > -T > I don't understand the reason for your question, but anyway: $ perl6 -c test.pl6 Syntax OK -- Fernando Santagata
Re: modules and subsets
File test.pm6 unit module test; subset PosInt of Int is export where * > 0; File test.p6 use lib '.'; use test; sub mytest(PosInt $a) { say $a } mytest(1); # output: 1 mytest(-1);# output Constraint type check failed in binding to parameter '$a'; expected test::PosInt but got Int (-1) On Wed, Dec 11, 2019 at 7:04 PM JJ Merelo wrote: > > > El mié., 11 dic. 2019 a las 18:54, JJ Merelo () > escribió: > >> Subsets follow pretty much the same rules as every other declared thing. >> Change subset by "variable" or "class", if the answer is true, it's also >> true for subsets. >> >> By default, the scope of anything (containers, classes, whatever) is >> lexical to the scope they are in. >> > > Sorry, that's not true. Classes have package scope, not lexical scope, by > default; that is, they are "our": https://docs.perl6.org/language/classtut > > Subsets... well I don't know. I would say they are package scoped by > default, same as classes. > > JJ > -- Fernando Santagata
Re: Fwd: Raku, docs, help [was: Re: vulgar?]
On Tue, Dec 10, 2019 at 3:53 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2019-12-09 09:44, Trey Harris wrote: > > Signatures are important to Raku. > > Trey, > > The signatures are very important to the developers. > They only confuse the programmer. > > -T > I'm a programmer, not an expert in language design, I don't even have a formal education about programming, because when I attended university there was no such thing yet. I started studying Raku in December 2015 and I have to admit that at first I didn't understand signatures.So I went on and I read the documentation page on signatures. That solved my problem. I'm talking about the 2015 version of the documentation, which is now much improved and I'm writing this just because I think that the people who have been writing that documentation for all those years really, really deserve to be thanked. A lot. -- Fernando Santagata
Re: How do I do literal quotes in a regex?
On Mon, Dec 9, 2019 at 9:38 AM Fernando Santagata wrote: > It can be used this way: > > $ raku -e'say „Hello!“' > Hello! > But it must be used with that closing quote '“' (U+201C); it cannot be > used paired with itself: > There's another quotation mark that can be used with '„', it's '”' (U+201D). I know, it's difficult to see the difference :-) $ raku -e'say „Hello!„' > ===SORRY!=== Error while compiling -e > Unable to parse expression in low curly double quotes; couldn't find final > <[”“]> (corresponding starter was at line 1) > at -e:1 > --> say „Hello!„⏏ > expecting any of: > argument list > low curly double quotes > term > > Your take: for maintainability, is it better to use >> these unicodes or to just stick with escaping things? >> > > I don't think there's a maintainability issue with Unicode operators, > because everyone has a plain ASCII counterpart; besides, their meaning is > quite apparent or in some cases even better than their ASCII counterpart: > consider the set union operator ∪ vs (|), the first being the universally > accepted mathematical symbol, while I find the second difficult to > interpret and remember. > > -- > Fernando Santagata > -- Fernando Santagata
Re: How do I do literal quotes in a regex?
On Mon, Dec 9, 2019 at 1:27 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > What is the unicode for the subscript double quote „ ? > That's U+201E and can it be used together with the regular > quote the same as 「」 ? > It can be used this way: $ raku -e'say „Hello!“' Hello! But it must be used with that closing quote '“' (U+201C); it cannot be used paired with itself: $ raku -e'say „Hello!„' ===SORRY!=== Error while compiling -e Unable to parse expression in low curly double quotes; couldn't find final <[”“]> (corresponding starter was at line 1) at -e:1 --> say „Hello!„⏏ expecting any of: argument list low curly double quotes term Your take: for maintainability, is it better to use > these unicodes or to just stick with escaping things? > I don't think there's a maintainability issue with Unicode operators, because everyone has a plain ASCII counterpart; besides, their meaning is quite apparent or in some cases even better than their ASCII counterpart: consider the set union operator ∪ vs (|), the first being the universally accepted mathematical symbol, while I find the second difficult to interpret and remember. -- Fernando Santagata
Re: implicit type change
It looks like a bug: the docs (https://docs.raku.org/language/nativetypes) specify that 'byte' and 'uint8' are the same and correspond to uint8_t in C. Substituting 'uint8' to 'byte' in your code returns the same result. Out of curiosity, if it is something meant for the public, what native call interface are you working on? On Sun, Dec 8, 2019 at 8:08 PM Marcel Timmerman wrote: > Hello, > > I have a nasty problem using native call interface. I get an array of > bytes from a call representing a pixel buffer. I am storing it in a > CArray[byte]. Golfing it down it comes to the following (REPL) > > > > use NativeCall > > my CArray[byte] $ba .= new( 255, 254, 3, 4); > NativeCall::Types::CArray[byte].new > > $ba[0].WHAT > (Int) > > $ba[0..*-1] > (-1 -2 3 4) > > > This means (for me) that there is an implicit type conversion from > unsigned to signed integer and it is not possible to use positive > numbers only, afterwards. > > Regards, > Marcel > -- Fernando Santagata
Re: Perl6 vs Julia
If math is your area of interest, the GSL is interesting *and* humongous: I've been working on it for two weeks writing the raw interface to the C library and I just started to write a Raku-level interface, something that would let programmers use the library without having to learn how to create a CArray and convert between Raku and C types. So after two weeks I counted how many C functions I converted as a raw interface: 561. Then I found out that I was at the third group of functions of about 40. Did I say it's huge? I think I will write the Raku interface to what I've done so far and start publish the "work in progress" on the CPAN, so other people will know that there's someone working on it. PRs will be welcome ;-) On Sun, Dec 8, 2019 at 7:41 PM Tom Blackwood wrote: > Nice! Thanks for letting me know. > > On Mon, Dec 9, 2019 at 12:21 AM Fernando Santagata < > nando.santag...@gmail.com> wrote: > >> Hi, >> I authored an interface to the Fastest Fourier Transform in the West >> (libfftw3) as Math::FFT::Libfftw3; I'm working on an interface to the GNU >> Scientific Library (libgsl). >> I'm writing this just to avoid duplicating an effort. >> >> On Sun, Dec 8, 2019 at 12:18 PM Tom Blackwood >> wrote: >> >>> Thanks JJ. >>> We know Perl has PDL for data science, >>> http://pdl.perl.org/ >>> >>> We are looking into it and see if it's possible to make a Perl6 version >>> of Scikit-learn based on PDL. >>> >>> regards. >>> Tom >>> >>> On Sun, Dec 8, 2019 at 6:40 PM JJ Merelo wrote: >>> >>>> It might have been, but syntax is more Python-like to the point that in >>>> some cases it's exactly the same. It's got a very extensive macro systems, >>>> which enables it to work concurrently, for instance. It's more >>>> scientific-computing oriented, which means that there are all sort of >>>> mathematical modules for it, and not so many for web, databases, or things >>>> like that. >>>> >>>> El dom., 8 dic. 2019 a las 4:38, Tom Blackwood () >>>> escribió: >>>> >>>>> Hello >>>>> >>>>> How do you think of Julia language? >>>>> >>>>> https://en.wikipedia.org/wiki/Julia_(programming_language) >>>>> >>>>> It says it is also influenced by perl language. >>>>> >>>>> Regards >>>>> >>>> >>>> >>>> -- >>>> JJ >>>> >>> >> >> -- >> Fernando Santagata >> > -- Fernando Santagata
Re: looking for good project to learn perl6
On Sun, Dec 8, 2019 at 7:38 PM Tom Blackwood wrote: > Tom > > We know pretty well tensorflow and spark ML. > Spark ML is primarily for machine learning, it lacks the ability of > deep learning such as deep CNN, GAN, GCN etc. In deep learning Industry > tensorflow and pytorch are widely used. I think Perl world should have our > own framework for ML/ DL. > Out of curiosity, for "our own framework" you mean a Raku interface to Tensorflow, or to some other software, because Tensorflow has been taken by Python? > Regards > > On Mon, Dec 9, 2019 at 1:52 AM Tom Browder wrote: > >> On Sun, Dec 8, 2019 at 10:38 AM Fernando Santagata >> wrote: >> > >> > Hello, >> > I started writing a raw interface to Tensorflow, but I stopped for >> various reasons [¹]. If anyone wants to work on it I can help and/or share >> what I've produced so far. >> > >> > [¹] three main reasons: >> ... >> >> Fernando, I'm on board with you on all three! >> >> But doesn't the Apache Group have something similar that could be a >> killer app without as much angst: Spark? >> >> See also: >> >> 1. >> https://dzone.com/articles/the-complete-apache-spark-collection-tutorials-and?edition=549292_source=Weekly%20Digest_medium=email_campaign=Weekly%20Digest%202019-12-04 >> >> 2. https://www.educba.com/tensorflow-alternatives/ >> >> Best regards, >> >> -Tom >> > -- Fernando Santagata
Re: How do I do literal quotes in a regex?
You won't believe it :-) but Raku's wonderful documentation has a page on how to enter Unicode characters: https://docs.raku.org/language/unicode_entry That page also links to a GitHub project which offers a .XCompose ready to use. I started from that and added some faster and easier (for me) to remember key combinations, such as for example: : "「" UFF62 : "」" UFF63 which use the left "Win" key as a dead key, followed by 'l' or 'L' to produce the Japanese quoting characters. On Sun, Dec 8, 2019 at 1:56 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > > On Sat, Dec 7, 2019 at 12:51 AM ToddAndMargo via perl6-users > > mailto:perl6-us...@perl.org>> wrote: > > > > Hi All, > > > > Is there a `Q[]` that can be used in a regex? > > > > I am looking for how to get around > > > > my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ '' /x/; say $y > > \:x:: > > > > This does not work: > > my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ Q[\\] /x/; say $y > > \:\\:: > > > > Nor does this: > > my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ [\\] /x/; say $y > > x:\\:: > > > > Many thanks, > > -T > > On 2019-12-07 07:02, Brad Gilbert wrote: > > The shortcut spelling of Q[…] is to use 「 and 」 (U+FF62 and U+FF63) > > > > my $x = 「\:\\::」; ( my $y = $x ) ~~ s/ 「\\」 /x/; say $y > > \:\\:: > > > > The case could be made that \Q[\\] should work as well. (It would need > > to be added). > > (Along with \q[…] and \qq[…]) > > > > Note that \Q[…] doesn't work in string literals currently either. While > > \q[…] and \qq[…] do. > > > > > "\q[\n]\n" > > \n > > > > > '\n\qq[\n]' > > \n > > > > Note that single and double quotes also work in regexs. > > > > The three of them ('…' "…" 「…」) have a few jobs. > > > > 1. They escape spaces and other non-alphanumerics. > > > > > 'a b c' ~~ / 'a b c' / > > Nil > > > 'a b c A B C' ~~ / :i 'a b c' / > > A B C > > > > > 'a b c' ~~ / 'a . c' / > > Nil > > > 'a . c' ~~ / 'a . c' / > > a . c > > > > Note that the rules for the string literal still apply. > > > > > "abc\n" ~~ / 'abc\n' / > > Nil > > > "abc\n" ~~ / "abc\n" / > > abc > > > > 2. They group characters as a single atom. > > (Meaning they behave a bit like [] in a regex) > > > > > 'abccd' ~~ / 'abc'+ d / > > Nil > > > 'abccd' ~~ / [abc]+ d / > > Nil > > > > > 'abccd' ~~ / abc+ d / > > abccd > > > > > 'abccd abcABCabcd' ~~ / :i 'abc'+ d / > > abcABCabcd > > > 'abccd abcABCabcd' ~~ / :i [abc]+ d / > > abcABCabcd > > > > Note that '…' in a regex behaves like '…' outside of one, as well as "…" > > behaving like "…" and 「…」 behaving like 「…」 > > Hi Brad, > >That was above and beyond! Thank you! > > my $x = Q[\:\\::]; ( my $y = $x ) ~~ s/ 「\\」 /x/; say $y > \:x:: > > What is the easiest way to get those weird brackets in Fedora31? > > -T > -- Fernando Santagata
Re: looking for good project to learn perl6
Hello, I started writing a raw interface to Tensorflow, but I stopped for various reasons [¹]. If anyone wants to work on it I can help and/or share what I've produced so far. [¹] three main reasons: * Ethics: I wouldn't like to be part of an effort to control people and free speech; * I don't trust how Google manages its projects (Just google for "google graveyard". I've been burned twice by Google dropping its products, so pardon me if I'm wary) * Lack of experience in the specific field of machine learning: while I understand the basics and I know how to interface C and Raku, I know that the Tensorflow C API is seldom used directly. Programmers usually work with the Python interface, which is much more extensive, but as far as I know, poorly documented. Those are just my opinions and I'm happy to change my opinions when facts contradict them ;-) On Sun, Dec 8, 2019 at 12:50 PM Peter Scott wrote: > Raku libraries for Keras/Tensorflow, or AWS, or Kubernetes, leveraging the > novel features of Raku, could be killer apps for Raku. Ambitious, though. > > Peter Scott > > On Dec 7, 2019, at 7:24 PM, Tom Blackwood wrote: > > > Hello William, > > We are actually a small team making the primary job for big data/machine > learning etc. > We know nothing about mailing list gateway and NNTP stuff. > But thanks for your suggestion, I will take a took at the references you > provided. > > Regards > Tom > > > On Sun, Dec 8, 2019 at 3:30 AM William Michels > wrote: > >> Hi Tom, >> >> My vote would be for someone to take on the task of writing >> "mailing-list" software in Raku/Perl6, and/or writing >> "mailing-list-archiving" software (e.g. an NNTP server) in Raku/Perl6. >> First of all, for your group this would be a relatively-high profile >> project, with the potential for hundreds or even thousands of >> companies adopting such a module for their own institutional or >> company needs. >> >> Regarding the "archiving" module in particular, you could see how the >> Perl mailing lists are archived, and easily imagine how they might be >> improved. There would be a need to access data from a database, filter >> out spam, organize the data by date and/or thread, and serve up the >> data in a web-accessible format. Selfishly, I would love to see a >> searchable archive of every Perl6/Raku email ever written. >> >> I've communicated with Ask Bjorn Hansen about the Perl software >> presently running the NNTP archive (www.nntp.perl.org), in particular >> the Perl6-Users mailing list. Ask Bjorn Hansen says the NNTP archive >> runs on Colobus which is written in Perl, with commits going all the >> way back to 2001. So why not rewrite it in Raku/Perl6?? In particular, >> I was hoping to see a better "subject threading" algorithm, since with >> Colobus (on occasion) emails from different "eras" are lumped together >> in the same thread (example: emails from 2010 showing up in Sept. 2019 >> threads). >> >> I don't know if your group has an interest in writing a full-blown >> NNTP server, but below are resources for Raku/Perl6, Python, and R. >> You can decide for yourself if the Raku/Perl6 resources need >> improving: >> >> Raku/Perl6: >> https://www.nntp.perl.org/group/ >> https://www.nntp.perl.org/group/perl.perl6.users/ >> https://trainedmonkey.com/projects/colobus/ >> https://github.com/abh/colobus >> >> Python: >> https://www.python.org/community/lists/ >> https://mail.python.org/archives/ >> https://mail.python.org/mailman/listinfo >> >> R: >> https://www.r-project.org/mail.html >> https://stat.ethz.ch/mailman/listinfo >> https://r.789695.n4.nabble.com >> >> >> HTH, Bill. >> >> >> >> On Fri, Dec 6, 2019 at 1:59 AM Tom Blackwood >> wrote: >> > >> > Thanks, I'll check it out! >> > >> > On Fri, Dec 6, 2019 at 5:50 PM JJ Merelo wrote: >> >> >> >> Try something in the most wanted repo: >> https://github.com/perl6/perl6-most-wanted/blob/master/most-wanted/modules.md >> That way you will learn _and_ help the community. >> >> >> >> El vie., 6 dic. 2019 a las 8:11, Tom Blackwood () >> escribió: >> >>> >> >>> Hello >> >>> >> >>> My team most time developed with ruby language. >> >>> These recent days we took time reading the book Learning Perl 6. >> >>> Then we consider to take an actual project to learn more deeply. >> >>> What project do you suggest for us to get involve into? >> >>> >> >>> Regards, >> >>> Tom >> >> >> >> >> >> >> >> -- >> >> JJ >> > -- Fernando Santagata
Re: Perl6 vs Julia
Hi, I authored an interface to the Fastest Fourier Transform in the West (libfftw3) as Math::FFT::Libfftw3; I'm working on an interface to the GNU Scientific Library (libgsl). I'm writing this just to avoid duplicating an effort. On Sun, Dec 8, 2019 at 12:18 PM Tom Blackwood wrote: > Thanks JJ. > We know Perl has PDL for data science, > http://pdl.perl.org/ > > We are looking into it and see if it's possible to make a Perl6 version of > Scikit-learn based on PDL. > > regards. > Tom > > On Sun, Dec 8, 2019 at 6:40 PM JJ Merelo wrote: > >> It might have been, but syntax is more Python-like to the point that in >> some cases it's exactly the same. It's got a very extensive macro systems, >> which enables it to work concurrently, for instance. It's more >> scientific-computing oriented, which means that there are all sort of >> mathematical modules for it, and not so many for web, databases, or things >> like that. >> >> El dom., 8 dic. 2019 a las 4:38, Tom Blackwood () >> escribió: >> >>> Hello >>> >>> How do you think of Julia language? >>> >>> https://en.wikipedia.org/wiki/Julia_(programming_language) >>> >>> It says it is also influenced by perl language. >>> >>> Regards >>> >> >> >> -- >> JJ >> > -- Fernando Santagata
Re: hash and print question
Try say %x{$y}.base(16); On Thu, Dec 5, 2019 at 10:52 AM Todd Chester via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > In the following, > > > $ p6 'my %x= YesNo=>0xff, OkayCancel=>0x55; my $y="YesNo"; if %x<<$y>> > {say %x<<$y >>.base(16)}else{say "n"};' > FF > > $ p6 'my %x= YesNo=>0xff, OkayCancel=>0x55; my $y="Help"; if %x<<$y>> > {say %x<< $y >>.base(16)}else{say "n"};' > n > > I have to use a space after $y > say %x<<$y >>.base(16) > > or I get the finger wagged at me. > > Ambiguous use of >>; use » instead to mean hyper, or > insert whitespace before >> to mean a quote terminator > (or use different delimiters?) > > Is there a better way to write: > say %x<<$y >>.base(16) > > Many thanks, > -T > -- Fernando Santagata
Re: zef uninstall .
On Wed, Sep 4, 2019 at 4:07 PM Tom Browder wrote: > On Wed, Sep 4, 2019 at 05:53 Fernando Santagata > wrote: > >> >> On Wed, Sep 4, 2019 at 12:21 PM William Michels >> wrote: >> >>> Hi Fernando, I'm not sure I understand. Is this for module >>> development? And you want to purge old versions of a module you're >>> developing, before doing a 'git push'? >> >> > I have never had a problem with: > > cd my-module > zef install . > zef uninstall My::Module > I was trying to do that automatically from a git pre-push hook. I opened an "issue", actually a feature request, in the zef repository on GitHub. I received some suggestions and right now my pre-push script looks like this: #/bin/sh zef uninstall "$(perl6 -MJSON::Fast -e 'my $meta = from-json slurp ”META6.json”; say $meta, $meta ?? ”:auth<$meta>” !! ””, $meta ?? ”:ver<$meta>” !! ””')" zef install . --force-install which is not exactly "clean." What I mean is that zef is able to read the META6.json file, because it does it when it installs a module from a directory using "zef install .". It might do the same when asked to uninstall what's in a certain directory, using something along the lines of "zef uninstall .". -- Fernando Santagata
Re: zef uninstall .
On Wed, Sep 4, 2019 at 12:21 PM William Michels wrote: > Hi Fernando, I'm not sure I understand. Is this for module > development? And you want to purge old versions of a module you're > developing, before doing a 'git push'? > Yes, it's for module development. What I do is to actually install, not just test, my module before pushing it to GitHub. Usually all my test programs have a "use lib 'lib'" to make sure to use the present version of the module to test itself. Though if I miss a "use lib 'lib'" maybe the installed module is used, so I want to uninstall it before the reinstall. > I'm not sure about an anonymous uninstall in the pwd ("."), but there > might be a way to set up a separate 'DevDir', and then use the 'nuke' > command to only delete paths in--and/or--to that directory. > > https://github.com/ugexe/zef > > nuke [RootDir | TempDir | StoreDir] > Deletes all paths in the specific configuration directory > > nuke [site | home] > Deletes all paths that are rooted in the prefix of the matching > CompUnit::Repository name > > # uninstall all modules > $ zef nuke site home > > HTH, Bill. > > > > > > > On Wed, Sep 4, 2019 at 1:05 AM Fernando Santagata > wrote: > > > > Hello, > > > > apparently there's no analogous of "zef install ." to uninstall a > module, i.e. an "anonymous" way to do it. > > > > The problem that I'm trying to solve is to automatically uninstall and > reinstall a module before a "git push". In order to do this I'm using the > git pre-push hook. > > So far my pre-push script is just: > > > > zef install . --force-install > > > > but now I'm thinking that it's not enough and I'd like to uninstall the > current module and then re-install it. > > To do that I need a way to uninstall an "anonymous" module, something > along the lines of "zef uninstall .". > > > > Any idea? > > > > -- > > Fernando Santagata > -- Fernando Santagata
zef uninstall .
Hello, apparently there's no analogous of "zef install ." to uninstall a module, i.e. an "anonymous" way to do it. The problem that I'm trying to solve is to automatically uninstall and reinstall a module before a "git push". In order to do this I'm using the git pre-push hook. So far my pre-push script is just: zef install . --force-install but now I'm thinking that it's not enough and I'd like to uninstall the current module and then re-install it. To do that I need a way to uninstall an "anonymous" module, something along the lines of "zef uninstall .". Any idea? -- Fernando Santagata
Re: 11.01 in binary
I guess you're reading data from a file, since Perl 6 numbers (such as 11.01) might have a Rat representation. If so I guess you have that data in a Blob, then read the four bytes using read-uint8 (https://docs.perl6.org/routine/read-uint8) and apply .base(2) to each of them. On Tue, Sep 3, 2019 at 2:30 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 9/3/19 5:21 AM, ToddAndMargo via perl6-users wrote: > >>> On Tue, Sep 3, 2019 at 1:15 PM ToddAndMargo via perl6-users > >>> mailto:perl6-us...@perl.org>> wrote: > >>> > >>> Hi All, > >>> > >>> How would I print out what a 32 real value of > >>> 11.01 (base 10) looks like in its raw > >>> binary form (ones and zeros)? > >>> > >>> Many thanks, > >>> -T > > > > On 9/3/19 5:09 AM, Fernando Santagata wrote: > >> Is this what you need? > >> > >> > (11.01).base(2) > >> 1011.0011 > >> > >> -- > >> Fernando Santagata > > > > > > > > Perfect! Thank you! > > > > $ p6 'say (11.01).base(2)' > > 1011.0011 > > > > How would I do it in reverse. Give a base 2 number > > and print it in base 10? > > > > Wait a minute. There is no decimal point. Only ones and zeros. > I am looking for a binary dump of what a 32 bit real variable > actually contains. > -- Fernando Santagata
Re: 11.01 in binary
Is this what you need? > (11.01).base(2) 1011.0011 On Tue, Sep 3, 2019 at 1:15 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > How would I print out what a 32 real value of > 11.01 (base 10) looks like in its raw > binary form (ones and zeros)? > > Many thanks, > -T > -- Fernando Santagata
Re: [ please ] request for perl machine learning utils development
I started working on Tensorflow, but I've been sidetracked by another more urgent project, libxml2. I don't know when I will be able to work on Tensorflow again, since libxml2 is quite a large library (and Tensorflow C API, besides being large, is not adequately documented). On Wed, Aug 28, 2019 at 10:47 AM Cloud Cache wrote: > Hi Elizabeth, > > Thanks for the encouragement. > I am not good at low level system development, just using the high-level > API from tensorflow/keras etc. > So I hope there should have perl's framework appearing. > > regards. > > > on 2019/8/28 16:39, Elizabeth Mattijsen wrote: > >> On 28 Aug 2019, at 08:23, Cloud Cache wrote: > >> Perl is for big data. Many operators in banks use perl to analyse data > stuff. Many programmers in big companies use perl to do statistics from all > kinds of logs. > >> > >> For me, I use perl everyday, for data gathering, data cleaning etc. I > pretty like its Regex and flexibility for text parsing. > >> > >> But there is no mainstream machine learning frameworks by perl. > >> I have to write codes with other languages and other frameworks to run > ML tasks. > >> > >> Will please perl6 developers take part focus on development of ML tools > and frameworks? > > > > Why don't you become a Perl 6 developer and work on that? Than you can > be sure it will have the interface and behaviour that you want! > > > > > >> I think there are many other perl people around the world expect this > capability. > > > > If there were more people actually working on this, we would actually > have that capability. > > > > > > > > Liz > > > -- Fernando Santagata
Re: Short term Zef fix
Just tried that; it doesn't seem to work. On Tue, Apr 30, 2019 at 1:37 PM Simon Proctor wrote: > Not tried that > > On Tue, 30 Apr 2019 at 12:35, Timo Paulssen wrote: > >> Doesn't updating zef to the latest version fix everything up nicely? >> - Timo >> On 30/04/2019 12:06, Simon Proctor wrote: >> >> Until the p6c system is fixed here's a short term fix that will at least >> let zef install modules from cpan. >> >> zef --help >> This lists a config file mine is : >> >> CONFIGURATION /home/sproctor/.config/zef/config.json >> >> Open that file and fine the "p6c" section. Set enabled to 0 and zef will >> stop trying to access the ecosystem modules. >> >> It's not perfect as not everything is in CPAN but it should help. >> >> -- >> Simon Proctor >> Cognoscite aliquid novum cotidie >> >> http://www.khanate.co.uk/ >> >> > > -- > Simon Proctor > Cognoscite aliquid novum cotidie > > http://www.khanate.co.uk/ > -- Fernando Santagata
Re: Short term Zef fix
Browsing zef's options I see that a --/p6c may be used instead of editing the configuration file. JJ's caveat still valid though. On Tue, Apr 30, 2019 at 12:07 PM Simon Proctor wrote: > Until the p6c system is fixed here's a short term fix that will at least > let zef install modules from cpan. > > zef --help > This lists a config file mine is : > > CONFIGURATION /home/sproctor/.config/zef/config.json > > Open that file and fine the "p6c" section. Set enabled to 0 and zef will > stop trying to access the ecosystem modules. > > It's not perfect as not everything is in CPAN but it should help. > > -- > Simon Proctor > Cognoscite aliquid novum cotidie > > http://www.khanate.co.uk/ > -- Fernando Santagata
Re: FatRat's falling back to Num's
This one works fine: sub plouffe (Int $k) { my $result = 1.FatRat * (1 / 16 ** $k).FatRat * ((4 / (8 * $k + 1)).FatRat - (2 / (8 * $k + 4)).FatRat - (1 / (8 * $k + 5)).FatRat - (1 / (8 * $k + 6)).FatRat ); } say (plouffe $_).WHAT for ^20 I guess that until a certain point all the terms not specifically cast to FatRat are of type Rat. After reaching the maximum possible Rat they're converted to Num and FatRat * Num = Num. On Fri, Apr 19, 2019 at 3:37 PM Laurent Rosenfeld via perl6-users < perl6-us...@perl.org> wrote: > Hello, > > in the context of the Perl Weekly Challenge, I was trying to use one of > Franco-Canadian mathematician Simon Plouffe's formulas to compute the > digits of pi. > > For this, I have written the following subroutine: > > sub plouffe (Int $k) { > my $result = (1 / 16 ** $k) * ( (4 / (8 * $k + 1)) - (2 / (8 * $k + > 4)) - (1 / (8 * $k + 5)) - (1 / (8 * $k + 6) ) ); > } > > With this, it should be possible to compute the pi decimals with something > like this: > > > my $k = [+] (plouffe $_ for 0..15) > 3.141592653589793129614170564041344859 > > > > That doesn't work properly, however as the digitss are wrong after a > certain rank (16th). The reason seems to be that, after a while, rationals > are converted to floats and precision is lost: > > > say (plouffe $_).WHAT for 0..15; > (Rat) > (Rat) > (Rat) > (Rat) > (Rat) > (Rat) > (Rat) > (Rat) > (Rat) > (Rat) > (Rat) > (Num) > (Num) > (Num) > (Num) > (Num) > > > > So, for an input value of 11 or more, the plouffe subroutine returns a Num. > > So I decided to try with FatRat: > > sub plouffe (Int $k) { > my $result = 1.FatRat * (1 / 16 ** $k) * ( (4 / (8 * $k + 1)) - (2 / > (8 * $k + 4)) - (1 / (8 * $k + 5)) - (1 / (8 * $k + 6) ) ); > } > > It is a bit better, but I am again falling back to Num when the subroutine > input value reaches 17 or above: > > > say (plouffe $_).WHAT for 0..20; > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (FatRat) > (Num) > (Num) > (Num) > (Num) > (Num) > > Has anyone an idea why we are not keeping FatRat values all the way? Or, > is there a better way to guarantee that we continue to use FatRat's? > > Note that I have found other ways of computing many pi digits, but the one > described above would be much simpler and much more elegant, if only it > worked OK. So my question is really not how to compute pi's digits, but > more this: why are the above computations falling from FatRat to Num after > a while, and is there something to do to keep FatRat calculation all the > way? > > Thanks to anyone who would be able to shed light on this. > > > > > > > > > -- Fernando Santagata
Re: valid values?
Hi Brad, How far should I follow the rule that I should not use a smartmatch in a where clause? I'm thinking of this: > sub test1(:@array? where Str) { say 'ok' } > test1() Constraint type check failed in binding to parameter '@array'; expected anonymous constraint to be met but got Array ($[]) in sub test1 at line 1 in block at line 1 > sub test2(:@array? where .all ~~ Str) { say 'ok' } > test2() ok The where clause in test1() doesn't work, but is the clause in test2() dangerous (action at a distance)? Should I rephrase it differently? On Mon, Mar 4, 2019 at 5:29 AM Brad Gilbert wrote: > The `where` clause is already a smart-match, adding `~~` to it is not > only redundant, it can cause confusing action at a distance. > (By that I mean the right side of `where` is exactly the same as the > right side of `~~`) > > You wouldn't write this: > > * ~~ (* ~~ 1|2|4|8|16) > > So don't write this either: > > … where * ~~ 1|2|4|8|16 > > --- > > It should be > > sub mysub(Int $value where 1|2|4|8|16) >{ > say "Got $value" > } > > On Sun, Mar 3, 2019 at 4:16 AM Fernando Santagata > wrote: > > > > Hi Todd, > > is this what you're looking for? > > > > sub mysub(Int $value where * ~~ 1|2|4|8|16) > > { > > say "Got $value" > > } > > > > mysub 2; # Got 2 > > mysub 3; # Constraint type check failed in binding to parameter > '$value'; expected anonymous constraint to be met but got Int (3) > > > > On Sun, Mar 3, 2019 at 11:09 AM ToddAndMargo via perl6-users < > perl6-us...@perl.org> wrote: > >> > >> Hi All, > >> > >> I want to pass an integer to a sub. The only > >> valid values of the integer are 1, 2, 4, 8, and 16. > >> > >> Other than using "if" to test their values, is > >> there a way to state that an integer can only > >> have certain predefined values? > >> > >> Many thanks, > >> -T > >> > >> -- > >> ~~~ > >> Having been erased, > >> The document you're seeking > >> Must now be retyped. > >> ~~~ > > > > > > > > -- > > Fernando Santagata > -- Fernando Santagata
Re: valid values?
On Sun, Mar 3, 2019 at 11:41 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > That way I can catch bad values at compile time and not have > to wait and see what it gets fed. > The snippet I showed you doesn't intercepts wrong values at compile time, but rather at run time. -- Fernando Santagata
Re: valid values?
Hi Todd, is this what you're looking for? sub mysub(Int $value where * ~~ 1|2|4|8|16) { say "Got $value" } mysub 2; # Got 2 mysub 3; # Constraint type check failed in binding to parameter '$value'; expected anonymous constraint to be met but got Int (3) On Sun, Mar 3, 2019 at 11:09 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > I want to pass an integer to a sub. The only > valid values of the integer are 1, 2, 4, 8, and 16. > > Other than using "if" to test their values, is > there a way to state that an integer can only > have certain predefined values? > > Many thanks, > -T > > -- > ~~~ > Having been erased, > The document you're seeking > Must now be retyped. > ~~~ > -- Fernando Santagata
Re: Travis-CI
On Tue, Feb 26, 2019 at 1:49 PM JJ Merelo wrote: > Hi, > > El mar., 26 feb. 2019 a las 11:34, Fernando Santagata (< > nando.santag...@gmail.com>) escribió: > >> Hello, >> >> Today I stumbled upon this article: >> >> https://blog.steve.fi/experimenting_with_github_actions.html >> >> the first line of which is: >> >> Recently I heared that travis-CI <https://travis-ci.org/> had been bought >>> out <https://news.ycombinator.com/item?id=18978251>, and later that >>> they'd started to fire their staff >>> <https://news.ycombinator.com/item?id=19218036>. >>> >> >> I'm not a big fan of Travis-CI's. In the past I found out that the Ubuntu >> Xenial perl6 container wrongly redirect to the Precise one; I raised the >> issue on their community forum, since the perl 6 language is >> community-maintained, but I received no feedback so far. [¹] >> > > I use Travis all the time, and it's used by default in the Perl 6 > ecosystem. I don't like the default perl6 travis configuration, which > compiles Perl 6 via rakudobrew every single time. I generally use either a > generic docker container, test-perl6, or custom containers such as the one > created for the ecosystem or the documentation. > >> >> Any thoughts on this topic? Is anyone going to prepare a perl6 recipe to >> use with Github actions? Any other alternative to Travis-CI? >> > > Can you use GitHub actions for CI? If that's the case, we should probably > do that. Are they hosted by GitHub? > Apparently those "actions" are available directly from Github, as reported by the article I quoted. Today I noticed that in the last issue of p6weekly ( https://p6weekly.wordpress.com/2019/02/25/2019-08-inline-scalaring/) Liz writes: Nick Logan added support for CircleCI. > So, yet another possible choice. When $dayjob leaves me some spare time I will give a try to both Github actions and CircleCI. > We also use shippable with the Perl 6 documentation, and Appveyor is also > used here and there. Recently, apparently Circle-CI has been set up to test > Rakudo, so it might be another option. > >> >> >> [¹] I cooked up a solution to that problem. If anyone is interested see >> for example: >> >> https://github.com/frithnanth/Perl6-Desktop-Notify-Progress/blob/master/.travis.yml >> which runs in 1' 11" ( >> https://travis-ci.org/frithnanth/Perl6-Desktop-Notify-Progress), but >> needs continuous updates, since there's no "latest" link in the Perl 6 >> packages page (https://github.com/nxadm/rakudo-pkg/releases) which the >> script uses to install Perl 6 in the container. >> > > > Using either those packages or available docker containers is always > better option than the default travis configuration, from my POV > > Cheers > -- > JJ > -- Fernando Santagata
Travis-CI
Hello, Today I stumbled upon this article: https://blog.steve.fi/experimenting_with_github_actions.html the first line of which is: Recently I heared that travis-CI <https://travis-ci.org/> had been bought > out <https://news.ycombinator.com/item?id=18978251>, and later that > they'd started to fire their staff > <https://news.ycombinator.com/item?id=19218036>. > I'm not a big fan of Travis-CI's. In the past I found out that the Ubuntu Xenial perl6 container wrongly redirect to the Precise one; I raised the issue on their community forum, since the perl 6 language is community-maintained, but I received no feedback so far. [¹] Any thoughts on this topic? Is anyone going to prepare a perl6 recipe to use with Github actions? Any other alternative to Travis-CI? [¹] I cooked up a solution to that problem. If anyone is interested see for example: https://github.com/frithnanth/Perl6-Desktop-Notify-Progress/blob/master/.travis.yml which runs in 1' 11" ( https://travis-ci.org/frithnanth/Perl6-Desktop-Notify-Progress), but needs continuous updates, since there's no "latest" link in the Perl 6 packages page (https://github.com/nxadm/rakudo-pkg/releases) which the script uses to install Perl 6 in the container. -- Fernando Santagata
Re: How to use sub/method 'dir'
I can only argue that since the function's name 'dir' reminds a shell level command, and 'ls a' and 'dir a' work in a certain way, I was expecting that the function 'dir' worked in the same way, following the Principle of Least Surprise :-) On Tue, Nov 27, 2018 at 1:37 AM Trey Harris wrote: > > On Mon, Nov 26, 2018 at 19:26 Trey Harris wrote: > >> >> >> On Mon, Nov 26, 2018 at 04:56 Fernando Santagata < >> nando.santag...@gmail.com> wrote: >> >>> On Sun, Nov 25, 2018 at 5:34 PM Brad Gilbert wrote: >>> >>>> The reason `dir('a', test => { .IO.d })` doesn't work like you expect >>>> is that it is passed strings. >>>> >>> >>> Thank you! >>> I could have inferred that from the declaration of the 'test' argument >>> here https://docs.perl6.org/routine/dir where the test is being done >>> against '.' and '..', two strings: >>> >>> subdir(Cool $path = '.', Mu :$test = none('.', '..')) >>>> method dir(IO::Path:D: Mu :$test = none('.', '..')) >>>> >>> >>> but I guess it's a long stretch. >>> Maybe a note in the docs would be useful to others. >>> >>> >>>> I would argue that inside of the `test` that `$*CWD` should be set to >>>> `a`, and/or the values should be IO objects. >>>> (They are going to become IO objects eventually anyway.) >>>> >>> >>> Indeed I think that even tough one can do any kind of test on the >>> directory's content, the most usual ones are those using the file test >>> operators, so defaulting to IO is probably more useful than defaulting to >>> Str. >>> >> >> I'm not sure that's true. I think it's a question of following the >> Principle of Least Surprise. >> >> The only substantive difference between `my $i = "foobar".IO` and `my $s >> = "foobar"` besides needing to stick the `.IO` in when you want to do IO-y >> things with `$s` is that `$i` retains the knowledge of $*CWD at the time of >> instantiation. But `dir` always returns paths that stringify _relative to >> `$*CWD` at the time of the `dir` call._ Notice the difference between >> `$i.gist` (which, if evaluated, will not consistently re-create the >> original object) and `$i.perl` (which will): >> >> > $f.gist >> "foobar".IO >> > $i.perl >> IO::Path.new("foobar", :SPEC(IO::Spec::Unix), >> :CWD("/home/trey/perl6/rakudo-star")) >> > chdir "/tmp" >> "/tmp".IO >> > $f.gist >> "foobar".IO >> > $i.perl >> IO::Path.new("foobar", :SPEC(IO::Spec::Unix), >> :CWD("/home/trey/perl6/rakudo-star")) >> > > Oops, ignore the changing variable names here; I was copying lines from a > REPL session where I'd used `$f`, and then I changed `$f` to match `$i` in > the text before it and didn't fully complete the renaming. It's just a > single variable. > > >> The string, OTOH, is also relative to the `$*CWD` at the time of the >> `dir()` call, but if you call `.IO` on it after changing directories, the >> path object is interpreted relative to the new directory. This is >> unsurprising; what _would be_ surprising is if a string changed as a result >> of external program state. >> >> Large-scale file-munging operations have always been squarely in Perl's >> wheelhouse, and doing fancy operations with complex subtrees (such as >> syncing, normalizing, archiving, collating, etc.) are common. >> >> The string doesn't offer as much in the way of features, but I think it >> behaves much more predictably when doing these sorts of operations. If you >> `chdir $dest` after the `dir` but before doing your munging, then you must >> remember to prepend the old working directory if you need to access the >> original file (i.e., `$src = $*CWD; for @files -> $f { $src.add($f) ... >> }`), while the new files would just be `$f`. If you don't change >> directories, then you must say `$dest.add($f)` to refer to the new files, >> while the old file is just `$f`. But in either case, it's unsurprising and >> predictable. >> >> If, OTOH, these were IO objects, if you changed directories, you'd think >> from the gist that you'd do the same. And if you don't change directories, >> you _could_ do the same (`$dest = "/destdir".IO; $dest.add($f)` works using >> the gist). But if you do change directories, it's now the _old file_ that's >> just `$f`; the new file beco
Re: How to use sub/method 'dir'
On Sun, Nov 25, 2018 at 5:34 PM Brad Gilbert wrote: > The reason `dir('a', test => { .IO.d })` doesn't work like you expect > is that it is passed strings. > Thank you! I could have inferred that from the declaration of the 'test' argument here https://docs.perl6.org/routine/dir where the test is being done against '.' and '..', two strings: subdir(Cool $path = '.', Mu :$test = none('.', '..')) > method dir(IO::Path:D: Mu :$test = none('.', '..')) > but I guess it's a long stretch. Maybe a note in the docs would be useful to others. > I would argue that inside of the `test` that `$*CWD` should be set to > `a`, and/or the values should be IO objects. > (They are going to become IO objects eventually anyway.) > Indeed I think that even tough one can do any kind of test on the directory's content, the most usual ones are those using the file test operators, so defaulting to IO is probably more useful than defaulting to Str. -- Fernando Santagata
Re: How to use sub/method 'dir'
To further clarify, what I did to prepare this test is: mkdir -p test/a/b cd test echo > a/c On Sun, Nov 25, 2018 at 11:11 AM Fernando Santagata < nando.santag...@gmail.com> wrote: > Here's output of 'a/b'.IO.d from the REPL: > > > 'a/b'.IO.d > True > > On Sun, Nov 25, 2018 at 1:52 AM Timo Paulssen wrote: > >> The dir method gives you entries in the directory you pass. If you don't >> pass a test it'll use the default test which is none(".", ".."), i.e. >> "anything except . and ..". >> >> I'm not sure why using { .IO.d } as the test would not give you b, >> though. Can you check what "a/b".IO.d outputs? Maybe that can give us a >> clue. >> >> HTH >> - Timo >> On 24/11/2018 22:18, Fernando Santagata wrote: >> >> Hello, >> >> I think that I don't understand how the 'test' argument of 'dir' works. >> I have a directory 'a', which contains a subdirectory 'b' and a file 'c'; >> I want to select only the subdirectories of 'a'. >> >> Using the REPL I tried to ask the content of the directory 'a': >> >> > my @dirs = dir('a') >> ["a/c".IO "a/b".IO] >> > my @dirs = dir('a', test => { .IO.d }) >> ["a/.".IO "a/..".IO] >> Why omitting the test the code returns the right list, while adding the >> test it returns just '.' and '..'? >> >> If I do the same thing for the top level directory '.' the behavior is >> different: >> >> > my @dirs = dir('.', test => { .IO.d }) >> [".".IO "a".IO "..".IO] >> >> Now I can see the directory 'a'. >> If I descend a level, doing a 'cd a', the behavior is consistent with >> what I see at the previous level. >> I'm confused. >> >> I'm using version 2018.10. >> >> -- >> Fernando Santagata >> >> > > -- > Fernando Santagata > -- Fernando Santagata
Re: How to use sub/method 'dir'
Here's output of 'a/b'.IO.d from the REPL: > 'a/b'.IO.d True On Sun, Nov 25, 2018 at 1:52 AM Timo Paulssen wrote: > The dir method gives you entries in the directory you pass. If you don't > pass a test it'll use the default test which is none(".", ".."), i.e. > "anything except . and ..". > > I'm not sure why using { .IO.d } as the test would not give you b, though. > Can you check what "a/b".IO.d outputs? Maybe that can give us a clue. > > HTH > - Timo > On 24/11/2018 22:18, Fernando Santagata wrote: > > Hello, > > I think that I don't understand how the 'test' argument of 'dir' works. > I have a directory 'a', which contains a subdirectory 'b' and a file 'c'; > I want to select only the subdirectories of 'a'. > > Using the REPL I tried to ask the content of the directory 'a': > > > my @dirs = dir('a') > ["a/c".IO "a/b".IO] > > my @dirs = dir('a', test => { .IO.d }) > ["a/.".IO "a/..".IO] > Why omitting the test the code returns the right list, while adding the > test it returns just '.' and '..'? > > If I do the same thing for the top level directory '.' the behavior is > different: > > > my @dirs = dir('.', test => { .IO.d }) > [".".IO "a".IO "..".IO] > > Now I can see the directory 'a'. > If I descend a level, doing a 'cd a', the behavior is consistent with what > I see at the previous level. > I'm confused. > > I'm using version 2018.10. > > -- > Fernando Santagata > > -- Fernando Santagata
How to use sub/method 'dir'
Hello, I think that I don't understand how the 'test' argument of 'dir' works. I have a directory 'a', which contains a subdirectory 'b' and a file 'c'; I want to select only the subdirectories of 'a'. Using the REPL I tried to ask the content of the directory 'a': > my @dirs = dir('a') ["a/c".IO "a/b".IO] > my @dirs = dir('a', test => { .IO.d }) ["a/.".IO "a/..".IO] Why omitting the test the code returns the right list, while adding the test it returns just '.' and '..'? If I do the same thing for the top level directory '.' the behavior is different: > my @dirs = dir('.', test => { .IO.d }) [".".IO "a".IO "..".IO] Now I can see the directory 'a'. If I descend a level, doing a 'cd a', the behavior is consistent with what I see at the previous level. I'm confused. I'm using version 2018.10. -- Fernando Santagata
Re: Nesting pod6 formatting codes
Thank you! BTW, the use of double angle brackets is not documented. On Tue, Nov 6, 2018 at 4:12 PM Will Coleda wrote: > You can increase the # of <<'s : > > C<<$*PERL.compiler.version < v2018.09>> > > Or you can use unicode: > > C«$*PERL.compiler.version < v2018.09» > > > On Tue, Nov 6, 2018 at 6:38 AM Fernando Santagata > wrote: > > > > Hi, > > > > Here: > > > > https://docs.perl6.org/language/pod#Formatting_codes > > > > I read this: > > > >> Formatting codes may nest other formatting codes. > > > > > > but when I try this: > > > > C<$*PERL.compiler.version E<0x3C> v2018.09> > > > > p6doc outputs this: > > > >> $*PERL.compiler.version E<0x3C> v2018.09 > > > > > > instead of $*PERL.compiler.version < v2018.09 > > > > Did I misunderstand the whole nesting thing? > > Is there any other way to include a '<' character inside a formatting > code? > > > > Thank you! > > > > -- > > Fernando Santagata > -- Fernando Santagata
Nesting pod6 formatting codes
Hi, Here: https://docs.perl6.org/language/pod#Formatting_codes I read this: Formatting codes may nest other formatting codes. > but when I try this: C<$*PERL.compiler.version E<0x3C> v2018.09> p6doc outputs this: $*PERL.compiler.version E<0x3C> v2018.09 > instead of $*PERL.compiler.version < v2018.09 Did I misunderstand the whole nesting thing? Is there any other way to include a '<' character inside a formatting code? Thank you! -- Fernando Santagata
Re: Run tests only if a module is available
Thank you, it's what I needed! On Fri, Oct 12, 2018 at 1:12 AM Timo Paulssen wrote: > I'd go with run-time loading and if the module doesn't exist, just "flunk" > or "skip" or what Test.pm6 offers. > > Here's a link that explains checking if a module is installed and loading > it if it is: > > https://rakudo.org/post/lexical-require-upgrade-info > > Hope that helps! > - Timo > On 11/10/2018 19:08, Fernando Santagata wrote: > > Hello, > > I wish to run some tests on one module of mine only if there's a certain > third-party module available during installation. > Before I concocted something horrid using try/catch in the INIT phaser, is > there any gentle way to do this? > > Thanks! > > -- > Fernando Santagata > > -- Fernando Santagata
Run tests only if a module is available
Hello, I wish to run some tests on one module of mine only if there's a certain third-party module available during installation. Before I concocted something horrid using try/catch in the INIT phaser, is there any gentle way to do this? Thanks! -- Fernando Santagata
Re: eof ?
The answer Laurent Roseenfeld gave you works for read and readchars as well. Save the following lines in a file and run it (try and change .read into .readchars too); it will output a series of 10-byte long Buf[uint8]s, until it reaches the end of file. #!/usr/bin/env perl6 given $*PROGRAM-NAME.IO.open { while my $bytes = .read: 10 { $bytes.say; } } On Tue, Oct 9, 2018 at 10:17 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 10/9/18 1:02 AM, ToddAndMargo via perl6-users wrote: > > Hi All, > > > > When reading a text file > > https://docs.perl6.org/routine/lines > > seems pretty straight forward. > > > > Question: How do I tell when I when I have > > reached the EOF (End Of File)? > > > > Many thanks, > > -T > > Please expand the question to include `read` and `readchars`. > -- Fernando Santagata
Re: A problem with native CArrays
Thank you for the clarification! On Mon, Oct 1, 2018, 05:54 Brad Gilbert wrote: > The [+] works because of an optimization. > > If you use the core :<+> it instead calls the .sum() method. > > Since CArray has a sum method, that gets called instead. > On Sun, Sep 30, 2018 at 4:28 AM Fernando Santagata > wrote: > > > > Hi, > > > > I was hunting for a bug in my code, this one: > > > > my @a := CArray[int32].new: 6,3; > > say [+] @a; # it should be "say [+] @a.list;" > > > > That statement prints "9", while changing the '+' with a '*' it > generates an error, as it should: > > > > Cannot resolve caller Numeric(NativeCall::Types::CArray[int32]: ); none > of these signatures match: > > (Mu:U \v: *%_) > > > > Is this a bug, an inconsistency, or a necessary evil? > > > > -- > > Fernando Santagata >
Re: A problem with native CArrays
What I was pointing out is that the '*' operator outputs an error, and I was expecting that, while the '+' doesn't. Besides, the '+' delivers the correct result, which apparently indicates that the two operators are treated differently. I was trying to understand whether this behavior is inherent to the Perl 6 type system or it's just a bug. On Sun, Sep 30, 2018, 12:27 JJ Merelo wrote: > This works: > > my int32 $a = 3; my int32 $b = 7; say $a * $b # OUTPUT: «21» > > El dom., 30 sept. 2018 a las 11:28, Fernando Santagata (< > nando.santag...@gmail.com>) escribió: > >> Hi, >> >> I was hunting for a bug in my code, this one: >> >> my @a := CArray[int32].new: 6,3; >> say [+] @a; # it should be "say [+] @a.list;" >> >> That statement prints "9", while changing the '+' with a '*' it generates >> an error, as it should: >> >> Cannot resolve caller Numeric(NativeCall::Types::CArray[int32]: ); none >> of these signatures match: >> (Mu:U \v: *%_) >> >> Is this a bug, an inconsistency, or a necessary evil? >> > > It's difficult to say. Some conversion is taking place somewhere to > Numeric, and it's getting stuff it does not like. The type is > NativeCall::Types::CArray[int32].new and it's being considered a single > item; it's attempting conversion to Numeric. The thing here is that CArray > is actually not an Array; it inherits directly from Any: > > say @a.^mro; # OUTPUT: «((CArray[int32]) (CArray) (Any) (Mu))» > > It does include a `list` for convenience, but it's not, by itself, a list. > That operator does not do the conversion, but expects it to be a list, > hence the error. > > Hope this helps > > JJ >
A problem with native CArrays
Hi, I was hunting for a bug in my code, this one: my @a := CArray[int32].new: 6,3; say [+] @a; # it should be "say [+] @a.list;" That statement prints "9", while changing the '+' with a '*' it generates an error, as it should: Cannot resolve caller Numeric(NativeCall::Types::CArray[int32]: ); none of these signatures match: (Mu:U \v: *%_) Is this a bug, an inconsistency, or a necessary evil? -- Fernando Santagata
Re: Information about Perl 6 internals
Thank you for answering, Your digression about PDL was very much appreciated. About the module I'm writing, the raw interface to the library is almost complete, but I need more time to work on the high level interface and right now I have little time, due to $job, so don't hold your breath :-) You wrote "You can still access it as a CArray if you allocate it yourself;"can you share any hint on how to make a CArray point to a Pointer? NativeHelpers::Blob doesn't seem to help, even if there are some ideas in there that might be adapted to the problem at hand. Thank you! On Thu, Sep 20, 2018 at 6:51 PM Curt Tilmes wrote: > I haven't seen many responses to this yet. I am by no means a > MoarVM/NQP/Rakudo internals expert, speaking only as a developer on top of > those things, not inside them. > > On Sun, Sep 16, 2018 at 8:12 AM Fernando Santagata < > nando.santag...@gmail.com> wrote: > >> I'm developing an interface to libfftw3 (Fastest Fourier Transform in the >> West). >> The library provides a function to allocate SIMD-aligned memory (Single >> Instruction Multiple Data), in order to maximize access speed to data. >> Before I start to investigate a way to blandish a CArray into pointing to >> a stretch of previously allocated memory, how does Perl 6 allocate memory? >> Does it already use the SIMD alignment? >> > > I think efforts like this are important for Perl 6. Things like PDL were > 'tacked on top' of Perl 5, while I think with 'native' types, the long term > goal is to have such things more integrated. NativeCall,, 'is native', > CArrays, etc, have been huge steps in that direction, but I think there is > much work to go. > > I've had very good luck using NativeCall, keeping everything in C land, > and having in/out methods to transform things, but less luck trying to keep > the data structures straight between the two. That feels like the old PDL > way. I want to construct huge multi-dimensional arrays of native types in > Perl 6 and seamlessly call NativeCall functions on it (like fftw) and also > auto-parallelized, optimized Perl 6 operations for plain math. We're not > quite there yet. > > Something to keep in mind. If you allocate memory from Perl, the garbage > collector may move it around on you. Always get a fresh C pointer to it > just prior to passing to any NativeCall function. Another option is to > just allocate (and free -- you are responsible for it) from C, either with > some library allocation function, or just plain NativeCall malloc()/free() > and friends. It will never move around, and you can still use a bunch of > Perlish ways (Pointer, CArray, etc.) to read and manipulate it. > > I don't know the answer to your SIMD alignment question, but I suspect the > answer is no. If that is a requirement for your library (or performance), > you probably just want to allocate it yourself. You can still access it > as a CArray if you allocate it yourself. > > If you are doing some action heavily and find it slow, build a tiny test > case to illustrate and file a bug. That will give the folks with the > implementation knowledge some guidance for what would really help you. > > There is a lot of work still needed, but things have come very far already > and are moving fast. The fundamental architecture was designed to support > numeric work in the manner you will be doing, so there is a lot of room for > improvement, especially with multi-threading, long after Perl 5 PDL, NumPy > and friends have run out of gas. > > Since I'm here :-) will Perl 6 ever support a native type mirroring the >> __float128 quadruple-precision type provided by gcc? >> > > I'll wager that the answer to "ever support" is probably yes, as long as > somebody wants it. We're just waiting for the same person to be in the > "wants it" and "can do it" category at the same time. > > Curt > > -- Fernando Santagata
Re: Is this a bug?
Should I report this here: https://github.com/rakudo/rakudo/ or there's a specific location for the REPL? On Sun, Sep 16, 2018 at 2:28 PM Elizabeth Mattijsen wrote: > Definitely a bug. Which seems to be limited to the REPL only, fortunately. > > > On 16 Sep 2018, at 12:57, Fernando Santagata > wrote: > > > > Hello, > > > > I found this behavior quite strange: > > > >> my int32 $a = 2 > > 2 > >> $a.^name > > Int > >> $a.WHAT > > At Frame 1, Instruction 20, op 'getlex_ni', operand 0, MAST::Local of > wrong type (3) specified; expected 4 > > > >> my num64 $b = 1.23e-2 > > 0.0123 > >> $b.^name > > Num > >> $b.WHAT > > (Num) > > > > This is Rakudo version 2018.08 built on MoarVM version 2018.08 > > > > -- > > Fernando Santagata > -- Fernando Santagata