My APL learning years were before nested arrays came along. Hence I am weak
in certain areas. I am using APL+Win.
I have 1600 recipes in 43 chapters. I have a vector of 43 and each element
is a vector of the recipe names in that chapter. I'd like to remove a level
of nesting and end up with a vector of the 1600 names.
> My APL learning years were before nested arrays came along. Hence I am weak
> in certain areas. I am using APL+Win.
> I have 1600 recipes in 43 chapters. I have a vector of 43 and each element
> is a vector of the recipe names in that chapter. I'd like to remove a level
> of nesting and end up with a vector of the 1600 names.
Assuming your 43-item vector looks like this (here, just 4 chapters):
⍴a←(,⊂'Only one recipe in this chapter') ('Ch 2 Recipe 1' 'Ch 2 Recipe 2') (0⍴⊂'') ('Ch4 R1' 'Ch4 R2' 'Ch4 R3')
4
⍴ša ⍝ Number of recipes in each chapter.
1 2 0 3
"Don Wiss" <donwiss@no_spam.com> wrote in message news:7gjh4892043kfd416o93omijmv07v24sfq@4ax.com...
> My APL learning years were before nested arrays came along. Hence I am weak
> in certain areas. I am using APL+Win.
> I have 1600 recipes in 43 chapters. I have a vector of 43 and each element
> is a vector of the recipe names in that chapter. I'd like to remove a level
> of nesting and end up with a vector of the 1600 names.
> It must be something real simple...
Enlist
Return a simple vector comprising the simple items of arg arranged in depth first row-major order. R is any array.
> "Don Wiss" <donwiss@no_spam.com> wrote in message news:7gjh4892043kfd416o93omijmv07v24sfq@4ax.com...
>> My APL learning years were before nested arrays came along. Hence I am weak
>> in certain areas. I am using APL+Win.
>> I have 1600 recipes in 43 chapters. I have a vector of 43 and each element
>> is a vector of the recipe names in that chapter. I'd like to remove a level
>> of nesting and end up with a vector of the 1600 names.
>> It must be something real simple...
> Enlist
> Return a simple vector comprising the simple items of arg arranged in depth first row-major order. R is any array.
> r← ∊{your 43 element vector} should do the trick
> Graham.
If what he wants to end up with is a 1600 element vector, with each element containing one recipe, then enlist will not do it -- it would go "too far." Enlist would remove ALL levels of nesting (he indicated remove "a" level, which I interpreted as meaning one level), and he'd end up with one simple character vector containing all the recipes all smooshed together. Don, clarification?
On Thu, 06 Sep 2012 13:13:02 -0400, Rav <Pa...@cais.com> wrote:
>On 9/6/2012 12:29 PM, Don Wiss wrote:
>> I have 1600 recipes in 43 chapters. I have a vector of 43 and each element
>> is a vector of the recipe names in that chapter. I'd like to remove a level
>> of nesting and end up with a vector of the 1600 names.
>Then this will do what you want, I think:
On Sep 6, 9:00 pm, Don Wiss <donwiss@no_spam.com> wrote:
> On Thu, 06 Sep 2012 13:13:02 -0400, Rav <Pa...@cais.com> wrote:
> >On 9/6/2012 12:29 PM, Don Wiss wrote:
> >> I have 1600 recipes in 43 chapters. I have a vector of 43 and each element
> >> is a vector of the recipe names in that chapter. I'd like to remove a level
> >> of nesting and end up with a vector of the 1600 names.
> >Then this will do what you want, I think:
> > ??,/a
> As in: {take},/a
> Yes. That works just fine. Thanks.
You are right; {take} works. But the symbol Rav used which may have
gotten lost in your browser was a disclose (right horseshoe). Just as
a matter of esthetics I like disclose better. The shape of ,/a is the
shape of a scalar. {take} of it means take the first element, but
there really is no "first" element of a scalar just as there is no
first element of a 3x4 matrix. Given that {take}3 4{rho}'asdfasdfasdf'
isn't allowed, the fact that {take}7 or {take},/a is allowed feels to
me not to be purist APL.
> On Sep 6, 9:00 pm, Don Wiss <donwiss@no_spam.com> wrote:
>> On Thu, 06 Sep 2012 13:13:02 -0400, Rav <Pa...@cais.com> wrote:
>>> On 9/6/2012 12:29 PM, Don Wiss wrote:
>>>> I have 1600 recipes in 43 chapters. I have a vector of 43 and each element
>>>> is a vector of the recipe names in that chapter. I'd like to remove a level
>>>> of nesting and end up with a vector of the 1600 names.
>>> Then this will do what you want, I think:
>>> ??,/a
>> As in: {take},/a
>> Yes. That works just fine. Thanks.
> You are right; {take} works. But the symbol Rav used which may have
> gotten lost in your browser was a disclose (right horseshoe). Just as
> a matter of esthetics I like disclose better. The shape of ,/a is the
> shape of a scalar. {take} of it means take the first element, but
> there really is no "first" element of a scalar just as there is no
> first element of a 3x4 matrix. Given that {take}3 4{rho}'asdfasdfasdf'
> isn't allowed, the fact that {take}7 or {take},/a is allowed feels to
> me not to be purist APL.
> Charles
Hi, Charles. While I happen to agree with you that disclose is preferable (since the intent is to remove a level of nesting, and not take the "first" element), and that's why I used it, at least in APL+Win and NARS2000 {take}3 4{rho}'asdfasdfasdf' does work (returns 'a'). I don't know about Dyalog or others.
Rav <Pa...@cais.com> writes:
>Hi, Charles. While I happen to agree with you that disclose is >preferable (since the intent is to remove a level of nesting, and not >take the "first" element), and that's why I used it, at least in APL+Win >and NARS2000 {take}3 4{rho}'asdfasdfasdf' does work (returns 'a'). I >don't know about Dyalog or others.
In Dyalog there is the migration level. If you are using migration levels greater than 2, then I am not sure what using {take} would do, but I think it would have the effect of being a first or disclose operation and would work on 3 4⍴⍳12 for example. However, with migration levels below 2, which is the default, ↑3 4⍴⍳12 gives you the same thing back, while ⊃3 4⍴⍳12 gives you 1. I think this is because the {take} function in migration level 0 flattens out a list that is nested. That is, (⍴↑3 4⍴⊂⍳12)≡3 4 12.
-- Aaron W. Hsu | arcf...@sacrideo.us | http://www.sacrideo.us Programming is just another word for the lost art of thinking.
> > On Sep 6, 9:00 pm, Don Wiss <donwiss@no_spam.com> wrote:
> >> On Thu, 06 Sep 2012 13:13:02 -0400, Rav <Pa...@cais.com> wrote:
> >>> On 9/6/2012 12:29 PM, Don Wiss wrote:
> >>>> I have 1600 recipes in 43 chapters. I have a vector of 43 and each element
> >>>> is a vector of the recipe names in that chapter. I'd like to remove a level
> >>>> of nesting and end up with a vector of the 1600 names.
> >>> Then this will do what you want, I think:
> >>> ??,/a
> >> As in: {take},/a
> >> Yes. That works just fine. Thanks.
> > You are right; {take} works. But the symbol Rav used which may have
> > gotten lost in your browser was a disclose (right horseshoe). Just as
> > a matter of esthetics I like disclose better. The shape of ,/a is the
> > shape of a scalar. {take} of it means take the first element, but
> > there really is no "first" element of a scalar just as there is no
> > first element of a 3x4 matrix. Given that {take}3 4{rho}'asdfasdfasdf'
> > isn't allowed, the fact that {take}7 or {take},/a is allowed feels to
> > me not to be purist APL.
> > Charles
> Hi, Charles. While I happen to agree with you that disclose is
> preferable (since the intent is to remove a level of nesting, and not
> take the "first" element), and that's why I used it, at least in APL+Win
> and NARS2000 {take}3 4{rho}'asdfasdfasdf' does work (returns 'a').
Right you are, also with the DOS versions of Manugistics APL (versions
5 & 6 -- called APL+DOS I think but I'm never sure) that I've been
using for years, always incorrectly assuming that this pearl of an
expression was unavailable to me. The times I could have had!