00:58 discord-raku-bot joined 01:05 riffraff18 joined 01:10 riffraff18 left 01:19 discord-raku-bot left 01:20 discord-raku-bot joined 01:48 discord-raku-bot left 01:56 discord-raku-bot joined 02:02 parv left 02:08 discord-raku-bot left, discord-raku-bot joined 03:05 riffraff18 joined 03:10 riffraff18 left 04:30 riffraff18 joined 04:31 riffraff18 left, riffraff18 joined 06:00 riffraff18 left 06:01 riffraff18 joined 07:47 parv joined 09:05 riffraff18 left, riffraff18 joined 09:10 riffraff18 left 09:36 riffraff18 joined 11:04 parv left
Nemokosch What is the most comfortable way to replace a Nil value with something else, like a default value for an expression: 12:26
What is the most comfortable way to replace a Nil value with something else, like a default value for an expression?
Also, why: 12:31
lizmat m: say Nil // 42 12:32
camelia 42
Nemokosch m: [213,23142124,Nil] ~~ [Nil, **]
oops
anyways, this is True 12:33
lizmat ?
Nemokosch why is it True?
lizmat m: dd 213 ~~ Nil
camelia Bool::False
Nemokosch yes, this will do, thank you
still, I'm curious why that match returns true
lizmat m: say [213,23142124,Nil] ~~ [Nil, **] 12:34
camelia True
Nemokosch m: dd [213,23142124,Nil] ~~ [Nil, **] 12:35
you won, haha
lizmat ** is a so-called HyperWhatever, but the semantics of that are pretty undeveloped 12:39
Nemokosch yes, I was trying to use it like a "slurpy whatever" 12:41
but apparently that's not the semantics we get here 12:42
lizmat a single * should act as a slurpy whatever in that context 12:43
Nemokosch oh that's good to know 12:47
by the way, while we are at it
a couple of days ago, something came up with array assignments
namely that [@a, @b] results into a proper two-dimensional something
but
my [@a, @b] = ...
seems to always be flat
and hence I don't think @b can ever get a non-default value 12:48
do you know something about this behavior?
let's have an example 12:49
m: my @a = 1, 2; my @b = 3,4; [@a, @b] = [@b, @a ]; dd @a; dd @b;
wait what
maybe it was with lists? 12:51
okay, found it
my @a = 1, 2; my @b = 3,4; (@a, @b) = (@b, @a); dd @a; dd @b; 12:52
m: my @a = 1, 2; my @b = 3,4; (@a, @b) = (@b, @a); dd @a; dd @b;
here you go
lizmat m: my @a = 1, 2; my @b = 3,4; (@a, @b) = (@b, @a); dd @a; dd @b;
camelia Array @a = ((my @Array_17078280) = [[], @Array_17078280])
Array @b = []
lizmat it basically boils down to: 12:54
m: my @a; my $b; (@a, $b) = 1,2,3; dd @a, $b
camelia Array @a = [1, 2, 3]
Any $b = Any
lizmat when should the assignment to @a stop ?
m: my @a; my $b; (@a, $b) = (1,2,3),4; dd @a, $b 12:55
camelia Array @a = [(1, 2, 3), 4]
Any $b = Any
Nemokosch @a shouldn't be slurpy whatsoever 13:06
as it indeed isn't when (@a, $b) is on the right handside
lizmat but how would it know when to stop ? 13:13
m: my @a; my $b; (@a, $b) = $(1,2,3),4; dd @a, $b
camelia Array @a = [(1, 2, 3), 4]
Any $b = Any
lizmat one could maybe argue that that should DWIM, but that's getting very magic indeed 13:14
Nemokosch it would stop after the first element 13:16
which in this case would be a list
or array, doesn't matter - a positional 13:17
@a shouldn't have to act differently on the left hand side 13:18
if it doesn't make the surrounding parens collapse on the rhs, it shouldn't on the rhs either
the inconsistency is the main problem, not the collapsing
even though the collapsing really doesn't seem to make sense in particular
lizmat well, I suggest you make a problem-solving issue for that: I'm afraid such a change would at least require a language level boundary 13:19
Nemokosch if there is no easy-to-spot rationale behind this asymmetry, this is a serious enough anomaly to be issued 13:20
Hydrazer is there a better way to have a default value for first? ```pl 13:31
my $num = [1,2,3,4,0].first(* < 1);
say $num ~~ Int ?? $num !! -69;
```
lizmat m: .say with [1,2,3,4,0].first(* < 1) 13:33
camelia 0
lizmat fwiw, with / without were specifically invented to handle cases where something could validly return 0
Hydrazer hm yeah that is nice 13:34
m: say with Nil 13:37
m:```
say with Nil
```
m: ```
say with Nil
```
Nemokosch // is nice šŸ™‚
Hydrazer interesting 13:45
Nemokosch Can I stack statement modifiers somehow? 14:34
I'm thinking of something like
m: dd (.words[0] for ^5);
this works 14:35
m: dd (.words[0] with 'ioj oiJOIjoij oij ');
this also works
m: dd (.words[0] with 'ioj oiJOIjoij oij ' for ^5);
this doesn't seem to do what I want
m: dd (.words[0] for ^5 with 'ioj oiJOIjoij oij ');
this doesn't work at all 14:37
another thing with list comprehensions 15:05
say I have an open file
```perl
dd ($file.get until $file.eof)
```
works alright
```perl 15:06
dd ({$file.get} until $file.eof)
```
is an infinite loop
the function doesn't seem to get called 15:08
Xueji Hello, could anyone explain something about types in raku to me? Let's look at this piece of code: 18:00
```
sub hokus-pokus(Bool %pokus, Str $item --> Bool) {
return %pokus{$item}:exists;
}
my SetHash[Str] $pokus = SetHash[Str].new: "1,2,3,4,5,6,7,8,9,10".split(',', :skip-empty).List;
my Bool %another = $pokus;
say hokus-pokus($pokus, "1");
```
If I try to run it, I get this error: `Calling hokus-pokus(SetHash[Str], Str) will never work with declared signature (Bool %pokus, Str $item --> Bool)`. Why can I assign $pokus to %another, but not call a function hokus-pokus($pokus)?
18:41 riffraff18 left, riffraff18 joined
Nemokosch m: sub hokus-pokus(Bool %pokus, Str $item --> Bool) { return %pokus{$item}:exists; } my SetHash[Str] $pokus = SetHash[Str].new: "1,2,3,4,5,6,7,8,9,10".split(',', :skip-empty).List; my Bool %another = $pokus; dd %another; dd $pokus; 18:45
oops
m: sub hokus-pokus(Bool %pokus, Str $item --> Bool) { return %pokus{$item}:exists; }; my SetHash[Str] $pokus = SetHash[Str].new: "1,2,3,4,5,6,7,8,9,10".split(',', :skip-empty).List; my Bool %another = $pokus; dd %another; dd $pokus; 18:47
If I were to guess, signatures don't make conversions per se 18:49
18:49 riffraff18 left, riffraff18 joined
Morfent m: Metamodel::Primitives.is_type: Positional[Bool], SetHash[Str] 19:40
er
m: say Metamodel::Primitives.is_type: Positional[Bool], SetHash[Str]
me doing the right type would help 19:41
m: say Metamodel::Primitives.is_type: Associative[Bool], SetHash[Str]
m: say Metamodel::Primitives.is_type: Associative[Str], SetHash[Str]
m: say Metamodel::Primitives.is_type: Associative, SetHash[Str] 19:42
oh 19:49
m:```
sub hokus-pokus(Bool %pokus, Str $item --> Bool) {
return %pokus{$item}:exists;
}
my SetHash[Str] $pokus = SetHash[Str].new: "1,2,3,4,5,6,7,8,9,10".split(',', :skip-empty).List;
my Bool %another = $pokus;
INIT say %another;
say hokus-pokus($pokus, "1");
```
no worries, the compiler's being smart here
however... 19:53
19:54 parv joined
m: .^name.say for SetHash[Str].^mro; 20:01
m: .^name.say for SetHash[Str].^mro(:roles); 20:02
i'd expect it to be an `Associative[Bool:D, Str]`
this'll typecheck: 20:06
m:```
sub hokus-pokus(Bool %pokus, Str $item --> Bool) {
return %pokus{$item}:exists;
}
my SetHash[Str] $pokus = SetHash[Str].new: "1,2,3,4,5,6,7,8,9,10".split(',', :skip-empty).List;
my Bool() %another = $pokus;
say hokus-pokus(%another, "1");
```
dropping `Bool()` for `Bool` should also work 20:07
Nemokosch oh right 20:09
the coercion
20:20 riffraff18 left, riffraff18 joined
Xueji Okay, I think I got it. Thanks. 20:21
20:26 riffraff18 left 20:46 riffraff18 joined 21:42 riffraff18 left 22:34 parv left