Ravel: Difference between revisions

Jump to navigation Jump to search
4 bytes removed ,  11:48, 25 October 2019
class= → lang=
Miraheze>Adám Brudzewsky
No edit summary
Miraheze>Adám Brudzewsky
(class= → lang=)
Line 8: Line 8:


You can use ravel to squash a [[matrix]] down to one dimension. The elements are listed in reading order—left to right, top to bottom.
You can use ravel to squash a [[matrix]] down to one dimension. The elements are listed in reading order—left to right, top to bottom.
<source class=apl>
<source lang=apl>
       ⊢x ← 3 4⍴⍳12            ⍝ A matrix
       ⊢x ← 3 4⍴⍳12            ⍝ A matrix
1  2  3  4
1  2  3  4
Line 22: Line 22:


Ravelling a [[scalar]] yields a [[singleton]] [[vector]].
Ravelling a [[scalar]] yields a [[singleton]] [[vector]].
<source class=apl>
<source lang=apl>
       ,3
       ,3
3
3
Line 32: Line 32:


[[String]] notation cannot produce a single-character string since it produces a [[scalar]] character instead. Using Ravel on a list of characters in quotes ensures it will be a [[vector]] of characters.
[[String]] notation cannot produce a single-character string since it produces a [[scalar]] character instead. Using Ravel on a list of characters in quotes ensures it will be a [[vector]] of characters.
<source class=apl>
<source lang=apl>
       ≢⍴ 'a'                  ⍝ Scalar character
       ≢⍴ 'a'                  ⍝ Scalar character
0
0
Line 40: Line 40:


[[Function axis|Axis specification]] may accept either a [[vector]] of two or more adjacent [[axis]] [[Index|indices]], or a single non-integer value. If multiple axes are given, they are merged into one axis whose length is the product of their lengths. If only one value is given, a new axis of length 1 is inserted in the indicated "gap" between axes.
[[Function axis|Axis specification]] may accept either a [[vector]] of two or more adjacent [[axis]] [[Index|indices]], or a single non-integer value. If multiple axes are given, they are merged into one axis whose length is the product of their lengths. If only one value is given, a new axis of length 1 is inserted in the indicated "gap" between axes.
<source class=apl>
<source lang=apl>
       ⍴ ,[2 3] 5 4 3 2⍴0
       ⍴ ,[2 3] 5 4 3 2⍴0
5 12 2
5 12 2

Navigation menu