bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: better apl array coding


From: Hans-Peter Sorge
Subject: Re: better apl array coding
Date: Tue, 15 Jun 2021 10:01:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

Hi,

if this is, what you want?

        ar←4 4⍴11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44
        ⍝ btw:
        ar← (10×⍳4)∘.+⍳4

        a←1 2 3 4 4 3 2 1
        b←1 2 3 4 4 3 2 1


      ,[1.1]'lp' 'ar' ar 'a' a 'b' b (d,⌽d←1 1⍉ar)

It is not quite clear, what your intend is.

First:    I'm not a "one liner fan" - though it's training for your 'APL-brain' - get a hand on nested arrays as in ,[1.1] 'lp' 'ar' ar 'a' a 'b' b (d,⌽d←1 1⍉ar) Second:  I'm not a fan of loops - never ever write one. - get a hand on nested arrays :-)

Best Regards
Hans-Peter


Am 15.06.21 um 02:45 schrieb enztec@gmx.com:
hello

i've been using this looping for array work but there has to be a better apl 
way of coding the indexing of the ar array
any suggestions



∇rs←lp;a;b;ar;i
'lp'
'ar'
+ar←4 4⍴11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44
'a'
+a←1 2 3 4 4 3 2 1
'b'
+b←1 2 3 4 4 3 2 1
i←1
rs←⍴0
sp:
rs←rs,ar[a[i]; b[i]]
→((i←i+1)⍴a)/sp
''
∇




reply via email to

[Prev in Thread] Current Thread [Next in Thread]