🦋 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.
EuAndreh[m] How can I add a tuple type as a return value? See: euandre.org/pastebin/raku-tuple-ty...ation.html 01:03
vrurg EuAndreh[m]: Use List or modules.raku.org/dist/Tuple:cpan:ELIZABETH 01:15
EuAndreh[m]: Depending on how you plan to use the return value, it could be a Pair or Array too. 01:16
EuAndreh[m] vrurg: I think it's closer to a Pair 01:17
Can the Pair be generic on the contents?
vrurg EuAndreh[m]: Like?
EuAndreh[m] Maybe something like Pair[Str, Str]
Actually, a Pair contains a key and a value. I'm after a tuple instead 01:18
So probably a List or an Array 01:19
vrurg Anyway, Pairs are not parameterizable.
EuAndreh[m] I guess Lists aren't also, right? 01:20
vrurg You're right.
EuAndreh[m] vrurg: Thank you very much :)
vrurg EuAndreh[m]: you're welcome. :) 01:21
cpan-raku New module released to CPAN! Red (0.1.1) by 03FCO 02:21
xinming_ SmokeMachine: Still trying, busy with other things in life, If I have time, I'll do it, and whenever I have time, I'll trouble you. 04:59
xinming_ What is the difference between categorize and classify in List class? I feel they are the same. 05:38
even the example, there is one example behave the same. 05:39
Geth_ doc: 24dd9ebf99 | (Stoned Elipot)++ | assets/sass/style.scss
Be more specific in selecting href to "external" sites

  ...and thus avoid selecting the "internal" link to language/operators#infix_//
as seen in doc/Language/typesystem.pod6
06:30
doc: 20b84e83cd | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | assets/sass/style.scss
Merge pull request #3135 from stoned/fix-external-url-selector

Be more specific in selecting href to "external" sites
sarna hey, can I somehow get more info from a test that failed? like, expected x, got y? 09:02
I'm using `mi6 test` and when something fails I just get "test x failed" :/ 09:06
ToddAndMargo Hi All. I am trying ot code a Native call to a C functions that uses a "LPTSTR". How do I declare that? Something like `constant DWORD := int32; ` but for LPTSTR? 09:12
lizmat sarna: raku -Ilib t/foo.t 09:16
ToddAndMargo if it helps, I found this description: "LPTSTR is a [long] pointer to a (non-const) TCHAR string" 09:17
and "LPTSTR: null-terminated string of TCHAR (Long Pointer)" 09:19
sarna lizmat: that doesn't give me any more info than "test x failed on line y" 09:26
lizmat well, then maybe the test is a bit wonky? Like being an "ok" or a "flunk" ? 09:27
what does the test say on that line ?
sarna it's an "ok" test
which one would give me more info?
lizmat is-deeply ? 09:28
is ?
lizmat m: use Test; is "foo", "bar" 09:29
camelia not ok 1 -
# Failed test at <tmp> line 1
# expected: 'bar'
# got: 'foo'
lizmat m: use Test; is-deeply "foo", 42
camelia not ok 1 -
# Failed test at <tmp> line 1
# expected: 42
# got: "foo"
sarna that works, thanks lizmat :)
lizmat afk for a few hours& 09:32
PSA: there will ne *no* Rakudo Weekly this week, the next one will be on 6 January 2020
sarna m: enum Foo<Bar Baz>; Foo(Nil or 0) 09:54
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3enum Foo<Bar Baz>; Foo(Nil7⏏5 or 0)
expecting any of:
sarna m: enum Foo<Bar Baz>; Foo((Nil or 0))
camelia ( no output )
sarna why do I need extra parens here? :D
moritz m: enum Foo<Bar Baz>; say Foo( 0 ) 11:16
camelia Bar
moritz m: enum Foo<Bar Baz>; say Foo( Nil or 0 )
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3enum Foo<Bar Baz>; say Foo( Nil7⏏5 or 0 )
expecting any of:…
moritz m: enum Foo<Bar Baz>; say Foo( 0 or 0 )
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in argument list; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3enum Foo<Bar Baz>; say Foo( 07⏏5 or 0 )
expecting any of:…
moritz looks like a bug to me
it seems to be stopping at the wrong precedence level here 11:17
sarna how to turn an array of chars into an array of numbers? I tried this, but it didn't work 11:37
sarna m: for "1234".comb { Int($_) } 11:38
camelia ( no output )
sarna oh lol it works
m: my @foo = do for "1234".comb { Int($_) }; dd @foo[0] 11:39
camelia Int @foo = 1
moritz m: say "1234".comb.map(+*) 11:40
camelia (1 2 3 4)
moritz m: say "1234".comb>>.Int
camelia (1 2 3 4)
sarna neat! 11:41
sarna what does that mean: `expected Positional[Int] but got Array ($[1, 2, 3])`? isn't Array positional? 12:38
m: sub foo(Int:D @arg) { } ; foo([1;2;3]) 12:39
camelia Type check failed in binding to parameter '@arg'; expected Positional[Int] but got Array ($[1, 2, 3])
in sub foo at <tmp> line 1
in block <unit> at <tmp> line 1
tbrowder hi, all 12:42
tellable6 2019-12-26T19:03:19Z #raku <jmerelo> tbrowder what about simply raku-advent-calendar.org for a domain?
2019-12-26T19:09:49Z #raku <lizmat> tbrowder perhaps raku-advent-calendar.blog ?
tbrowder the choices i gave are what was offered free, i assume anything else would cost more but i don't know. i'll check when i get a chance... 12:44
ref modules: i want to add to a module a test that requires a debian package. is there any clever way to skip the test if it's not available? 12:48
the meta6 would actually list a module that requires the uuid-dev library 12:49
tbrowder that module is LibUUID 12:50
Doc_Holliwood Cow-orker: Hey, you, what are you up to? Me: I'm looking for whatever. Cow-orker: Ok, ok. No need to be snarky.
m: .say for (2..50).grep: is-prime(*) 12:52
camelia No such method 'is-prime' for invocant of type 'Whatever'
in block <unit> at <tmp> line 1
Doc_Holliwood Why doesn't this work?
Or rather, why doesn't it dwim?
Doc_Holliwood m: .say for (2..50).grep: is-prime(* + 0) 12:54
camelia No such method 'is-prime' for invocant of type 'WhateverCode'
in block <unit> at <tmp> line 1
Doc_Holliwood m: .say for (2..50).grep: is-prime((* + 0)())
camelia Too few positionals passed; expected 1 argument but got 0
in block <unit> at <tmp> line 1
SmokeMachine m: sub foo(Int:D @arg) { } ; foo([1,2,3]) 13:06
camelia Type check failed in binding to parameter '@arg'; expected Positional[Int] but got Array ($[1, 2, 3])
in sub foo at <tmp> line 1
in block <unit> at <tmp> line 1
SmokeMachine m: sub foo(Int:D @arg) { } ; foo(Array[Int].new: [1,2,3]) 13:06
camelia ( no output )
SmokeMachine m: sub foo(@arg where .all ~~ Int:D) { } ; foo([1,2,3]) 13:07
camelia ( no output )
lizmat m: .say for (2..50).grep: *.is-prime # Doc_Holliwood
camelia 2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
SmokeMachine sarna: ^^
sarna thanks SmokeMachine :) 13:08
SmokeMachine sarna: `Int @array` is different from a array with every element being an int... 13:10
Doc_Holliwood lizmat: that's what i get for simplyfying :P Here's what I originally wanted to do: 13:11
SmokeMachine m: say [1, 2, 3] ~~ Positional[Int]; say Array[Int].new([1, 2, 3]) ~~ Positional[Int]
camelia False
True
Doc_Holliwood m: use Prime::Factor; .say for (2..50).grep: is-prime( prime-factors(*).elems ); 13:13
camelia ===SORRY!===
Could not find Prime::Factor at line 1 in:
inst#/home/camelia/.perl6
inst#/home/camelia/rakudo-m-inst-1/share/perl6/site
inst#/home/camelia/rakudo-m-inst-1/share/perl6/vendor
inst#/home/camelia/rakudo-m-inst-1/sh…
SmokeMachine m: subset ArrayOfInts of Positional where .all ~~ Int:D; say [1, 2, 3] ~~ ArrayOfInts
camelia True
sarna SmokeMachine: wait, what 13:14
D: heck
SmokeMachine sarna: what? 13:15
sarna SmokeMachine: what is `Int @array` then?
isn't it "a thing that does positional and has Ints inside"?
SmokeMachine sarna: `Int @array` is equivalent of `Array[Int]` 13:16
Doc_Holliwood it is. but a plain [1,2] isn't an array of Ints
sarna what's [1,2] then?
Doc_Holliwood it could contain anything. the subset above is a runtime check for any array
SmokeMachine sarna: no, it's a defined type... so, to set a value for that, that value should have that type..
m: [1,2].^name.say 13:17
camelia Array
SmokeMachine m: Array[Int].new([1,2]).^name.say
camelia Array[Int]
SmokeMachine sarna: ^^
sarna oh, that's because I can append values of any type to that literal, right? 13:18
Doc_Holliwood right.
sarna thanks for explaining, I got it now
SmokeMachine m: my Int @a; @a.push: 1; @a.push: "a" 13:19
camelia Type check failed in assignment to @a; expected Int but got Str ("a")
in block <unit> at <tmp> line 1
SmokeMachine m: my @a where .all ~~ Int; @a.push: 1; @a.push: "a" 13:19
camelia Type check failed in assignment to @a; expected <anon> but got Str ("a")
in block <unit> at <tmp> line 1
sarna that's funny: 13:21
m: my @a where .any ~~ Int; @a.push: 1; @a.push: "a"
camelia Type check failed in assignment to @a; expected <anon> but got Str ("a")
in block <unit> at <tmp> line 1
SmokeMachine m: my @a where { .all ~~ Int || fail "Please just give me Ints" }; @a.push: 1; @a.push: "a" 13:24
camelia Please just give me Ints
in block <unit> at <tmp> line 1
Xliff . 15:05
sena_kun: You around? 15:06
elmo40 hrmm... interesting 15:17
Tirifto Hello! Is there a way to create an empty (path-less) IO::Path object, or is it a much better idea to avoid the kind of situation where I would need to do that in the first place? 16:06
AlexDaniel Tirifto: what about a type object? 16:08
m: say IO::Path
camelia (Path)
AlexDaniel but yes, I'm intersted to know why you need this
intersted* uhh sloppy fingers :)
heh I did it again :D
Tirifto AlexDaniel: I'm writing a script to assemble webpages for me. It has a class for data of the pages it's going to export (one object per page), with one datum being the path the page's content should be written to. At one point in the script, it's known that a new page will be exported, but the data of the page is yet to be provided (piece by piece). My first idea was to create the page object with all of its attributes empty, and fill them 16:20
in as the data are read. In keeping with this, I could just give it any arbitrary path, since the datum's going to get overwritten anyways, but some more obviously default/temporary value would feel more proper. :P
AlexDaniel Tirifto: yeah sounds like you just need a type object 16:21
m: my IO::Path $x; dd $x
camelia Path $x = IO::Path
AlexDaniel m: my IO::Path $x; dd $x; $x = ‘foo’.IO; dd $x
camelia Path $x = IO::Path
Path $x = IO::Path.new("foo", :SPEC(IO::Spec::Unix), :CWD("/home/camelia"))
Tirifto AlexDaniel: Aha, neat! So type objects fit in their types? 16:22
AlexDaniel Tirifto: yeah, constraints are :U by default, you can use :D if you wanted to forbid that 16:23
m: my IO::Path:D $x = IO::Path 16:24
camelia Type check failed in assignment to $x; expected IO::Path:D but got IO::Path (IO::Path) (perhaps Nil was assigned to a :D which had no default?)
in block <unit> at <tmp> line 1
AlexDaniel m: my IO::Path:D $x = ‘foo’.IO
camelia ( no output )
Tirifto :D
Actually, :U 16:25
Thank you, AlexDaniel, that solved the problem! I can move on to the next one. :) 16:30
Geth_ doc: d22976f450 | (Stoned Elipot)++ | doc/Language/typesystem.pod6
Fix link to sub-signatures
17:02
lizmat www.reddit.com/r/rakulang/comments..._a_string/ 17:43
takers?
moritz there was an answer already, I've given a somewhat longer version 19:12
Dasein How do you properly install Zef? 21:26
I've had issues because of being a noob
lizmat 29 seconds is not a lot of time to give you an answer 21:29
Tirifto If my class ‘has @.an-array’, how can I leave it empty upon blessing? 21:44
(I've added a custom ‘new’ method, but blessing with the pair ‘an-array => @()’ raised complaints about wrong number of arguments, and declaring a variable as ‘my $an-array = ()’ and blessing with that as ‘:$an-array’ gives me the array [()], which contains one element, when I'd really like zero.) 21:48
Oh, it looks like I don't need to mind all of the attributes in my blessing, and those omitted will be empty? 21:50
Xliff . 21:54
jnthn Tirifto: Yes, an @-sigil thing will default to an empty array, so nothing is needed to leave it empty. But the fix would be to use `my @an-array;` and bless with `:@an-array`, or even shorter without the temporary, `:an-array[]`. 21:57
Easiest to do nothing at all, of course :)
Tirifto Ah, thank you, jnthn! 22:00
Makes sense. :)
Also, does substitution somehow mess with the ‘$_’ variable? I find that ‘$item ~~ s[$ph_title] = .title’ complains about the invocant being of type ‘Str’, even when outside of the line it's not, while ‘my $new = $_; $item ~~ s[$ph_title] = $new.title’ will work just fine. 22:07
(Sorry if I'm overlooking basic information in the documentation; there's (fortunately) a lot to read there!) 22:09
tobs Tirifto: it seems that the matchee $item becomes $_ for the duration of s///. (I'm surprised this syntax even does what you meant...) 22:25
m: my $a = "far"; my $b = "bar"; given $a { say $b ~~ s['a'] = .uc; say $_ }; say $a; say $b
camelia 「a」
far
far
bBARr
tobs I for one would have excepted the substitution's Match object to be $_ during the substitution, but that apparently only works with the &subst method when it receives a callable, but that's my own confusion, not yours :) 22:29
Xliff m: my $a = "far"; my $b = "bar"; given $a { say $b ~~ s['a'] = $a.uc; say $_ }; say $a; say $b 22:30
camelia 「a」
far
far
bFARr
Tirifto I like how Raku has kept the sense of wonder and mystery from Perl. :) 22:31
Xliff m: my $a = "far"; my $b = "bar"; given $a { s['a'] = .uc given $b; say $_ }; say $a; say $b 22:33
camelia far
far
bBARr