From 682ec99d2c5fbef60be6ac08c027fa09a5d0f37e Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 8 May 2022 13:41:03 -0400 Subject: Introduce | when it's used in the combinator tutorial --- tutorial/README.md | 2 +- tutorial/combinator.md | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'tutorial') diff --git a/tutorial/README.md b/tutorial/README.md index 98813365..c02c4725 100644 --- a/tutorial/README.md +++ b/tutorial/README.md @@ -12,5 +12,5 @@ The tutorials available so far: |------------------------------|----------|----------- | [Expressions](expression.md) | Arithmetic, syntax, affine characters | `+-×÷⋆√˜⁼˙∘` | [List manipulation](list.md) | Lists, strings, and strands; pervasion | `∾⋈⌽↕¨´` -| [Combinators](combinator.md) | Tacit programming, booleans | `<>≠=≤≥≡≢○⊸⟜` +| [Combinators](combinator.md) | Tacit programming, booleans | `\|<>≠=≤≥≡≢○⊸⟜` | [Variables](variable.md) | Declarations, cross-roles | `∧∨¬⊣⊢↑↓«»⌾` diff --git a/tutorial/combinator.md b/tutorial/combinator.md index 7ae8237c..70f03cfa 100644 --- a/tutorial/combinator.md +++ b/tutorial/combinator.md @@ -16,6 +16,13 @@ There are benefits to being tightly restricted and horribly confined! In program This composition starts with the three values `|`, `-`, and `6`. To produce its result, it first applies `-` to `6`, giving `¯6`, a new value that it's free to use later. Then it applies `|` to `¯6`, giving `6` again. Bit of a waste. + +Oh, right, `|` is another one of those math class things, the absolute value. It makes negative numbers positive, and leaves positive ones alone, so |-6| is 6. But Iverson worked out a neat trick when he turned his mathematical notation into a programming language: if we write `|¯6` without the trailing bar, then `|` can be an ordinary one-argument function. Which means it can be used as an operand to the combinator `∘` for example. + In BQN's combinators, the result of a function application is never used as a function itself. This allows us to use a graphic like the one below to represent a combinator. In each graph, function applications are illustrated with the name of the function linked by yellow lines to its arguments below (this is the same view as the expression diagrams we've been using, flipped upside down and cleaned up a little).