Post History
BQN, 18 bytesSBCS {⊑(⊑𝕨⊸⍷)¨⊸/∾⟜𝕩¨↑𝕨} Run online! A direct translation of Razetime's APL solution (my attempted improvement ⊣∾{⊢´/𝕨⊸«⊸≡¨↑𝕩}↓⊢ turns out to be not at all correct). The BQN solut...
#1: Initial revision
# [BQN](https://mlochbaum.github.io/BQN/), 18 bytes<sup>[SBCS](https://github.com/mlochbaum/BQN/blob/master/commentary/sbcs.bqn)</sup>
```
{⊑(⊑𝕨⊸⍷)¨⊸/∾⟜𝕩¨↑𝕨}
```
[Run online!](https://mlochbaum.github.io/BQN/try.html#code=RuKGkHviipEo4oqR8J2VqOKKuOKNtynCqOKKuC/iiL7in5zwnZWpwqjihpHwnZWofQoKRsK0wqgg4p+oCiAgIkFCQ0RFRiLigL8iRUZHSEkiCiAgIkFBQUFBQSLigL8iQUFBQUFBQUEiCiAgIkFCQyLigL8iMTIzIgogICIi4oC/IkFCQ0RFIgogICJBQkNEIuKAvyJBQkNEIgogICIi4oC/IiIK4p+p)
A direct translation of Razetime's APL solution (my attempted improvement `⊣∾{⊢´/𝕨⊸«⊸≡¨↑𝕩}↓⊢` turns out to be not at all correct).
The BQN solution is much shorter mainly because it has [Prefixes](https://mlochbaum.github.io/BQN/doc/prefixes.html) (`↑`) built in. Being able to filter with `⊸/` (see [Before](https://mlochbaum.github.io/BQN/tutorial/combinator.html#before-and-after)) also helps a lot.
```
{⊑(⊑𝕨⊸⍷)¨⊸/∾⟜𝕩¨↑𝕨} # Function with left argument 𝕨 and right argument 𝕩
↑𝕨 # All prefixes of 𝕨
∾⟜𝕩¨ # Append 𝕩 after each one
⊸/ # Filter by...
( )¨ # On each string,
𝕨⊸⍷ # Where does 𝕨 appear as a substring?
⊑ # But I only care if it's the first one
⊑ # Then take the first
```
Put together, the pattern `⊑𝕨⊸⍷` tests if `𝕨` is a prefix of the argument.
