Custom operators: Difference between revisions

From The K Language Wiki
Content added Content deleted
(Create stub)
 
(add example with desc)
 
Line 1: Line 1:
'''Custom operators''' using Unicode characters were introduced by [[ngn/k]] as ''defined verbs''.
'''Custom operators''' using Unicode characters were introduced by [[ngn/k]] as ''defined verbs''.

ngn/k allows definitions of monadic and dyadic overloads for defined verbs, as follows:

<pre>
(⍴:):1+
(⍴):#</pre>

The syntax for the definition also defines how the operator is used. A <code>:</code> is mandatory for using a monadic overload. K will otherwise assume partial application.


[[Category:Features]]
[[Category:Features]]

Latest revision as of 03:59, 6 July 2023

Custom operators using Unicode characters were introduced by ngn/k as defined verbs.

ngn/k allows definitions of monadic and dyadic overloads for defined verbs, as follows:

(⍴:):1+
(⍴):#

The syntax for the definition also defines how the operator is used. A : is mandatory for using a monadic overload. K will otherwise assume partial application.