Re: On Junctions

[I’d been planning to put this suggestion on hold until the spec is sufficiently complete for me to attempt to implement it as a module. But people are discussing this again, so maybe it's not just me. I apologize if I appear to be beating a dead horse...]
```
Jon Lang wrote:```
```
```
```Maybe you could have something like a filter function
```
```
yes, but

```
```that takes a
junction and a test condition and returns a junction of those
```
eigenstates from the original one that passed the test.
```
```
But why is this a useful thing to do? I think that you're proposing, for compound junctions:
```
ok any( 1|2, 1&2, 5|15, 5&15 ) where { \$_ < 10 }
=== any( 1|2, 1&2, 5|15 )

```
To me, it still feels like you're thinking of a junction as a set of values, and inventing an operator specifically for the purpose of messing with those values. I do not see "values of a junction" as a meaningful user-level concept. I prefer to turn the problem around, and suggest a different operator, motivated by a different issue, and then apply that operator to junctions.
```

Consider this statement:

say (0..Inf).grep: { \$_ < 10 };

```
I would expect it to take infinite time to complete (or else fail quickly). It would be wrong to expect perl to figure out the correct answer analytically, because that is impossible in the general case of an arbitrary code block. So I instead propose an operator-based grep:
```
say 0..inf G[<] 10;
>>> [0..9]

```
This “grep metaoperator” can be expected to analytically determine the result (of grepping an infinite list) in finite time. It might also be used to avoid curlies for simple greps:
```
say @lines G~~ /foo/;

```
The operator exists to filter infinite lists in finite time. But it also solves the junction problem:
```
say (-Inf .. Inf) G== 3|4;
>>> [3,4]

say ^Int G== 3|4; ## assuming ^Int means “any Int value”
>>> [3,4]

\$score = [+] 1|11, 1|11, 1+11, 1+11, 4;
say max( 1..21 G== \$score ) // "bust";
>>> 18
```