Commute: Difference between revisions

Jump to navigation Jump to search
m (Added fork emulation)
mNo edit summary
Line 16: Line 16:
{{Works in|[[Dyalog APL]], [[dzaima/APL]], [[NARS2000]]}}
{{Works in|[[Dyalog APL]], [[dzaima/APL]], [[NARS2000]]}}


[[Commute]] can be used to emulate a <source lang=apl inline>f g h</source> [[Fork]] when combined with [[Compose]]:
[[Commute]] can be used to emulate a <source lang=apl inline>f g h</source> [[Fork]] when combined with [[Compose]] (note the following code is not workable APL, but a series of evaluations):
<source lang=apl>
<source lang=apl>
g⍨∘f⍨∘h⍨ x   
g⍨∘f⍨∘h⍨ x   
Line 23: Line 23:
(h x) g⍨∘f x ⍝ the last ⍨ is being used dyadically, i.e. Swap
(h x) g⍨∘f x ⍝ the last ⍨ is being used dyadically, i.e. Swap
(h x) g⍨ (f x)  
(h x) g⍨ (f x)  
(f x) g (h x) the last ⍨ is being used dyadically, i.e. Swap
(f x) g (h x) the last ⍨ is being used dyadically, i.e. Swap
</source>
</source>