Scalar function: Difference between revisions

Jump to navigation Jump to search
39 bytes removed ,  08:44, 1 April 2020
Remove derived op to work in dzaima/APL
(→‎User defined scalar functions: Remove incorrect information about J and dzaima/APL)
(Remove derived op to work in dzaima/APL)
Line 73: Line 73:
|}
|}
== User defined scalar functions ==
== User defined scalar functions ==
In [[nested array model]] dialects with the [[Depth (operator)|Depth]] operator (<source lang=apl inline>⍥</source>), any function can be used as a scalar function (that is, be applied to all simple scalars) using the [[derived monadic operator]] <source lang=apl inline>perv←⍥0</source>:
In [[nested array model]] dialects with the [[Depth (operator)|Depth]] operator (<source lang=apl inline>⍥</source>), any function can be used as a scalar function (that is, be applied to all simple scalars) using the <source lang=apl inline>perv←⍥0</source>:


[https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/qKPtUduE6kd9U4HUo56mlMzigke9u2ofdbcAxYJdgUR4sLprWWpeibqGenBqcXFmfl5AUSaQq6AO1KyuyfWoo70CqNk5PyVVoeJ/QWpRGcio3qUGXH75ecHJiTmJRW55YEt6t1qpA/UBzVZQT1OvRZZXAOlT0DBQMNRUMFTQeNTVZKhgoAl0XjsXyOBHvWv@AwA Try it online!]
[https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/qKPtUduE6kd9U4HUo56mlMzigke9u2ofdbcAxYJdgUR4sLprWWpeibqGenBqcXFmfl5AUSaQq6AO1KyuyfWoo70CqNk5PyVVoeK/X35ecHJiTmKRWx7Y4N6tVupAtUDzFNTT1Gu5NJAV9C410FTQMFAw1FQwVNB41NVkqGCgCXRTOxfItEe9a/4DAA Try it online!]


<source lang=apl>
<source lang=apl>
      perv←⍥0
       NonScalarFn←{⍵:'t' ⋄ 'f'}
       NonScalarFn←{⍵:'t' ⋄ 'f'}
       NonScalarFn perv (0 1) 1 (⊂1 0)
       (NonScalarFn⍥0) (0 1) 1 (⊂1 0)
┌──┬─┬────┐
┌──┬─┬────┐
│ft│t│┌──┐│
│ft│t│┌──┐│
Line 87: Line 86:
└──┴─┴────┘
└──┴─┴────┘
</source>
</source>
{{Works in|[[Extended Dyalog APL]]}}
{{Works in|[[Extended Dyalog APL]], [[dzaima/APL]]}}
In dialects that support [[dfn]]s, this operator can be defined<ref>[[John Scholes]], [https://dfns.dyalog.com/n_perv.htm perv] (Scalar pervasion). dfns workspace, 2019-02-17.</ref> as:
In dialects that support [[dfn]]s, this operator can be defined<ref>[[John Scholes]], [https://dfns.dyalog.com/n_perv.htm perv] (Scalar pervasion). dfns workspace, 2019-02-17.</ref> as:


Navigation menu