trusted
183
edits
Miraheze>Adám Brudzewsky No edit summary |
(→Notable uses: Point "identity matrix" to Wikipedia) |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 28: | Line 28: | ||
</source> | </source> | ||
Reshape can also decrease the rank or [[bound]] of an array. One notable example is the use of an empty left argument <source lang=apl inline> | Reshape can also decrease the rank or [[bound]] of an array. One notable example is the use of an empty left argument [[Zilde]] (<source lang=apl inline>⍬</source>) to produce a [[scalar]]. The scalar is the first 0-[[cell]] of the right argument. In [[Nested array model|nested]] languages <source lang=apl inline>⍬⍴</source> is like [[First]] except that it does not remove a layer of nesting. | ||
<source lang=apl> | <source lang=apl> | ||
9 ⍴ ∘.+⍨ 1 2 1 | 9 ⍴ ∘.+⍨ 1 2 1 | ||
Line 65: | Line 65: | ||
</source> | </source> | ||
{{Works in|[[Dyalog APL]]}} | {{Works in|[[Dyalog APL]]}} | ||
Here the right argument is converted to a ravel vector by ravelling and appending the [[prototype]], then [[indexing]] to produce a vector of the correct length. The indices used are the ravel indices of the result, but they are made to wrap around using [[Residue]]. | Here the right argument is converted to a ravel vector by ravelling and appending the [[prototype]], then [[Bracket indexing|indexing]] to produce a vector of the correct length. The indices used are the ravel indices of the result, but they are made to wrap around using [[Residue]]. | ||
== J variant: Shape == | == J variant: Shape == | ||
Line 73: | Line 73: | ||
== Notable uses == | == Notable uses == | ||
Reshape can be used to produce an [[identity matrix]] by reshaping a vector which is one longer than the desired side length. | Reshape can be used to produce an [[wikipedia:identity matrix|identity matrix]] by reshaping a vector which is one longer than the desired side length. | ||
<source lang=apl> | <source lang=apl> | ||
4 4 ⍴ 5↑1 | 4 4 ⍴ 5↑1 | ||
Line 88: | Line 88: | ||
* [https://chat.stackexchange.com/rooms/52405/conversation/lesson-10-apl-functions-- APL Cultivation] | * [https://chat.stackexchange.com/rooms/52405/conversation/lesson-10-apl-functions-- APL Cultivation] | ||
* [https://www.sacrideo.us/apl-a-day-4-arrays-have-elements/ Arrays have elements] (part of [https://www.sacrideo.us/tag/apl-a-day/ APL a Day]) | |||
=== Documentation === | === Documentation === | ||
* [http://help.dyalog.com/latest/ | * [http://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Reshape.htm Dyalog] | ||
* [http://wiki.nars2000.org/index.php/Rho NARS2000] | * [http://wiki.nars2000.org/index.php/Rho NARS2000] | ||
* [http://microapl.com/apl_help/ch_020_020_470.htm APLX] | * [http://microapl.com/apl_help/ch_020_020_470.htm APLX] | ||
* [https://code.jsoftware.com/wiki/Vocabulary/dollar#dyadic J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/dollar#dyadic J NuVoc] (as <source lang=apl inline>$</source> "Shape") | * [https://code.jsoftware.com/wiki/Vocabulary/dollar#dyadic J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/dollar#dyadic J NuVoc] (as <source lang=apl inline>$</source> "Shape") | ||
{{APL built-ins}} | {{APL built-ins}}[[Category:Primitive functions]] |