I tried to write it a couple of different ways, but I keep coming back to approximately your code as the most direct way, if written slightly differently with (⍕¯2+⍴) in the middle; I'm puzzled by the behaviour of being able to drop and take negative numbers to index from the end of the array, but not being able to use negative indexes in other contexts. Why is (¯1⌷word) an error, instead of working like (¯1↑word) works?
Here's a much more convoluted way, because everything is difficult in this language:
a frustratingly roundabout way to build up the boolean vector:
'accessibility'
1100000000001 ⍝ for penclose
without counting the length first.
(Is there a way to drop from the middle of an array? "delete index 4 5 6"? Or to insert into the middle of an array? "Insert between elements 2 and 3"?)
That's not an acronym, GP's point is that a single word acronym contains even less information than this (apparently called a 'numeronym').
I'm resisting the urge to rewrite it in APL. :) Nicely done.
No need to resist
I tried to write it a couple of different ways, but I keep coming back to approximately your code as the most direct way, if written slightly differently with (⍕¯2+⍴) in the middle; I'm puzzled by the behaviour of being able to drop and take negative numbers to index from the end of the array, but not being able to use negative indexes in other contexts. Why is (¯1⌷word) an error, instead of working like (¯1↑word) works?
Here's a much more convoluted way, because everything is difficult in this language:
a frustratingly roundabout way to build up the boolean vector:
without counting the length first.
(Is there a way to drop from the middle of an array? "delete index 4 5 6"? Or to insert into the middle of an array? "Insert between elements 2 and 3"?)
6 replies →
APL is a strong drug, I need to regulate my dosage. :)
Why can I not resist these urges? Here it is in J, which is basically APL but in ASCII:
Did you reply to the wrong person?
This is a cool one-liner though!