🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
raku-bridge <theangryepicbanana> lizmat: idk what newdisp is, but thanks for the help :) 00:58
guifa2 o/ 04:49
tellable6 2020-12-16T12:10:57Z #raku <lizmat> guifa2 as the original creator of `callwith`, I think it has been a mistake to make it (at least as it currently is implemented)
2020-12-16T12:11:20Z #raku <lizmat> guifa2 so I would be in favour of deprecating callwith, hope this helps
guifa2 lizmat: I t 04:50
lizmat: that might be, but it seems the issue is more than once code is wrapped, if it somehow gets precompiled, the original one is lost. For instance, I tried using my &foo = nextcallee; foo(…); but it seems to give that same error. I'm not sure where to start digging to track down the issue though 04:52
(callsame has the same issue too). I'll try to golf it and get the issue into the new issue tracker 04:54
elcaro todays AOC could largely be done by creating custom infix ops `p` and `t` that are assoc<left> versions of `+` and `*`, then just EVAL 06:00
elcaro but it feels like cheating :) 06:00
eg. '8 * 3 + 9 + 3 * 4 * 3'.trans('+*' => 'pt').&EVAL 06:02
lizmat drops a pin 11:52
moritz catches the pin before it hits the channel floor 11:58
tadzik quickly, someone integrate 9.81m/s² over 6 minutes and we'll see how tall (at least!) the channel is :P 12:02
moritz don't forget the air drag, which increases proportionally to v² :D 12:09
without air drag, we're at about 636km 12:11
tadzik oh no
see, here's where my university physics introduction, with it's continuous "ignore the air drag" becomes insufficient :P 12:12
timotimo just google the cw value and use the terminal velocity as a good enough approximation :) 12:14
moritz or you could work with the proper diffential equations, and integrate them numerically. Pretty easy with Math::RungeKutta for example (to bring us back to topic :D ) 12:25
lizmat afk for a few hours& 12:37
tony-o .tell jmerelo fyi: github.com/ugexe/zef/pull/378 17:31
tellable6 tony-o, I'll pass your message to jmerelo
Henri Okay, so I'm a Raku beginner. I'm trying to parse a CSV file and I have a few questions. 17:47
pastebin.com/C4FGN37H
I get the error that: The iterator of this Seq is already in use/consumed by another Seq.
And I understand the error, but am unsure how to fix it.
I tried to pull out the iterator object underneath, but then map did not type-check against the iterator object.
Henri Also, earlier I tried to write my multi as read-csv($filename, True) and read-csv($filename, False) as one might do in Haskell, but this did not work and was rather painful to fix. 17:48
Could someone help me out?
I'm a bioinformatics researcher and I am looking for a good functional language to do my work. 17:50
tony-o the dispatcher won't do guards
you can kind of emulate guards with `where` in the signature
Henri Python is nice, but just doesn't cut it. I'm used to the expressiveness of Clojure/Racket.
tony-o I thought you could do stuff like fact(0) = 1 17:51
tony-o m: multi sub x (Bool $x where { $_.so }) { True.say; }; multi sub x (Bool $x where { ! ($_.so) }) { False.say; }; x(True); x(False);
camelia True
False
Henri Interesting, the solution I have works now, and it kind of does the same thing, but it doesn't have the .so 17:54
What is the importance of that?
patrickb tony-o: Is 360.zef.pm already running on the new proto eco? 18:02
tony-o patrickb: yes 18:03
Henri: testing it, seems it's not as important anymore but evaulating junctions or other things used to warn that ! $x might not do what you'd think
i do like lisps and haskell quite a bit 18:04
Henri yes i just have the problem that they aren't scriptable for some of my needs
clojure you have to create a whole project and then run the JVM to start it up 18:05
haskell well, that has it's own difficulties
tony-o i liked clojure up to the jvm part
Henri i appreciate the JVM for the most part
perryprog I actually like that part of Clojure
Henri offers tons of great libraries
perryprog It gives you access to—yeah that
Henri seamless interop
tony-o that part is really nice
patrickb and 32.zef.pm is also the new backend, but imported p6c?
Henri have you guys been using Raku for a lot of tasks? 18:06
tony-o 32.zef.pm is p6c - 360.zef.pm is zef: auths but requires you to register/login and upload with the zef: auth
tony-o the tool for doing those last three actions is WIP, i can invite you to the repo if you'd like to contribute 18:07
patrickb am interested
tony-o Henri: i mainly use perl/python for work, wrote a lisp-ish language in C, goof around stuff in raku 18:07
tony-o patrickb: are you patrickb or Patrickb on github? 18:09
patrickb tony-o: patrickbkr
tony-o invite sent
Henri tony-o I've never actually tried perl5 before 18:10
tony-o Henri: where is the Seq error in your code?
what line, i mean
Henri I figured it out!
it was with hdr
because i was realizing it multiple times 18:11
so i just added a .cache on line 5
tony-o gotcha
if you end up releasing your csv as a module check out tux's benchmark repo for csv parsers
Henri yes maybe I could if I end up using it enough 18:12
i think that raku could do with a lot of bioinformatics features
so i might make a little library for myself and push it out there
how's your experience working with grammars? 18:13
that seems to be the most attractive feature to me
tony-o grammars are slow (imo) but really powerful and pretty fun to play around with 18:14
github.com/tony-o/perl6-slang-sql
Henri speed is definitely a concern for me.
what about the regex engine?
would you say that's speedy 18:15
most of the formats I parse are line-based, so it's not really necessary to build a tree-based grammar for it
tony-o i'd test it to see if the regex suits your needs, if it doesn't then nativecall+raku is awesome to work with 18:16
speed benefits of C and the ease of use with interacting with the data in an hll is top 18:17
Henri thanks for the tip. 18:22
i'll check that out
Doc_Holliwood is this cheating? 18:32
github.com/holli-holzer/advent2020...uzzle.raku
moritz Doc_Holliwood: I consider it technique :D 18:41
rjbs Is it "Rah-ku" or "Ray-ku" and is this documented? 19:31
Grinnz i go with what this says translate.google.com/?sl=ja&tl...=translate 19:32
tony-o if i ever say it aloud i say it like he beginning of raccoon 19:46
warriors hi 19:48
warriors names that start with ^ what are those called, are they methods ? 19:53
tony-o they're part of the mop 19:58
docs.raku.org/language/mop
warriors thanks 19:59
Henri currying?
what's the standard strategy for this...
warriors is this why .attributes dont return them ?
tony-o Henri: do you have an example? there's array/hash flattening but it isn't purely currying 20:00
warriors: what is "them?"
Henri i have multi called parse-grna-row(Doench, %row, $idx) 20:01
warriors ^ names ( what do call this symbol by the way ^)
Henri and row is either declared as %row or @row, and I want to dynamically figure out at runtime which one it is :)
Henri so I think I can partially apply to first argument (an enum type) and then look at the resulting functions argument types 20:01
tony-o m: sub add ($a, $b) { say $a + $b ; }; my @a = 1, 2; add(|@a);
camelia 3
tony-o a ^ is called a caret 20:02
the dispatcher will pick the right method for @|% if your signatures are that way.. if you want to tell at runtime what a scalar is you can do $x ~~ Hash 20:03
Henri Oh nice!
Can I do the same thing for return types?
tony-o m: multi sub x(%a) { say "hash"; }; multi sub x(@a) { say "array"; }; my @a = 1, 2; my %a = 5, 1, 6, 2; x(@a); x(%a); 20:04
camelia array
hash
tony-o say more. 20:05
Henri tony-o that makes sense
say something similar, but instead my @a = sub(1) would call the array version
and my %a = sub(1) would call the hash version
tony-o what is sub(1) ? 20:06
Henri x(1)*
sorry
same input type, different return value type
warriors so why .methods dont return caret names ? and why does it return WHICH but not WHAT, in general I am trying to identify the different types of things that can have names in raku, i know for introsepection we have .methods and .attributes , but apparently they is more kinds of things, 20:07
Henri instead of your example, different input type
tony-o i don't think it could work that way 20:08
vrurg Henri: No, Raku do not dispatch depending on calling context. But you can use pass an array or a hash as a parameter and modify it in your sub. 20:11
tony-o warriors: once you're in the MOP you're in the introspection bits of raku. if you're looking for the functionality provided by _something_ then use .^mro and then inspect the raku source to figure out what else is immediately available on it. .attributes and .methods don't show up because the MOP isn't showing what it can do but the object you're calling it on 20:12
vrurg warriors: Because .^ methods belong to metamodel namespace.
warriors: WHICH is a method, WHAT is a shortcut to the core which is handled by compiler and results not in a method call but in specific bytecode. 20:13
warriors so what is WHAT exactly
a keyword
syntax? 20:14
vrurg warriors: I don't have a term for it. But "syntax" would be the closest one, perhaps. Same thing about HOW.
warriors a keyword
vrurg In fact, $obj.WHAT is nqp::what($obj). $obj.HOW is nqp::how($obj) 20:15
warriors its part of the language, not a type of thing we can define
vrurg warriors: no, it is not because a keyword exists on its own but these are method-like entitites.
tony-o warriors: this might be helpful - github.com/rakudo/rakudo/blob/0290...l.pod#L286 20:16
warriors thanks
vrurg BTW, documentation call them 'reverved methods
docs.raku.org/language/typesystem#...ed_method)
class Foo { method ^foo { } }; say Foo.HOW.^methods 20:18
evalable6 (foo archetypes new new_type add_fallback compo…
vrurg, Full output: gist.github.com/2dc7a79b5a2a21afa3...4cafd408c9
vrurg warriors: ^ with regard to carret methods
Henri is there a stdout/stderr IO::Handle? 20:54
lizmat $*OUT 20:57
$*ERR
ggoebel www.reddit.com/r/adventofcode/comm...;context=3 21:13
tellable6 2020-12-17T04:13:46Z #raku <coldpress> ggoebel: native types are really so much faster!
ggoebel oops sorry
moon-child why is that, though? Int should involve one (correctly predicted, so effectively free) branch per arithmetic op for as long as they're in the range of a native type 21:20
moritz because you first need a run-time dispatch to reach the actual numerical operation 21:56
Henri For calling methods you can either use obj.method: a or obj.method(a) correct? 22:11
raku-bridge <theangryepicbanana> Henri: yes 22:21
leont Is there a built-in way to split a list into a list of lists, based on some separator? 22:34
moon-child m: print [1, 2, 3, 0, 1, 0, 2].split(0) 22:36
camelia 1 2 3 1 2
leont That coerces to a string first 22:37
leont r: sub split-list(@args is copy) { return gather { while @args { my @elems; while @args.shift -> $next { if $next eq "|" { take @elems.clone; @elems = () } else { push @elems, $next } }; LAST { take @elems if @elems} } } }; dd split-list <a b c | d e | f g 22:46
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in quote words; couldn't find final '>' (corresponding starter was at line 1)
at <tmp>:1
------> 3 } } }; dd split-list <a b c | d e | f g7⏏5<EOL>
expecting any…
5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in quote words; couldn't find final '>' (corresponding starter was at line 1)
at <tmp>:1
------> 3 } } }; dd split-list <a b c | d e | f g7⏏5<EOL>
expecting an…
leont r: sub split-list(@args is copy) { return gather { while @args { my @elems; while @args.shift -> $next { if $next eq "|" { take @elems.clone; @elems = () } else { push @elems, $next } }; LAST { take @elems if @elems} } } }; dd split-list <a b c | d e | f g>
camelia (["a", "b", "c"], ["d", "e"], ["f", "g"]).Seq
leont It works, but it feels like there should be a more elegant way
elcaro gist.github.com/0racle/c57fc86a0a0...8a435872b1 23:20
leont: gist.github.com/0racle/c57fc86a0a0...8a435872b1
I too was playing around with a `split-on` function recently (i think i saw something in haskell) 23:21
none of the functions are particularly elegant, but I think B benched the fastest (B and C were pretty close, A was significantly slower)
leont B is also the one I'd find most intuitive 23:22
Henri is there a mutating version of map, or is that what the map method does? 23:23
moon-child Henri: you can use @arr .= map(&fun) 23:24
it doesn't mutate (if perf/mem use is a concern), but is otherwise a concise way to say the same thing
elcaro or if you have a list of containers, you could do .map(-> $x is rw { ... })
Henri moon-child thank's that's helpful
i'm liking raku a ton, it seems like a great alternative to bash :) 23:25
MasterDuke leont: have you looked at classify and categorize? 23:28
leont Yeah, but they don't quite do what I want 23:29
I think I could write an implementation on top of them, but I don't see a way that's more elegant than the current options
leont Also, is there a clean way to concatenate regexes? 23:43
moon-child m: my regex a { 'beep' }; my regex b { 'boop' }; print 'beepboop' ~~ /<a><b>/; 23:45
camelia beepboop
leont No I mean I literally have an array with regexp objects, and I want to make them one regexp
Preferably without having to eval stuff
leont Currently I'm doing this: sub join-regex(@terms) { my $base = ''; for @terms -> $term { $base = rx/$base$term/; } return $base;} 23:47
Doesn't appear to work, and calling dd on such a regexp just gives me «rx/$base$term/», which doesn't help me figure out what's going wrong
moon-child m: my @regecide = /beep/, /boop/; print 'beepboop' ~~ @regecide.reduce(-> $x, $y { /$x$y/ }) 23:48
camelia beepboop
leont Of course, reduce 23:49
moon-child which being said, I don't see why your solution wouldn't work 23:50
perhaps $base should be initialized to //
/''/ rather
aukkras p6: say <1 2 3>.map(-> $x {$x <=> 2}); 23:54
camelia (Less Same More)
aukkras is there more concise way to do the above ? something like: say <1 2 3> <=> 2;
moon-child m: print <1 2 3> «<=>» 2 23:56
camelia Less Same More
moon-child »<=>» is better, actually
and you can use << and >> in place of « and » 23:57
aukkras ok, thanks
is <<<=>>> a concatenation of few operators ? <<, <=> and >> ? 23:58
superspaceship operator :) 23:59
moon-child it's the « » hyperoperator
or » »
docs.raku.org/language/operators#H..._operators
aukkras thanks again :)