This channel is intended for people just starting with the Raku Programming Language ( Logs are available at
Set by lizmat on 8 June 2022.
01:21 explorer left 04:30 kjp left 04:35 kjp joined
dano I have an array of elements and and I need to know if there are ANY matches to a predicate. What is the way to do this in Raku? I guess I could do .grep(predicate).elems > 0, but that isn't the most efficient way of doing it 07:38
rcmlz If this predicate can be expressed also as junction, then you could use a junction on booth sides. all(@list) > 0; # All members greater than zero? all(@a) == any(@b); # All elements of @a present in @b? 08:45
appart from that I use and a lot ... 08:46
for doing stuff on lists. 08:47
gfldex dano: Any-junctions do short circuit. So if the Array is large, you want those. 09:28
lizmat there's also .first: that's a grep that returns the first match 09:46
dano ^^
10:51 lizmat_ joined 10:52 lizmat_ left, lizmat_ joined 10:54 lizmat left
dano Thanks, .first is what I needed, though the junctions thing seems interesting 11:02
lizmat_ although boolifications of Junctions *do* shortcut, building the Junction is *not* lazy 11:23
so I think using .first is the most efficient thing to do 11:24
second most efficient thing would be to limit .grep to producing only a single value
aka: .grep(...).head or .grep[0]
11:24 lizmat_ left 11:25 lizmat joined
gfldex lizmat: Could building the Junction be lazy (given somebody discovers the tuit-well)? 13:39
lizmat possibly: the eigenstates are currently an (eager) IterationBuffer 15:08
making it a full blown List would make that possible, but at the expense of all other eager uses 15:09
21:55 samebchase left 22:04 snonux left 22:05 snonux joined