Identity: Difference between revisions

Jump to navigation Jump to search
888 bytes added ,  20:53, 27 May 2020
Disambiguate with Identity element
mNo edit summary
(Disambiguate with Identity element)
(3 intermediate revisions by 3 users not shown)
Line 2: Line 2:
|<code>⊣</code> <code>⊢</code>
|<code>⊣</code> <code>⊢</code>
|}
|}
:''This page is about the class of primitive functions. For the result of an empty reduction, see [[Identity element]].''
An '''Identity function''', or '''tack function''', is one of the three [[primitive function]]s which returns one of its [[argument]]s with no modification:
An '''Identity function''', or '''tack function''', is one of the three [[primitive function]]s which returns one of its [[argument]]s with no modification:
* '''Identity''', '''Same''', or '''Pass''' (<source lang=apl inline>⊣</source> or <source lang=apl inline>⊢</source>) is [[monadic]] and returns its only argument.
* '''Identity''', '''Same''', or '''Pass''' (<source lang=apl inline>⊣</source> or <source lang=apl inline>⊢</source>) is [[monadic]] and returns its only argument.
Line 7: Line 8:
* '''Right Identity''', or '''Right''' (<source lang=apl inline>⊢</source>) is [[dyadic]] and returns its right argument.
* '''Right Identity''', or '''Right''' (<source lang=apl inline>⊢</source>) is [[dyadic]] and returns its right argument.


The ''right tack'' glyph <source lang=apl inline>⊢</source>, when used for Right, is almost paired with Identity for the monadic case. ''Left tack'', <source lang=apl inline>⊣</source> is usually used for Identity as well, but may be given a different meaning, such as [[Stop]] in [[SHARP APL]].
The ''right tack'' glyph <source lang=apl inline>⊢</source>, when used for Right, is almost paired with Identity for the monadic case. ''Left tack'', <source lang=apl inline>⊣</source> is usually used for Identity as well, but may be given a different meaning, such as [[Stop]] (which returns the constant <source lang=apl inline>0 0⍴0</source>) in [[SHARP APL]] and [[APLX]], or [[Hide]] (which returns the constant <source lang=apl inline>0</source> as a [[shy]] result) in [[GNU APL]].


Identity functions (Identity in particular) may be used like elements of [[APL syntax|syntax]] to break up [[stranding]], or to force a [[shy]] result to be shown. They can also be combined with an array-oriented [[operator]] to perform structural manipulations on arrays. Identity functions are a central feature of [[tacit programming]], in which functions and operators rather than names are used to direct the flow of arguments. The pairing of both Left and Right with monadic Identity makes it easier to design [[ambivalent]] functions which usefully work with one or two arguments.
Identity functions (Identity in particular) may be used like elements of [[APL syntax|syntax]] to break up [[stranding]], or to force a [[shy]] result to be shown. They can also be combined with an array-oriented [[operator]] to perform structural manipulations on arrays. Identity functions are a central feature of [[tacit programming]], in which functions and operators rather than names are used to direct the flow of arguments. The pairing of both Left and Right with monadic Identity makes it easier to design [[ambivalent]] functions which usefully work with one or two arguments.
Line 32: Line 33:
== Uses ==
== Uses ==


As the left [[operand]] to [[Compose]], Right makes the resulting [[derived function]] ignore its left argument (so the result is produced by a [[monadic]] invocation of the right operand, on the right argument). The same pattern can be produced by using Right as the right operand to [[Atop]].
As the left [[operand]] to [[Beside]], Right makes the resulting [[derived function]] ignore its left argument (so the result is produced by a [[monadic]] invocation of the right operand, on the right argument). The same pattern can be produced by using Right as the right operand to [[Atop]].
<source lang=apl>
<source lang=apl>
       2 ⊢∘- 7
       2 ⊢∘- 7
Line 118: Line 119:
1 2 3 4 5 6
1 2 3 4 5 6
</source>
</source>
{{APL built-ins}}
 
== External links ==
 
=== Tutorials ===
* Optima Systems blog: [https://optima-systems.co.uk/left-and-right-tack-in-dyalog-apl/ Left and Right Tack in Dyalog APL]
=== Documentation ===
* Dyalog: [https://help.dyalog.com/17.1/Content/Language/Symbols/Left%20Tack.htm Left Tack], [https://help.dyalog.com/17.1/Content/Language/Symbols/Right%20Tack.htm Right Tack]
* APLX: [http://microapl.com/apl_help/ch_020_020_754.htm Left], [http://microapl.com/apl_help/ch_020_020_756.htm Right], [http://microapl.com/apl_help/ch_020_020_755.htm Pass]
 
{{APL built-ins}}[[Category:Primitive functions]]

Navigation menu