Index Generator: Difference between revisions

Jump to navigation Jump to search
m
→‎Scalar-vector discrepancy in nested APLs: Kap also treats singleton vectors as vectors
m (Text replacement - "<source" to "<syntaxhighlight")
Tags: Mobile edit Mobile web edit
m (→‎Scalar-vector discrepancy in nested APLs: Kap also treats singleton vectors as vectors)
 
(2 intermediate revisions by 2 users not shown)
Line 77: Line 77:
== Scalar-vector discrepancy in nested APLs ==
== Scalar-vector discrepancy in nested APLs ==


In [[NARS]] and later [[Nested array theory|nested]] APLs which share its definition, the result of Iota is [[simple]] when the argument is a [[singleton]] and [[nested]] otherwise. This is because, when the argument is a singleton, each [[index]] in the result is represented as a [[scalar]] rather than a 1-[[element]] [[vector]]. [[dzaima/APL]] breaks from this definition by using vector indices whenever the argument is a vector, and scalar indices if the argument is a scalar, so that the result is only simple if the argument was scalar. This definition has the property that the [[shape]] of each index matches the shape of the argument.
In [[NARS]] and later [[Nested array theory|nested]] APLs which share its definition, the result of Iota is [[simple]] when the argument is a [[singleton]] and [[nested]] otherwise. This is because, when the argument is a singleton, each [[index]] in the result is represented as a [[scalar]] rather than a 1-[[element]] [[vector]]. [[dzaima/APL]] and [[Kap]] break from this definition by using vector indices whenever the argument is a vector, and scalar indices if the argument is a scalar, so that the result is only simple if the argument was scalar. This definition has the property that the [[shape]] of each index matches the shape of the argument.


Such an extension breaks compatibility with earlier non-nested APLs: although these APLs required the argument of Iota to be a [[singleton]], they always allowed a [[scalar]] or [[vector]], and sometimes any [[singleton]]. This is because a shape to be passed to Iota would often naturally be a vector: for example, [[Shape]] always returns a vector, and a function such as [[Tally]] to return a scalar length did not exist.
Such an extension breaks compatibility with earlier non-nested APLs: although these APLs required the argument of Iota to be a [[singleton]], they always allowed a [[scalar]] or [[vector]], and sometimes any [[singleton]]. This is because a shape to be passed to Iota would often naturally be a vector: for example, [[Shape]] always returns a vector, and a function such as [[Tally]] to return a scalar length did not exist.
Line 91: Line 91:
== Outside of APL ==
== Outside of APL ==


The name "iota" has sometimes been used to indicate an increasing sequence of integers even in languages other than APL:
The name "iota" has sometimes been used to indicate an increasing sequence of integers even in languages other than APL. In the [[wikipedia:C++|C++11]] standard library, <syntaxhighlight lang=c++ inline>std::iota()</syntaxhighlight> fills an iterator with such a sequence, and was named after the APL glyph.<ref>cppreference.com. [https://en.cppreference.com/w/cpp/algorithm/iota std::iota]. Retrieved 2020-04-28.</ref><ref name="iotashaming"/><ref>Rob Mayoff. [https://stackoverflow.com/a/9244949 Answer to "What does iota of std::iota stand for?"] on Stack Overflow.  Retrieved 2020-04-28.</ref> The [[wikipedia:Go (programming language)|Go]] language also uses the name <syntaxhighlight lang=go inline>iota</syntaxhighlight> as a predeclared identifier which represents increasing integers: each time it is used within a single constant declaration its value will be one higher.<ref>The Go Programming Language Specification. [https://golang.org/ref/spec#Iota Iota]. 2020-01-14.</ref> Functions named "iota" appear in libraries such as [[wikipedia:Scheme (programming language)|Scheme]]'s SRFI 1 (list library),<ref>Olin Shivers. [https://srfi.schemers.org/srfi-1/srfi-1.html#iota SRFI 1: List Library]. Finalized 1999-10-09.</ref> [[wikipedia:general-purpose computing on graphics processing units|GPGPU]] library [[wikipedia:ArrayFire|ArrayFire]],<ref>ArrayFire: Functions. [https://arrayfire.org/docs/group__data__func__iota.htm iota]. Jun 2, 2015.</ref> and [[wikipedia:JavaScript|JavaScript]] library scijs.<ref>scijs.not. [https://scijs.net/packages/#scijs/iota-array iota-array]. Retrieved 20223-05-11</ref> The [[wikipedia:Berkeley Software Distribution|BSD]] operating system (including derivative [[wikipedia:macOS|macOS]]) uses <syntaxhighlight lang=shell inline>jot</syntaxhighlight> to print sequential data, a name derived in part from APL's glyph.<ref>openbsd.org. [https://man.openbsd.org/jot#DESCRIPTION jot]. Retrieved 2022-08-04.</ref>
* The [[wikipedia:C++|C++11]] standard library has <syntaxhighlight lang=c++ inline>std::iota()</syntaxhighlight> fills an iterator with such a sequence, and was named after the APL glyph.<ref>cppreference.com. [https://en.cppreference.com/w/cpp/algorithm/iota std::iota]. Retrieved 2020-04-28.</ref><ref name="iotashaming"/><ref>Rob Mayoff. [https://stackoverflow.com/a/9244949 Answer to "What does iota of std::iota stand for?"] on Stack Overflow.  Retrieved 2020-04-28.</ref>
* The [[wikipedia:Go (programming language)|Go]] language also uses the name <syntaxhighlight lang=go inline>iota</syntaxhighlight> as a predeclared identifier which represents increasing integers: each time it is used within a single constant declaration its value will be one higher.<ref>The Go Programming Language Specification. [https://golang.org/ref/spec#Iota Iota]. 2020-01-14.</ref>
* The popular [[wikipedia:Scheme (programming language)|Scheme]] list library SRFI 1 also includes a function called <syntaxhighlight lang=scheme inline>iota</syntaxhighlight> in reference to APL, which takes a count as well as optional starting value (default 0) and step size (default 1) arguments.<ref>Olin Shivers. [https://srfi.schemers.org/srfi-1/srfi-1.html#iota SRFI 1: List Library]. Finalized 1999-10-09.</ref>
* The [[wikipedia:ArrayFire|ArrayFire]] library for [[wikipedia:general-purpose computing on graphics processing units|general-purpose computing on graphics processing units]] has an <syntaxhighlight lang=c inline>iota</syntaxhighlight> function with a result similar to that of A+ and J when given a [[#Vector_arguments|vector argument]].<ref>ArrayFire: Functions. [https://arrayfire.org/docs/group__data__func__iota.htm iota]. Jun 2, 2015.</ref>
* The [[wikipedia:Berkeley Software Distribution|BSD]] operating system and its derivatives, for example [[wikipedia:macOS|macOS]], have a <syntaxhighlight lang=shell inline>jot</syntaxhighlight> which can print sequential data. The name <syntaxhighlight lang=shell inline>jot</syntaxhighlight> derives in part from APL's glyph.<ref>openbsd.org. [https://man.openbsd.org/jot#DESCRIPTION jot]. Retrieved 2022-08-04.</ref>


== See also ==
== See also ==

Navigation menu