Naming Conventions |
|||||
|
Scalar |
Vector |
Matrix |
Any |
Non- |
Boolean |
BS |
BV |
BM |
BA |
BN |
Integer |
IS |
IV |
IM |
IA |
IN |
Float |
FS |
FV |
FM |
FA |
FN |
Numeric |
NS |
NV |
NM |
NA |
NN |
Character |
CS |
CV |
CM |
CA |
CN |
Enclosed |
ES |
EV |
EM |
EA |
EN |
enclosed |
TS |
TV |
TM |
TA |
TN |
Simple |
SS |
SV |
SM |
SA |
SN |
Any |
AS |
AV |
AM |
AA |
AN |
phrase e.g.: .X...Y. ⍝ X←BS; Y←IV |
|||||
combinations: use ISV for Integer scalar∨vector |
|||||
B3, I4 &c. to specify higher ranks. |
|||||
InvertList
Convert an N-vector of M-vectors into an M-vector of N-vectors such that the Ith item of the result contains the Ith item of each item of the argument. This operation is called "zip" in functional languages, where it turns a pair of lists into a list of pairs. The standard coding is ⎕IO dependent which here assumes zero.
⊂[1]⍉⊃EV
Examples
⎕FX⍕2 1⍴'r←InvertList ev' 'r←⊂[1]⍉⊃ev'
InvertList('zero' 'one' 'two')('three' 'four' 'five')
zero three one four two five InvertList(0 1)(2 3)(4 5) 0 2 4 1 3 5
InvertList'these' 'three' 'words' ttw hho err sed ees
It's a self inverse when applied to a nested vector all of whose items have the same length.
InvertList InvertList'these' 'three' 'words' these three words
Specialities
Dyalog
This amazingly concise version, suggested by Pete Donnelly, depends on Dyalog's monadic ↓ as split which is equivalent to standard ⊂[0⊥⍳⍴⍴an]AN.
↓⍉↑ev ⍝ ⎕ML≤1
↓⍉⊃ev ⍝ ⎕ML>1see http://www.dyalog.com/dfnsdws/tube_n_zip_cat.htm for a fuller description.
Compatibility
Checked with: APL2, APLX, Dyalog, NARS2000
Test Cases
Show test cases
Test my code, both Examples and Test Cases.
See also: ...
Mentor: PhilLast
Tags: <NestedTranspose> <Zip> <Swap>
APL Wiki