Simple examples: Difference between revisions

Jump to navigation Jump to search
561 bytes added ,  08:14, 14 August 2020
(Remove faulty part)
(2 intermediate revisions by one other user not shown)
Line 41: Line 41:
=== Tacit programming ===
=== Tacit programming ===


{{Main|Tacit}}
{{Main|Tacit programming}}


In APL’s tacit definition, no braces are needed to mark the definition of a function: primitive functions just combine in a way that enables us to omit any reference to the function arguments — hence ''tacit''. Here is the same calculation written tacitly:
In APL’s tacit definition, no braces are needed to mark the definition of a function: primitive functions just combine in a way that enables us to omit any reference to the function arguments — hence ''tacit''. Here is the same calculation written tacitly:
Line 48: Line 48:
8.875
8.875
</source>
</source>
This is a so called 3-train, also known as a ''fork''. It is evaluated like this:
{|
|<source lang=apl>(+⌿ ÷ ≢) 3 4.5 7 21</source>|| {{←→}} ||<source lang=apl>(+⌿ 3 4.5 7 21) ÷ (≢ 3 4.5 7 21)</source>
|}
Note that <source lang=apl inline>+⌿</source> is evaluated as a single derived function.
The general scheme for monadic 3-trains is the following:
{|
|<source lang=apl>(f g h) ⍵</source>|| {{←→}} ||<source lang=apl>(f ⍵) g (h ⍵)</source>
|}
But other types of [[Tacit programming#Trains|trains]] are also possible.


==Text processing==
==Text processing==

Navigation menu