APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !


Postby Roger|Dyalog on Wed Jun 09, 2021 4:17 pm

In previous posts, the game was to write functions g such that

      (x symbol y) ≡ x g y

for x and y of interest where g does not use the primitive symbol in question. Here, the game is to write a function h which does not use ⍸ or / or ⌿, so that for boolean vector b,

      b ← 1=?9973⍴2
(⍸b) ≡ h b

Since ⎕io is intimately involved with ⍸, the expression should work when ⎕io is 0 or 1. (Nevertheless, ⎕io delenda est!.)

Without 0

      ww ← {(⍳⎕io<⊃⍵),0~⍨⍵×⍳≢⍵}

(⍸b) ≡ ww b

The non-zero elements of b×⍳≢b nearly have what is required. We do need put back a leading 0 when ⎕io is 0 and the leading element of b is 1.

Without Without

      ws ← {(+/~⍵) ↓ {⍵[⍋⍵]} ⍵×⍳≢⍵}

(⍸b) ≡ ws b

If we are paranoid and suspect that / (replicate) may be involved in computing ~0, an alternative computation is to drop the requisite number of leading elements from the sorted result of ⍵×≢⍵.
Posts: 232
Joined: Thu Jul 28, 2011 10:53 am

Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest