🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel! Set by lizmat on 25 August 2021. |
|||
00:04
reportable6 left
00:05
reportable6 joined
|
|||
gfldex | elcaro: gfldex.wordpress.com/2020/10/26/pl...olescence/ | 00:13 | |
00:23
dextercd left
|
|||
elcaro | gfldex: yeah I knew about this, and used your module prior... but I thought it was only `postcircumfix:<{|| }>` ... not `postcircumfix:<[|| ]>` | 00:42 | |
when your blog post was published, I'm sure I tried using it on a matrix and it didn't work. maybe I'm wrong... or maybe it was fixed later. | 00:43 | ||
gfldex | elcaro: It can take a few weeks for PRs to make it into a release. | 00:56 | |
01:01
xinming joined
01:17
jgaz left,
jgaz joined
01:23
swaggboi left
01:28
swaggboi joined
01:41
jgaz left
01:57
xinming left
02:02
frost joined
02:07
ggoebel left
02:15
xinming joined
|
|||
elcaro | gfldex: It was after the merge... more likely I forgot to use v6.e.PREVIEW before testing :/ | 02:17 | |
glad it's there, tho... seems I've been awaiting a feature that's been implemented for over a year :D | 02:18 | ||
02:22
swaggboi left
02:36
swaggboi joined
02:50
swaggboi left
03:02
nine left,
nine joined
03:03
swaggboi joined
03:50
gordonfish left
04:50
reportable6 left,
shareable6 left,
evalable6 left,
notable6 left,
unicodable6 left,
linkable6 left,
tellable6 left,
statisfiable6 left,
greppable6 left,
bloatable6 left,
committable6 left,
coverable6 left,
squashable6 left,
sourceable6 left,
nativecallable6 left,
benchable6 left,
quotable6 left,
releasable6 left,
bisectable6 left
04:51
committable6 joined,
coverable6 joined,
squashable6 joined
04:52
linkable6 joined,
greppable6 joined,
statisfiable6 joined,
sourceable6 joined,
unicodable6 joined,
tellable6 joined
04:53
evalable6 joined
05:50
releasable6 joined
05:51
shareable6 joined
05:52
bisectable6 joined
05:53
nativecallable6 joined
06:08
squashable6 left
06:09
squashable6 joined
06:11
squashable6 left
06:12
squashable6 joined
06:34
mathias[m] left
06:52
benchable6 joined,
bloatable6 joined
06:53
notable6 joined
07:05
reportable6 joined
07:29
seednode left
07:30
seednode joined
07:58
squashable6 left
08:00
squashable6 joined
08:07
abraxxa joined
08:13
abraxxa left
08:14
abraxxa joined
08:38
jjido joined
08:43
TheAthlete joined
09:35
Sgeo left
09:45
frost left,
TheAthlete left
10:03
Skarsnik_ joined
|
|||
Manifest0 | How can i invoke a method from an object, when i have the method name as string in a var, like this: class A{method t(){say "t!!"}}; my $a = A.new(); my $m = 't'; $a.$m(); ? | 10:40 | |
10:40
mathias[m] joined
|
|||
gfldex | m: class A{method t(){say "t!!"}}; my $a = A.new(); my $m = 't'; $a.$m(); | 10:49 | |
camelia | No such method 'CALL-ME' for invocant of type 'Str' in block <unit> at <tmp> line 1 |
||
gfldex | m: class A{method t(){say "t!!"}}; my $a = A.new(); my $m = 't'; $a."$m"(); | ||
camelia | t!! | ||
Manifest0 | gfldex: super! :-) | 10:50 | |
i have to say, though, it's not intuitive | 10:54 | ||
11:08
frost joined,
ab5tract joined
11:15
TempIRCLogger left
11:37
squashable6 left,
ggoebel joined
11:40
squashable6 joined
11:42
squashable6 left
11:49
Altai-man joined
12:02
TempIRCLogger joined
12:03
reportable6 left
12:04
reportable6 joined
12:12
Skarsnik_ left
12:31
TempIRCLogger left,
TempIRCLogger joined
12:35
TempIRCLogger left,
TempIRCLogger joined,
Ergo444 joined
|
|||
Ergo444 | hi | 12:36 | |
where can I view the log of this channel? | |||
lizmat | logs.liz.nl/raku/live.html | ||
12:44
squashable6 joined
12:48
ab5tract left
12:52
[Coke] left
12:59
[Coke] joined,
jgaz joined
|
|||
lucs | How can I successfully slurp in (or something) a latin1 encoded file when I don't happen to know the encoding? | 13:04 | |
lizmat | slurp :encoding("latin1") ? | ||
lucs | Yeah, but I don't know the encoding, it might be UTF-8 or latin1. | 13:05 | |
lizmat | actually: :enc<latin1> | ||
lucs | Fair enough, still :) | ||
lizmat | then utf8-c8 as encoding perhaps ? | 13:06 | |
lucs | Hmm... I'll try-that. | ||
Still complains of malformed UTF-8 :( | 13:08 | ||
Ergo444 | not suprising | 13:09 | |
lucs | I'd try to trap the exception, except that the data is coming from $*IN, so if it fails at first, I think the data is not available to try again, or is it? | 13:10 | |
Is there any way to get the raw $*IN contents into a variable and work from that? | 13:12 | ||
13:13
TempIRCLogger left,
TempIRCLogger joined
|
|||
lizmat | slurp(:bin) will give you a Bug | 13:14 | |
*Buf | |||
lucs | Oh, okay, never worked with those, will read up on them. | ||
Thanks. | |||
13:18
TempIRCLogger left,
TempIRCLogger joined
13:25
mscha joined
|
|||
mscha | m: class Foo { rule foo { foo }; method bar($s) { dd $s ~~ /<foo>/ } }; Foo.new.bar('foo'); | 13:25 | |
camelia | No such method 'foo' for invocant of type 'Match' in method bar at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
mscha | m: class Foo { my rule foo { foo }; method bar($s) { dd $s ~~ /<&foo>/ } }; Foo.new.bar('foo'); | ||
camelia | Match.new(:orig("foo"), :from(0), :pos(3)) | ||
mscha | Declaring a `rule` (or `token`, `regex`) is apparently legal outside of a Grammar, but is unusable as far as I can tell. Why isn't he first one a syntax error? | 13:27 | |
13:36
lizmat_ joined
13:37
frost left,
[Coke] left
13:38
TempIRCLogger left,
lizmat left
13:40
[Coke] joined
13:45
ab5tract joined
|
|||
ab5tract | m: class A{method t(){say "t!!"}}; my $a = A.new(); my $m = 't'; $a.<<$m>>(); | 13:46 | |
camelia | Type A does not support associative indexing. in block <unit> at <tmp> line 1 |
||
ab5tract | (was simply curious :) ) | ||
13:51
lizmat_ left,
lizmat joined
13:52
quotable6 joined
13:54
TempIRCLogger__ joined,
TempIRCLogger__ left
13:58
TempIRCLogger joined
14:00
TempIRCLogger left
14:01
TempIRCLogger joined
14:03
TempIRCLogger left,
TempIRCLogger joined
14:08
TempIRCLogger left,
TempIRCLogger joined,
habere-et-disper joined
14:10
TempIRCLogger left,
TempIRCLogger joined
|
|||
habere-et-disper | What is the recommended/idiomatic way to sort an array of arrays? | 14:13 | |
m: say sort [ [1,3,2], [5,4,6], [6,2,1] ].map: *.sort | |||
camelia | ((1 2 3) (1 2 6) (4 5 6)) | ||
habere-et-disper | It seems we have to say sort twice? | 14:14 | |
lizmat | what is the criterium to sort the lists on ? | ||
habere-et-disper | Maybe that is a good compromise for composability? | ||
14:14
TempIRCLogger left,
abraxxa left,
TempIRCLogger joined
|
|||
habere-et-disper | lizmat ascending numerical order is fine | 14:16 | |
lizmat | so you want to sort on the first element, if that's the same, sort on the next, etc ? | ||
after having sorted all of the "sub" arrays ? | 14:17 | ||
14:17
jjido left
|
|||
habere-et-disper | Sort all the sub-arrays, then the top array. | 14:17 | |
Which I sort of think of as a default in this case? | |||
lizmat | well, I think it will stringify arrays and compare that | 14:18 | |
which is... suboptimal | |||
habere-et-disper | okay, thanks. | 14:20 | |
Are we using the Edit Distance/Levenshtien algorithm to make suggestions? That would seem to automatically catch typos. | 14:25 | ||
lizmat | yes, we are, plus some specific suggestions | 14:26 | |
m: say "foo".length | |||
camelia | No such method 'length' for invocant of type 'Str'. Did you mean any of these: 'chars', 'codes'? in block <unit> at <tmp> line 1 |
||
habere-et-disper | Wow! Excellent. Thanks. | 14:28 | |
14:32
TempIRCLogger__ joined,
lizmat_ joined
14:33
abraxxa joined,
habere-et-disper left
14:34
TempIRCLogger left,
lizmat left
14:35
lizmat_ left,
lizmat joined
14:46
TempIRCLogger__ left
14:47
TempIRCLogger joined
14:49
mscha left
14:55
eseyman left
|
|||
tbrowder | publishing modules to Zef with mi6 is now soooo easy. i have now published 8 there which were orig on cpan and will do more. | 14:58 | |
14:59
mcmillhj joined
|
|||
tbrowder | if you haven't been using App::Mi6 for module management you have been missing the boat | 14:59 | |
15:00
Ergo4444 joined,
Ergo4444 left
|
|||
Ergo444 | how can I empty a hash? | 15:01 | |
m: my %h; %h = {}; | |||
camelia | Potential difficulties: Useless use of hash composer on right side of hash assignment; did you mean := instead? at <tmp>:1 ------> 3my %h; %h = {}7⏏5; |
||
Ergo444 | What is wrong in here? | ||
SmokeMachine | m: my %h = :a, :b; say %h; %h = (); say %h | 15:03 | |
camelia | {a => True, b => True} {} |
||
lizmat | m: my %h; %h = (); | ||
camelia | ( no output ) | ||
mcmillhj | Maybe I am being dense and not understanding the documentation, but is there are there methods for adding and removing elements from sets? Or am I supposed to use the set operators for this? docs.raku.org/type/Set | 15:04 | |
El_Che | "A Set is an immutable set" | ||
"(For mutable sets, see SetHash instead.)" | |||
15:05
eseyman joined
|
|||
lizmat | m: my %s is SetHash; %s.set: 1,2,3; dd %s | 15:05 | |
camelia | Too many positionals passed; expected 2 arguments but got 4 in block <unit> at <tmp> line 1 |
||
lizmat | m: my %s is SetHash; %s.add: 1,2,3; dd %s | ||
camelia | No such method 'add' for invocant of type 'SetHash' in block <unit> at <tmp> line 1 |
||
lizmat | hmmm | ||
mcmillhj | El_Che sorry, I did mean to link SetHash I have both tabs open :) | 15:06 | |
lizmat | m: my %s is SetHash; %s.set: (1,2,3); dd %s | ||
camelia | SetHash.new(2,1,3) | ||
mcmillhj | lizmat okay, but to test for existence do I just `%s{<KEY HERE>}` ? | ||
lizmat | mcmillhj: indeed | ||
m: my %s is SetHash; %s.set: (1,2,3); dd %s{1}; dd %s{0} | 15:07 | ||
camelia | Bool::True Bool::False |
||
mcmillhj | okay, great. I think I was just not understanding the documentation. Thanks all. | ||
El_Che | mcmillhj: then the documentation may need some love | 15:10 | |
mcmillhj | El_Che I think it was more me being confused / not reading carefully. I was just kind of expecting an API like I have seen in other languages: .add, .has, etc... My bias isn't the docs fault though :) | 15:11 | |
lizmat | mcmillhj: BagHashes have .add | 15:13 | |
Ergo444 | hello what is wrong with this? | ||
lizmat | mcmillhj: SetHashes also have .unset | 15:14 | |
Ergo444 | m: my %h; %h = {}; | ||
camelia | Potential difficulties: Useless use of hash composer on right side of hash assignment; did you mean := instead? at <tmp>:1 ------> 3my %h; %h = {}7⏏5; |
||
Ergo444 | useless use? | ||
it is not useless | |||
lizmat | Ergo444: so what do you think it should do ? | ||
Ergo444 | empty the hash | 15:15 | |
lizmat | %h = () | ||
will do that for you | |||
Ergo444 | what is wrong with {}? | ||
lizmat | well, its semantics are not clear | ||
Ergo444 | how so? | ||
lizmat | should it flatten or not ? | 15:16 | |
%h = () will reset an existing Hash object | 15:17 | ||
%h := { } will re-bind the %h to a fresh (empty) Hash object | |||
Ergo444 | flatten? | ||
Flatten what? | |||
lizmat | the right hand side of %h = } | ||
the right hand side of %h = { } | 15:18 | ||
Ergo444 | there is nothing to flatten | ||
lizmat | yes there is, A Hash object | ||
%h = { } | |||
is effectively the same as: | |||
%h = Hash.new | |||
Ergo444 | and? | 15:19 | |
How would an object be flattened? | 15:22 | ||
I only know this term with lists. | 15:23 | ||
What does it mean to flatten an object? | |||
15:24
Sgeo joined
|
|||
lizmat | well, generally we talk about it in the context of arrays / hashes only | 15:24 | |
m: my @a = { :a, :b }; dd @a | |||
camelia | Array @a = [:b(Bool::True), :a(Bool::True)] | ||
lizmat | this flattened the hash into Pairs in the array | 15:25 | |
m: my @a = { :a, :b }, { :c, :d }; dd @a | |||
camelia | Array @a = [{:a(Bool::True), :b(Bool::True)}, {:c(Bool::True), :d(Bool::True)}] | ||
lizmat | this did not, because of the single argument rule | ||
15:33
euandreh left
15:35
mcmillhj left,
euandreh joined
15:38
Geth left,
Geth joined
15:40
TempIRCLogger left,
TempIRCLogger joined
|
|||
Ergo444 | What is the single assignment rule? | 16:07 | |
16:08
mcmillhj joined
|
|||
lizmat | single argument rule | 16:09 | |
m: my @a = ^5; for @a { dd $_ } | 16:10 | ||
camelia | Int @a = 0 Int @a = 1 Int @a = 2 Int @a = 3 Int @a = 4 |
||
lizmat | note that this flattened the array in the for loop | ||
m: my @a = ^5; for @a, @a { dd $_ } | |||
camelia | Array @a = [0, 1, 2, 3, 4] Array @a = [0, 1, 2, 3, 4] |
||
lizmat | note that this did not, because the for loop got more than 1 argument | ||
16:11
dextercd joined
16:26
Altai-man left
16:29
Altai-man joined
16:34
abraxxa left,
Guest36 joined
|
|||
Guest36 | Beat do raku | 16:34 | |
ab5tract | The single argument rule should arguably ( ;) ) be considered the lynch pin to understanding the somewhat odd corners of when to slip/flatten and when to not. IIRC this was basically how we came to "solve" the GLR (Great List Refactor). | 16:36 | |
which reminds me to ask a) how is TimToady these days?; and b) where is the butterfly book? :) | 16:37 | ||
16:38
Guest36 left
17:04
lichtkind_ left
17:14
lichtkind joined
17:33
ab5tract left
17:34
mcmillhj left
17:36
Ergo444 left
17:44
ggoebel left
18:02
reportable6 left
18:09
abraxxa-home joined
18:20
Altai-man left
18:41
mcmillhj joined
19:01
djerius left
19:02
djerius joined
|
|||
mcmillhj | m: class Point { has Int $.x; has $.y; method find(SetHash[Point] %search-space) { return Nil; } }; my $p = Point.new(x => 0, y => 0); $p.find(SetHash.new); | 19:04 | |
camelia | Type check failed in binding to parameter '%search-space'; expected Associative[SetHash[Point]] but got SetHash (SetHash.new()) in method find at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
19:04
reportable6 joined
|
|||
mcmillhj | ^ what's the correct way to type the `find` function if I want to accept a `SetHash` of `Point` objects | 19:04 | |
lizmat | m: class Point { has Int $.x; has $.y; method find(SetHash[Point] $search-space) { return Nil; } }; my $p = Point.new(x => 0, y => 0); $p.find(SetHash.new); | 19:10 | |
camelia | Type check failed in binding to parameter '$search-space'; expected SetHash[Point] but got SetHash (SetHash.new()) in method find at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
lizmat | m: class Point { has Int $.x; has $.y; method find(SetHash[Point] $search-space) { return Nil; } }; my $p = Point.new(x => 0, y => 0); $p.find(SetHash[Point].new); | ||
camelia | ( no output ) | ||
lizmat | mcmillhj ^^ | 19:11 | |
m: class Point { has Int $.x; has $.y; my constant SHP = SetHash[Point]; method find(SHP $search-space) { return Nil; } }; my $p = Point.new(x => 0, y => 0); $p.find(SHP.new); | |||
camelia | 5===SORRY!5=== Error while compiling <tmp> Undeclared name: SHP used at line 1 |
||
mcmillhj | lizmat ty++ | 19:12 | |
lizmat | m: class Point { has Int $.x; has $.y; our constant SHP = SetHash[Point]; method find(SHP $search-space) { return Nil; } }; my $p = Point.new(x => 0, y => 0); $p.find(SHP.new); | ||
camelia | 5===SORRY!5=== Error while compiling <tmp> Undeclared name: SHP used at line 1 |
||
lizmat | m: class Point { ... }; our constant SHP = SetHash[Point]; class Point { has $.x; has $.y; method find(SHP $search-space) { return Nil; } }; my $p = Point.new(x => 0, y => 0); $p.find(SHP.new); | 19:13 | |
camelia | ( no output ) | ||
mcmillhj | oh nice, that looks a lot cleaner. Thank you. | ||
19:15
jgaz left
|
|||
lizmat | mcmillhj: what is done there with class Point { ... } is called "stubbing the class" so that it is known, and only later actually filled in | 19:16 | |
mcmillhj | lizmat I like it, it will let me rewrite my types in my domain | 19:17 | |
19:24
abraxxa-home left
20:01
Skarsnik_ joined
|
|||
mcmillhj | Is there a way to provide an initial value for `reduce` ? | 20:37 | |
lizmat | this is typically the value that the argumentless call of the operator returns | 20:43 | |
20:43
tejr left
|
|||
lizmat | m: say &infix:<+>() | 20:44 | |
camelia | 0 | ||
lizmat | m: say &infix:<*>() | ||
camelia | 1 | ||
lizmat | mcmillhj ^^ is that what you mean | ||
? | |||
mcmillhj | not exactly, I was thinking more like a foldl or foldr operation but when I can supply the initial value of the accumulator | 20:45 | |
I can paste my small example if that would make it more clear. | |||
lizmat | yes, please | 20:46 | |
20:47
tejr joined
|
|||
mcmillhj | Uploaded file: uploads.kiwiirc.com/files/12b32d29...pasted.txt | 20:49 | |
topaz.github.io/paste/#XQAAAQBmAgA...+0TxaCF4mb | |||
/9/TUj9S4YvpcEK6xYWPhCiPug5vxGfsTBgY= | |||
maybe reduce is the wrong verb, it's more like aggregate in my case | 20:54 | ||
lizmat | perhaps something like this: | 20:58 | |
m: my %m is Map = "(", 1, "[", 2, q/{/, 3, "<", 4; my $current = "<"; say %m{$current} | |||
camelia | 4 | ||
lizmat | m: my %m is Map = "(", 1, "[", 2, q/{/, 3, "<", 4; my $current = "x"; say %m{$current} // 0 | ||
camelia | 0 | ||
mcmillhj | that could work, let me try that out. Thank you. | 21:04 | |
21:14
Geth left,
Geth joined
21:19
gordonfish joined
21:37
mcmillhj left
|
|||
tonyo | what happened with this? docs.raku.org/language/modules#Dis...ng_modules | 21:48 | |
was fez removed for some reason? | |||
[Coke] | docs.raku.org/language/modules#Upl..._ecosystem ? | 21:51 | |
don't see any recent changes to that bulleted list. | 21:53 | ||
last content change on that file is from Jul 31 2021 | |||
(and it doesn't seem to touch that section) - so probably not yet added. | |||
22:01
jjido joined
22:55
MasterDuke left
22:56
summerisle is now known as eof
23:33
jjido left
23:48
dextercd left
|