04:57 sjn left, sjn joined 08:10 dakkar joined 11:29 TempIRCLogger left, TempIRCLogger joined 16:35 dakkar left
Nemokosch Hello again, this time I simply brought Python 18:35
```py
answer in ('yes', 'no', 'maybe', 'whatever')
```
so I'd like to do something like this in Raku
how do I do it?
lizmat $answer (elem) <yes no maybe whatever>
or: $answer ∈ <yes no maybe whatever> 18:36
Nemokosch oh so it works without extra quoting
thanks; I still got the quotes wrong here and there 18:37
lizmat <foo bar baz> is the equivalent of ('foo','bar','baz')
Nemokosch yes, I'm supposed to know that... actually sometimes I get confused by the gist output 18:43
lizmat gist is just that: it's a gist, it's not code :-) 18:45
Nahita m:``` 18:46
say <yes no maybe whatever>.raku;
```
lizmat ("yes", "no", "maybe", "whatever") 18:47
actually, this is shorter:
dd <yes no maybe whatever>
it calls .raku on whatever you give it, and does some more introspection 18:48
gfldex m:``` 21:42
multi sub infix:<in>(\needle, List \l) { l.first(needle) ?? True !! False }
multi sub infix:<in>(\needle, Iterable \l) { l.list.first(needle) ?? True !! False }
multi sub infix:<in>(\needle, Str \s) { s.contains(needle) ?? True !! False }
say 'foo' in 'foobar';
say 'foo' in 'barbuzz';
say '1' in <1 2 3>;
say '1' in <0 2 3>;
```
<@!297037173541175296> if you really like the in operation, you can define a new operator ofc. ^^^
Nemokosch cool 😎 😄 22:18
avuserow You can also use junctions: `$answer eq any(<yes no maybe whatever>)` 23:39
Nemokosch also cool 23:54
however...
```perl
constant \choices = {1 => ('old', "old_$basis-postfix"), 2 => ('new', 'old'), 3 => ('new', 'old', "old_$basis-postfix")};
if $choice.Str (elem) '1'..'3' {
run 'meld', slip(choices{$choice});
}
```
this really hurt my brain 23:55
first of all, $choice came from prompt and it was some IntStr hybrid that fails on the (elem) operator without conversion. How should I more reasonably check for it? 23:56
And why does it pass for a hash index as expected if it fails the (elem) check?
The more troublesome thing is, choices{$choice} is a scalar list apparently 23:57
it took me a lot of time to figure this problem out
slip comes to save the day but how can I have the elements as normal, list-lists? 23:58