At: Difference between revisions

From The K Language Wiki
Content added Content deleted
No edit summary
m (Lowercase title)
Line 1: Line 1:
{{lowercase title}}
{{primitive|x@y}}
{{primitive|x@y}}

'''At''' is a primitive that unifies list indexing, function application, and dictionary lookup into a single concept. Syntactically, it can be expressed in three equivalent ways: <code>x@y</code> (using <code>@</code> as a verb), <code>x y</code> (juxtaposition of nouns), and <code>x[y]</code> (M-expression).
'''at''' is a primitive that unifies list indexing, function application, and dictionary lookup into a single concept. Syntactically, it can be expressed in three equivalent ways: <code>x@y</code> (using <code>@</code> as a verb), <code>x y</code> (juxtaposition of nouns), and <code>x[y]</code> (M-expression).
"abc"[1]
"abc"[1]
"b"
"b"

Revision as of 21:29, 8 July 2022


At
x@y

at is a primitive that unifies list indexing, function application, and dictionary lookup into a single concept. Syntactically, it can be expressed in three equivalent ways: x@y (using @ as a verb), x y (juxtaposition of nouns), and x[y] (M-expression).

 "abc"[1]
"b"
 {1+2*x}@3
7
 (`a`b!0 1)`b
1

If y is an atom not in the domain of x, at returns the null value for x's type (except in kona).