3 ms·
> Do the "contains" example with 5 terms. rg foo1 | rg foo2 | rg foo3 | rg foo4 | rg foo5 or, if filename matches are a possibility rg foo1 | rg :.\*foo2
by mkl 3y ago
> Do the "contains" example with 5 terms.
rg foo1 | rg foo2 | rg foo3 | rg foo4 | rg foo5
or, if filename matches are a possibility
rg foo1 | rg :.\*foo2 | rg :.\*foo3 | rg :.\*foo4 | rg :.\*foo5
vs
rak '{.contains("foo1") && .contains("foo2") && .contains("foo3") && .contains("foo4") && .contains("foo5")}'
My point is that despite their claim of superiority, their examples do not show any. Maybe there's a more efficient rak way to do that chain of .contains? Why not demonstrate that?
- hwayne 3y agoI haven't tried this in Rak proper, but based on my understanding of the README you can do something like the following: rak '{so one ["foo1", "foo2", "foo3"].map(-> \x{$_.contains(x)})}' That's a bit though; it'll match lines that contain exactly one of "foo1", "foo2", "foo3", but not zero or 2+.
- lizmat 3y ago$ rak '{.contains: "foo1" & "foo2" & "foo3" & "foo4" &"foo5"}' This actually shows one of the secret powers of the Raku Programming Language: Junctions https://docs.raku.org/type/Junction https://docs.raku.org/type/Junction Alternately one could express this as: $ rak '{.contains: <foo1 foo2 foo3 foo4 foo5>.all}' Or using whatever currying: https://docs.raku.org/type/Whatever https://docs.raku.org/type/Whatever $ rak '*.contains: <foo1 foo2 foo3 foo4 foo5>.all'