Brendan LeTourneau
Brendan LeTourneau

Reputation: 23

APL Dyalog Nested Array Element Transformations

I've been using Dyalog APL for a class assignment and I've run across an issue in transforming each element of a nested array.

I have a character array called HOLD which has a variable amount of 7 character long arrays in it. Using a split transformation I can turn it into a nested array of readonly nested arrays, however I need them to be to be character vectors.

I can individually change an element into a character vector with the MIX operator,

TEST←↑HOLD[1]  ⍝Test will be a character vector

but I can't seem to do this to every single element at the same time.

My best attempt looks like

TEST←↑¨HOLD ⍝Test will be a nested array, seemingly identical to hold

but this seems to leave each element as readonly character array. How can I preform this operation on every element in HOLD at the same time and get a resulting nested array of only character vectors?

Upvotes: 2

Views: 661

Answers (1)

MBaas
MBaas

Reputation: 7530

What you're looking for is the "enlist"-primitive. It requires ⎕ML to be >0, so I'm assigning it within a dfn (to keep scope local): TEST←{⎕ML←1 ⋄ ∊⍵}HOLD

If your ⎕ML is already >0 (see status bar), you can simply do: TEST←∊HOLD

Try it online!

Upvotes: 2

Related Questions