list f ⍨ ←

General APL language issues

list f ⍨ ←

Postby Phil Last on Thu Nov 30, 2017 2:51 pm

      ⊢z x c←⍳¨3 4 5     ⍝ set
┌─────┬───────┬─────────┐
│0 1 2│0 1 2 3│0 1 2 3 4│
└─────┴───────┴─────────┘
1 2 3↓z x c ⍝ 0
RANK ERROR
1 2 3↓z x c ⍝ 0

1 2 3↓¨z x c ⍝ 1
┌───┬───┬───┐
│1 2│2 3│3 4│
└───┴───┴───┘
z x c↓⍨←1 2 3 ⍝ 2
z x c
┌───┬───┬───┐
│1 2│2 3│3 4│
└───┴───┴───┘
⊢z x c←⍳¨3 4 5 ⍝ reset
┌─────┬───────┬─────────┐
│0 1 2│0 1 2 3│0 1 2 3 4│
└─────┴───────┴─────────┘
z x c↓¨⍨←1 2 3 ⍝ 3
z x c
┌────┬─────┬──────┐
│┌┬┬┐│┌┬┬┬┐│┌┬┬┬┬┐│
│││││││││││││││││││
│└┴┴┘│└┴┴┴┘│└┴┴┴┴┘│
└────┴─────┴──────┘
I always but always get confused and have to try lots of things in the session before I get algorithms like these correct.
a b c↓⍨← . . .
a b c/⍨← . . .
a b c↓¨⍨← . . .
a b c/¨⍨← . . .
I can nowhere find any reference to this kind of assignment in the help. Is there such a page? Can we have one if not. One that explains why (2) above works but (0) doesn't even though (3) (which doesn't do at all what I expected) is nearer kin to (1) that it is to (0). (if you know what I mean.)

Actually, having composed the above I'm so conversant with it that I probably won't need the page. For at least a couple of days. But posting anyway in case anyone else is confused.
User avatar
Phil Last
 
Posts: 441
Joined: Thu Jun 18, 2009 6:29 pm

Re: list f ⍨ ←

Postby JohnS|Dyalog on Fri Dec 01, 2017 6:32 am

I agree this should be spelled out more in the help:

      ⍝ Modified assignment includes an implicit each:

v←0 0 0
⎕io←1
v[2 2 3 2] +← 1 ⍝ handy histogram technique
v
0 3 1
)copy dfns tc
... saved ...

v←0 0 0 ⍝ reset
v[2 2 3 2] +tc← 1 ⍝ again with tracing
0 + 1 => 1
1 + 1 => 2
0 + 1 => 1
2 + 1 => 3

i←0
i i i +← 1
i
3
i←0
i i i +tc← 1
0 + 1 => 1
1 + 1 => 2
2 + 1 => 3

⍝ similarly (with ⎕io=1):

z x c←⍳¨3 4 5

z x c ↓tc⍨← 1 2 3 ⍝ with implicit each
1 ↓ 1 2 3 => 2 3
2 ↓ 1 2 3 4 => 3 4
3 ↓ 1 2 3 4 5 => 4 5

z x c←⍳¨3 4 5 ⍝ reset

z x c ↓tc¨⍨← 1 2 3 ⍝ with additional explicit each
1 ↓ 1 =>
1 ↓ 2 =>
1 ↓ 3 =>
2 ↓ 1 =>
2 ↓ 2 =>
2 ↓ 3 =>
2 ↓ 4 =>
3 ↓ 1 =>
3 ↓ 2 =>
3 ↓ 3 =>
3 ↓ 4 =>
3 ↓ 5 =>
User avatar
JohnS|Dyalog
 
Posts: 164
Joined: Wed Sep 10, 2008 10:01 am


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest