🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
tonyo m: use Test; my \a := Test; dd a::<&output> #leont this seems to work 02:52
camelia Sub output = sub output { #`(Sub|4666691861120) ... }
tbrowder__ tonyo: thnx 12:23
i'm trying to use >>. on a hash of hashes and can't quite get the syntax right. i would appreciate anyone's eyes on the gist to see what needs to be done: 12:25
gist.github.com/tbrowder/b59566957...c03cc21db8
got to leave for a while, thans 12:26
*thanks
guifa_ [ a => 1, b => 2] constructs an array of hashes, rather than a hash of hashes 12:35
Nemokosch it's important to note that this is not a hash and that affects the observed behavior radically
guifa_ m: my $h = [a => {:1x, :2y}, b => {:4x, :8y}]; say $h.WHAT;
camelia (Array)
Nemokosch this is an array
guifa_ ANd also, ».map is basically mapping it twice
if you do %foo».bar, it'll run bar on each element of %foo, that is, on each pair. If you do %foo».map(*.bar), it'll run bar on each element of each element of %foo 12:36
and you have %foo».map( *».map( … ) ), which is each element of each element of each element of each element of %foo 12:37
Nemokosch > if you do %foo».bar, it'll run bar on each element of %foo, that is, on each pair not exactly. It will run bar on each value in %foo, regardless of the corresponding key 12:40
oh, and even that isn't accurate because >>.bar might even recurse over that value 12:42
m: my %foo = a => [1, 2], b => 3; %foo>>.say;
Raku eval 3 1 2
Nemokosch it's safe to say regardless that >>.map is a striking anti-pattern 12:46
Anton Antonov Maybe this was reported already — installing with zef from the 360.zef,pm hangs. 13:26
I noticed that last night; this morning too. 13:27
I found this: vc.ru/u/144173-kirill-belov/685482...peterburge 13:33
(Sorry, for my previous post — wrong channel/forum.) 13:36
tbrowder__ ref my gist, WOW, the fact that is an array is surprising to me. no wonder i'm having trouble. i have been using that construct for years and not had any problems. i need to buy a lottery ticket! 15:09
i vaguely remember discussions about %() and {} but not how it all ended. 15:10
back to the drawing board. thanks a heap, guifa 15:12
m: %h = [a => {:1x, :2y}, b => {:4x, :8y}]; say $h.WHAT; 15:15
camelia ===SORRY!=== Error while compiling <tmp>
Variable '%h' is not declared. Perhaps you forgot a 'sub' if this was
intended to be part of a signature?
at <tmp>:1
------> <BOL>⏏%h = [a => {:1x, :2y}, b => {:4x, :8y}];
tbrowder__ m: my %h = [a => {:1x, :2y}, b => {:4x, :8y}]; say $h.WHAT;
camelia ===SORRY!=== Error while compiling <tmp>
Variable '$h' is not declared. Did you mean '%h'?
at <tmp>:1
------> [a => {:1x, :2y}, b => {:4x, :8y}]; say ⏏$h.WHAT;
tbrowder__ m: my %h = [a => {:1x, :2y}, b => {:4x, :8y}]; say %h.WHAT;
camelia (Hash)
tbrowder__ ok, that's what i've been using, with the % sigil 15:16
whew!
i guess i should ask, when should one use the $ for hashes, i see it all the time 15:17
lizmat m: my %h = a => {:1x, :2y}, b => {:4x, :8y}; # don't need the [ ] 15:18
camelia ( no output )
lizmat m: my %h = a => {:1x, :2y}, b => {:4x, :8y}; dd %h
camelia Hash %h = {:a(${:x(1), :y(2)}), :b(${:x(4), :y(8)})}
lizmat a hash contains containers as values: if you have nested hashes, the containers make them itemized because the hash then lives inside a container in a hash valiue 15:19
*value
tbrowder__ thnx, lizmat 15:20
bye for now
lizmat ack
rf morning folks 15:27
lizmat rf almost evening here :-)
rf In your case, good evening :) 15:28
lizmat thank you, good morning ! :-) 15:49
tbrowder__ guifa: going back to my gist $h, and changing it to %h, what is the syntax to multiply each numerical value in the hash/hash by the same factor. that is the structure i have to deal with (not my choice). 15:55
i can do it the easy way, but i would like a shorter solution using map or whatever it requires. 15:58
lizmat m: my %h = :a{:42a, :666b}; dd %h.deepmap({ $_ = $_ * 7 }) 16:05
camelia {:a(${:a(294), :b(4662)})}
tbrowder__ lizmat, cool! 16:11
lizmat docs.raku.org/routine/deepmap
tbrowder__ m: "thank you!".say for 1..10
camelia thank you!
thank you!
thank you!
thank you!
thank you!
thank you!
thank you!
thank you!
thank you!
thank you!
lizmat yw :-)
tbrowder__ some of what's confusing me in the docs is i see reference to map using deepmap somehow and i 16:13
didn't think i needed to look into using it directly. 16:14
lizmat until I looked at optimizing deepmap, I didn't know of its existence either, if that's any consolation :-) 16:15
tbrowder__ yes, but i think both need good, practical examples in the docs. 16:17
back to coding...see y'all later 16:18
lizmat not disagreeing :-)
Nemokosch Frankly, whatever you think of this fact, Raku is a language that invites you to be creative. The language is too big to reasonably write down every combination of features that somebody might find useful. 16:56
and it's definitely not the fault of the documentation that somebody proceeds to think [pair1, pair2, pair3] was a hash. There is no implication of that anywhere, and [...] is described as an "array maker" 16:57
tbrowder__ Nemokosh, I have used that construct for many years. i never thought of it as a "hash maker", i always thought of it as a hash boundary when i created my own hashes, *always* with a % sigil. early on the {} was warned about as not creating a hash, and %() seemed like too much typing for me. i also know arrays and hashes don't usually need () or {} but i still use them often in my code. 17:25
and speaking as a user of raku since 2015, but not an expert, the docs have improved greatly due the hard work of a lot of people, but good examples are always helpful, especially for less-used features such as deepmap and map. 17:28
Nemokosch that's fair enough in that particular case, I just see this discrepancy between the attitude the language basically mandates, and the role several people seem to read into the documentation 17:31
tbrowder__ such as? 17:35
the intentional tmtowtdi feature is alive and well in raku 17:36
fer sure 17:37
imho, much of the docs could be clearer, the examples too "cute" sometime and adding a new twist in the middle of a basic example. see oo for example 17:39
gotta go, good day to all
Nemokosch I see people, even fairly familiar with Raku as a language and as a project, thinking that they - or anyone else, for that matter - can learn Raku only/mostly by reading the documentation 18:03
it's not (only) a criticism of the documentation that this is not possible 18:04
By design, Raku is not really a language that you can "document" in that sense 18:05
tbrowder__ i don't disagree, but the docs, along with The Raku Guide are certainly good enough to get one started. but you're right, one must use the code to really learn. and imho that applies to most any language that i have any experience with. 18:09
i'm from the old school when we had to program fortran and alsol with 80-column punch cards, described on paper, handed through a window to "coders" who punched the cards, etc. lucky to get 24-hr turnaround just to find mistakes. 18:12
Nemokosch Yeah well, i don't know because i basically never tried to learn a language "the schoolbook way". Whenever I had to look something up for python, it felt like that could be a language one can just learn like good old written law 18:32
I guess this part is cultural, too. In the US, at least, common law is like the main paradigm 18:33
tbrowder__ i would love to have a raku version of the perl cookbook 18:52
o'reilly wouldn't let us create an online version. probably not enough profit potential for a version created by them. 18:54
ash hi hello 20:17
uzl[m] Hi everyone! 20:54
When I go to sprintf (docs.raku.org/type/Cool#method_sprintf) and then click in "format directives", I'm taken to docs.raku.org/routine/sprintf.html#Directives, however I don't see any directives there.
Are the docs linking to the wrong page? It's the same for fmt and printf
> and imho that applies to most any language that i have any experience with 20:57
Piggybacking on throwder's comment, I think it'd be nice to have a little icon for each code snippet to copy it to the clipboard, same as in Github's code snippets. It's not a problem with a few lines but when you've a long example, highlighting and then copying can get a bit finicky.
tbrowder__: You just mentioned punch cards, and a few months ago I read "Grace Hopper and the Invention of the Information Age" and I think you'll like it. In fact, I recommend it to everyone here 20:59
tbrowder__: 21:01
>i would love to have a raku version of the perl cookbook
What about a crowdsourced one created by the Raku community?
* tbrowder__: 21:02
> i would love to have a raku version of the perl cookbook
What about a crowdsourced one created by the Raku community?
m: say "%15s".sprintf: "hello" 21:05
camelia hello
uzl[m] m: say "-%15s".sprintf: "hello"
camelia - hello
uzl[m] m: say "%-15s".sprintf: "hello"
camelia hello
uzl[m] m: my $length = 10; say "%{$length}s".sprintf: "hello" 21:06
camelia hello
uzl[m] m: my $length = 10; say "%-{$length}s".sprintf: "hello"
camelia hello