Comment by jodrellblank

6 years ago

    PS C:\> 'accessibility' -replace '(?<=^.)(.+)(?=.$)', {$_.Length}
    a11y

(PowerShell 7)

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

      (⊃,(⍕2-⍨≢),⊃∘⌽)'accessibility'

    • 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:

          ,/((⊂∘⍕∘⍴∘⊃@2)⊢⊂⍨((1@2)1,⍨¯1↓1⌷(↑(1,⊂))))'accessibility'
          a11y
      

      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"?)

      6 replies →

  • Why can I not resist these urges? Here it is in J, which is basically APL but in ASCII:

           ({.,(":@(_2+$)),{:) 'accessibility'
           -->  a11y