Constant

Constant ๐•—ห™ ๐•ฉ ๐•— ๐•ฉ ๐•จ ๐•—ห™ ๐•ฉ ๐•— ๐•จ ๐•ฉ

It's one of the simple ones: fห™๐•ฉ is f. And ๐•จfห™๐•ฉ? It's f. Like the identity functions, Constant doesn't compute anything but just returns one of its inputs. It's somewhat different in that it's a deferred modifier, so you have to first apply Constant to its operand and then to some arguments for that non-event to happen.

The design of BQN makes Constant unnecessary in most cases, because when a non-operation (number, character, array, namespace) is applied it already returns itself: ฯ€ห™ is the same function as ฯ€. If you've used much tacit programming, you've probably written a few trains like 2ร—+ (twice the sum), which is nicer than the equivalent 2ห™ร—+. However, a train has to end with a function, so you can't just put a number at the end. Applying ห™ is a convenient way to change the number from a subject to a function role.

โ†—๏ธ
    +รท2   # A number
0.5

    +รท2ห™  # A function
+รท2ห™

    3 (+รท2ห™) 7
5

When programming with first-class functions, the constant application shortcut becomes a hazard! Consider the program {๐•จโŒพ(2โŠธโŠ‘) ๐•ฉ} to insert ๐•จ into an array ๐•ฉ as an element. It works fine with a number, but with a function it's broken:

โ†—๏ธ
    โˆž {๐•จโŒพ(2โŠธโŠ‘) ๐•ฉ} 1โ€ฟ2โ€ฟ3โ€ฟ4
โŸจ 1 2 โˆž 4 โŸฉ

    M โ† -
    m {๐•จโŒพ(2โŠธโŠ‘) ๐•ฉ} 1โ€ฟ2โ€ฟ3โ€ฟ4
โŸจ 1 2 ยฏ3 4 โŸฉ

Here m is applied to 2โŠ‘๐•ฉ even though we want to discard that value. Spelled as m, our context-free grammar knows it's a function argument, but this doesn't affect later usage. Under always applies ๐”ฝ as a function. The proper definition of the insertion function should use a ห™, like this:

โ†—๏ธ
    m {๐•จห™โŒพ(2โŠธโŠ‘) ๐•ฉ} 1โ€ฟ2โ€ฟ3โ€ฟ4
โŸจ 1 2 - 4 โŸฉ