Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for the Behind operator #171

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions language-reference-guide/docs/primitive-operators/behind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<h1 class="heading"><span class="name">Behind</span> <span class="command">{R}←{X}f⍛gY</span></h1>

!!! note "Classic Edition"
The symbol `⍛` is not available in Classic Edition, and the Behind operator is instead represented by `⎕U235b`.

`f` can be any monadic function which returns a result. Its result must be suitable as the left argument to the funtion `g`.

`g` can be any dyadic function, and it does not need to return a result.

`Y` can be any array that is suitable as the right argument to the function `g`.
If `X` is omitted, `Y` must also be suitable as the right argument to the function `X`.

`X` can be any array that is suitable as the right argument to the function `f`.

The derived function is equivalent to either `(f Y) g Y` or `(f X) g Y`, depending on whether `X` is specified or not.

The Behind operator allows functions to be *glued* together to build up more complex functions. For further information, see [Function Composition](./operator-syntax.md).

<h2 class="example">Examples</h2>
```apl
⍝ Is it a palindrome?
⌽⍛≡ 'Dyalog'
0
⌽⍛≡ 'racecar'
1

⍝ Drop from the right
4-⍛↓'Dyalog APL'
Dyalog
```
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ A dyadic operator may be bound or *curried* with its right operand to form a mon

# Function Composition

Function composition refers to the "gluing" together of two functions using a dyadic operator such that the functions are applied to the argument(s) as normal, but in a particular pattern specific to the operator that is being used. The term function composition comes from traditional mathematics where it is used for a function `h(x)=f(g(x))` when written as `h(x)=(f∘g)(x)` APL generalises this idea to dyadic functions, allowing various patterns of application in addition to the simple application of one monadic function to the result of another monadic function. The three main patterns, represented by Atop, Beside, and Over can be visualised as follows:
Function composition refers to the "gluing" together of two functions using a dyadic operator such that the functions are applied to the argument(s) as normal, but in a particular pattern specific to the operator that is being used. The term function composition comes from traditional mathematics where it is used for a function `h(x)=f(g(x))` when written as `h(x)=(f∘g)(x)` APL generalises this idea to dyadic functions, allowing various patterns of application in addition to the simple application of one monadic function to the result of another monadic function. The four main patterns, represented by Atop, Behind, Beside, and Over can be visualised as follows:

![compositions](../img/compositions.png)

When any of these are applied monadically, the dotted branch falls away, and they are all equivalent to each other and to `h(x)=(f∘g)(x)` of traditional mathematics.
![behind compositions](../img/behind-compositions.png)

When any of these are applied monadically, the dotted branch falls away, and with the exception of Behind, they are all equivalent to each other and to `h(x)=(f∘g)(x)` of traditional mathematics.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Table: Dyadic Primitive Operators {: #DyadicOperators }
| At |`f@gY` | `Xf@gY` |
| Atop |`f⍤gY` | `Xf⍤gY` |
| Axis |`f[B]Y` | `Xf[B]Y` |
| Behind |`f⍛gY` | `Xf⍛gY` |
| Beside |`f∘gY` | `Xf∘gY` |
| Bind |`A∘gY` | &nbsp; |
|_ _|`(f∘B)Y` | &nbsp; |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
|`⍤` |Jot Diaeresis |[Atop](atop.md) |`{R}←{X}f⍤gY` |
|`[]` |&nbsp; |[Axis with Dyadic Operand](axis-with-dyadic-operand.md) |`R←Xf[B]Y` |
|`[]` |&nbsp; |[Axis with Monadic Operand](axis-with-monadic-operand.md) |`R←f[B]Y` |
|`⍛` |Jot Underbar |[Behind](behind.md) |`{R}←{X}f⍛gY` |
|`∘` |Jot |[Beside](beside.md) |`{R}←{X}f∘gY` |
|`∘` |Jot |[Bind](bind.md) |`{R}←A∘fY{R}←(f∘B)Y`|
|`⍨` |Tilde Diaeresis|[Commute](commute.md) |`{R}←{X}f⍨Y` |
Expand Down
22 changes: 22 additions & 0 deletions language-reference-guide/docs/symbols/jot-underbar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<h1 class="heading"><span class="name">Jot Underbar</span> <span class="command">⍛</span></h1>

## Jot Underbar is a Dyadic Operator

## Operator Jot Underbar Means

[Behind](../primitive-operators/behind.md)
```apl
⍝ Is it a palindrome?
⌽⍛≡ 'Dyalog'
0
⌽⍛≡ 'racecar'
1

⍝ Drop from the right
4-⍛↓'Dyalog APL'
Dyalog
```

[Language Elements](./language-elements.md)


8 changes: 8 additions & 0 deletions language-reference-guide/docs/symbols/language-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@
<td class="Dyalog"><a href="../at">@</a>
</td>
</tr>
<tr>
<td class="Dyalog"><a href="../jot-underbar">⍛</a></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>

## Other Language Elements
Expand Down
1 change: 1 addition & 0 deletions language-reference-guide/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ nav:
- Atop: primitive-operators/atop.md
- Axis with Monadic Operand: primitive-operators/axis-with-monadic-operand.md
- Axis with Dyadic Operand: primitive-operators/axis-with-dyadic-operand.md
- Behind: primitive-operators/behind.md
- Beside: primitive-operators/beside.md
- Bind: primitive-operators/bind.md
- Commute: primitive-operators/commute.md
Expand Down
1 change: 1 addition & 0 deletions language-reference-guide/print_mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ nav:
- Atop: primitive-operators/atop.md
- Axis with Monadic Operand: primitive-operators/axis-with-monadic-operand.md
- Axis with Dyadic Operand: primitive-operators/axis-with-dyadic-operand.md
- Behind: primitive-operators/behind.md
- Beside: primitive-operators/beside.md
- Bind: primitive-operators/bind.md
- Commute: primitive-operators/commute.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ A `TRANSLATION ERROR` will also be issued when a Classic edition attempts to `)L

`TCPSocket` objects have an `APL` property that corresponds to the Unicode property of a file, if this is set to `Classic` (the default) the data in the socket will be restricted to `⎕AV`, if Unicode it will contain Unicode character data. As a result, `TRANSLATION ERROR`s can occur on transmission or reception in the same way as when updating or reading a file component.

The symbols `⊆`, `⍸`, `⍤`, `⍠`, `⌸`, `⌺` and `` used for the
The symbols `⊆`, `⍸`, `⍤`, `⍠`, `⌸`, `⌺`, `⍥` and `` used for the
Nest (Interval Index) and
Where (Partition) functions, the
Rank,
Variant,
Key,
Stencil and
Over operators respectively are available only in the Unicode edition. In the Classic edition, these symbols are replaced by `⎕U2286`, `⎕U2378`, `⎕U2364`, `⎕U2360`, `⎕U2338`, `⎕U233a` and `⎕U2365` respectively. In both Unicode and Classic editions Variant may be represented by `⎕OPT`.
Stencil,
Over and
Behind operators respectively are available only in the Unicode edition. In the Classic edition, these symbols are replaced by `⎕U2286`, `⎕U2378`, `⎕U2364`, `⎕U2360`, `⎕U2338`, `⎕U233a`, `⎕U2365` and `⎕U235b` respectively. In both Unicode and Classic editions Variant may be represented by `⎕OPT`.

## Very large array components

Expand Down