This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html Set by lizmat on 8 June 2022. |
|||
02:27
razetime joined
|
|||
jaguart | what sig do I need for multi method .gist for :D defined instance or :U Class ? | 02:34 | |
ah found it: multi method gist ( Fruit:D: --> Str) { return "I am a $!flavour $!colour $!shape $!name"; } | 02:35 | ||
or even: multi method gist ( Fruit:D: --> Str:D ) { return "I am a $!flavour $!colour $!shape $!name"; } | 02:37 | ||
@Nemokosh - my wish is to be able to tweak some of the docs. I'm in the process of working through the instructions... | 02:49 | ||
02:52
Kaiepi left
|
|||
jaguart | and TIL: uzluisf.gitlab.io/raku-by-example/...nd-objects | 02:52 | |
Sometimes it's like there is so much at docs.raku.org that I need a beginner-index to useful resources | 03:03 | ||
e.g. because at docs.raku.org search, I search for 'Class' I end up at docs.raku.org/language/classtut -> looks like I should have been searching for 'object' to find docs.raku.org/language/objects | 03:23 | ||
03:32
jaguart2 joined
03:38
jaguart2 left,
jaguart joined
05:25
Heptite left
|
|||
Mason | How would one use a tuple as a key to a hash? | 05:38 | |
something like `%test{(1, 2)} = "hi"` creates strange results | |||
05:50
Kaiepi joined
|
|||
jaguart | depends - how are you going to look up the value later? | 06:20 | |
eg if you want to lookup by the lists values... | 06:25 | ||
m: my %h = (1,2).join('='),"hi";%h.say | |||
camelia | {1=2 => hi} | ||
jaguart | if if its a specific lists... | 06:28 | |
m: my @a = 1,2,3; my %h = @a.WHICH, "hi"; %h.say | |||
camelia | {Array|6442509276640 => hi} | ||
jaguart | How do I fix: zef install Documentable ===> Failed to find dependencies: File::Temp:ver<0.0.6> | 06:31 | |
when zef search File::Temp cannot find any version 0.0.6 | 06:32 | ||
and zef info File::Temp shows I have v0.0.10 installed? | 06:33 | ||
and git clone github.com/Raku/Documentable.git; cd Documentable; zef install . ===> Testing [FAIL]: Documentable:ver<2.0.1>:auth<github:Raku>:api<1> | 06:46 | ||
the actual error being: Cannot resolve caller render(Pod::Block::Named:D... from Documentable::To::HTML::Wrapper line 109... | 06:55 | ||
oh - I see this was borked in June and there are no plans to fix | 06:58 | ||
github.com/Raku/Documentable/issues/162 | |||
Which means that instructions at : github.com/Raku/doc for tweaking docs is outdated. | 07:01 | ||
07:16
Kaiepi left
07:58
Kaiepi joined
|
|||
Nemokosch | Pretty sure I installed Documentable since | 08:26 | |
By the way, yes... you know, the thing is, Raku/doc still includes the code of the current, oldschool site. In this sense, it's set to be outdated | 08:28 | ||
A good example of how missing things get escalated | 08:29 | ||
<@259818303420235786> I was in the same position a year ago but the situation is better now | 08:30 | ||
m: say (1,2).WHICH; say (1,2).WHICH | 08:31 | ||
Lists are not value types, they have referential identity | 08:32 | ||
liz to the rescue: raku.land/zef:lizmat/Tuple | 08:37 | ||
this is a very thin wrapper around ValueList that you could also use directly | |||
mostly this just adds a tuple subroutine | 08:38 | ||
deadmarshal | How should I sort in descending order? bpa.st/BDBA | 09:39 | |
Nemokosch | deadmarshal: you forgot to put the ordering function in a block | 09:43 | |
deadmarshal | thanks | 09:44 | |
15:08
discord-raku-bot joined
15:12
discord-raku-bot left
15:18
discord-raku-bot joined
15:19
razetime left
15:37
Heptite joined,
mcmillhj joined
16:06
mcmillhj left
16:17
mcmillhj joined
|
|||
mcmillhj | If I want to iterate over an Array pairwise but also get the element index what is the best way to do that? `[<a b>].pairs.rotor(2)` gives me the data I want but I am struggling to destructure that when I loop over it: `@knots.pairs.rotor(2) -> ($head, $tail)` "Too few positionals passed to '<anon>'; expected 2 arguments but got 0 in sub-signature" | 16:19 | |
m: for <a b>.pairs.rotor(2) -> ($h, $t) { dd [$h, $t]; } | 16:21 | ||
camelia | Too few positionals passed to '<anon>'; expected 2 arguments but got 0 in sub-signature in block <unit> at <tmp> line 1 |
||
mcmillhj | figured it out, the parentheses were messing up the unpacking | 16:34 | |
m: for <a b>.pairs.rotor(2) -> $h, $t { dd [$h, $t]; } | |||
camelia | Too few positionals passed; expected 2 arguments but got 1 in block <unit> at <tmp> line 1 |
||
mcmillhj | m: for <a b>.pairs.rotor(2).flat -> $h, $t { dd [$h, $t]; } | ||
camelia | [0 => "a", 1 => "b"] | ||
mcmillhj | also needed `.flat` | 16:35 | |
Nemokosch | is this what you wanted? | 16:48 | |
that's not how I would have read it 😅 | |||
mcmillhj | It's all of the data that I needed. I am not sure if there is a better way I can do it however. | 16:51 | |
Nemokosch | Oh gotcha | 17:07 | |
I think kv can also work | |||
That generates flat by default | |||
17:10
discord-raku-bot left,
discord-raku-bot joined
|
|||
mcmillhj | oooh, okay I'll play around with that | 17:10 | |
m: for <a b>.kv.rotor(2) -> $h, $t { dd [$h, $t]; } | 17:11 | ||
camelia | [(0, "a"), (1, "b")] | ||
mcmillhj | yep, that looks a bit better | ||
17:22
mcmillhj left
|
|||
gfldex | m: for <a b>.pairs -> (:key($idx), :value($v)) { dd [$idx, $v]; } | 18:05 | |
camelia | [0, "a"] [1, "b"] |
||
19:01
RakuIRCLogger left
19:02
lizmat_ joined
19:04
lizmat left
19:09
lizmat_ left
19:10
lizmat joined
19:52
mcmillhj joined
20:13
mcmillhj left
|
|||
p6steve | m: for <a b>.kv.rotor(2) { dd [$^h, $^t] } | 22:33 | |
23:17
deoac joined
|
|||
deoac | Â my %my-bag = (a => 1, b => 1, c => 2, d => 3).Bag; | 23:19 | |
How do I remove the element with the lowest value? I don't know the keys. | 23:20 | ||
Yes, I want it removed from the Bag; not just returned. | |||
guifa | m: my %my-bag = (a => 1, b => 1, c => 2, d => 3).Bag; %my-bag{%my-bag.sort(*.value).head.key}:delete; say %my-bag | 23:22 | |
camelia | {a => 1, c => 2, d => 3} | ||
guifa | That's non deterministic though, since a and b would have equal values | ||
Nemokosch | instead of sort and head, min would do, right? | 23:23 | |
guifa | does it provide the pair with the minimum value? | ||
Nemokosch | if you pass a callback to it... 😉 | 23:24 | |
guifa | TIL | ||
m: my %my-bag = (a => 1, b => 1, c => 2, d => 3).Bag; %my-bag{%my-bag.min(*.value).key}:delete; say %my-bag | |||
camelia | {b => 1, c => 2, d => 3} | ||
Nemokosch | it would be so cool if all methods that return data from a composite data structure could just take :delete | 23:29 | |
guifa | Agreed. But I can see where people might want to do some chained calls for that (say, sort(…).head(2) maybe) and I don't think there's a simple way to pull that off with it | 23:31 | |
deoac | You all are the best - thank you | 23:32 | |
Nahita | `%my-bag` there is not a Bag BTW, it's a Hash -- RHS makes a Bag allright but assigning that to %-sigiled thing makes LHS of type Hash; even if it was a Bag, couldn't delete from it too, need BagHash | 23:33 | |
guifa | Nahita good point | ||
my %my-bag is BagHash = (a => 1, b => 1, c => 2, d => 3).Bag; %my-bag{%my-bag.min(*.value).key}:delete; say %my-bag | |||
m: my %my-bag is BagHash = (a => 1, b => 1, c => 2, d => 3).Bag; %my-bag{%my-bag.min(*.value).key}:delete; say %my-bag | |||
camelia | BagHash(b c(2) d(3)) | ||
Nahita | e.g., `my %bh is BagHash = ...; %bh{%bh.minpairs.first.key}:delete` | ||
if you want all minimals gone, `%bh{%bh.minpairs>>.key}:delete` | 23:34 | ||
Nemokosch | the sole fact that the code worked at all proved that it couldn't be a bag | ||
`minpairs` is good, never heard of it | 23:37 | ||
so apparently .key is nodal? | |||
hm, maybe Pairs in general are nodal for hyper metaop? 🤔 | 23:38 | ||
m: my %my-bag := (a => 1, b => 1, c => 2, d => 3).BagHash; dd %my-bag>>.succ; dd %my-bag.list>>.succ; | 23:43 | ||
not trivial at all | 23:44 | ||
jaguart | If a class is in a module, how do I get the Metamodel::ModuleHOW from the class? as in I think .WHO returns the package, what returns the module? | 23:51 | |
Nemokosch | isn't a module a high-level package? | 23:56 | |
jaguart | yeah - would be nice if .WHO gate you package // module | 23:57 |