4 ms·
What was the acronym for "accessibility" again?
by gmfawcett 7y ago
What was the acronym for "accessibility" again?
- deleted 7y ago[deleted]
- jodrellblank 7y agoPS C:\> 'accessibility' -replace '(?<=^.)(.+)(?=.$)', {$_.Length} a11y (PowerShell 7)
- phinnaeus 7y agoDid you reply to the wrong person? This is a cool one-liner though!
- gmfawcett 7y agoI'm resisting the urge to rewrite it in APL. :) Nicely done.
- gmfawcett 7y agoWhy can I not resist these urges? Here it is in J, which is basically APL but in ASCII: ({.,(":@(_2+$)),{:) 'accessibility' --> a11y
- lelf 7y agoNo need to resist (⊃,(⍕2-⍨≢),⊃∘⌽)'accessibility'
- gmfawcett 7y agoAPL is a strong drug, I need to regulate my dosage. :)
- jodrellblank 7y agoI 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"?)
- gmfawcett 7y ago"Everything is difficult in this language" made me smile. :) I mostly agree. There are things things that APL / J make amazingly easy, too, but a lot of simple things are just brutal to me. I'm not a hardcore APL programmer -- I've played with J more than APL, but I'm still a novice at both. I just enjoy the mental challenge sometimes. To insert items from B into A at point N, you could (in pseudocode, I don't have time to play with APL right now!): (Take N of A) , B , (Drop N of A) To remove items from the middle of an array between N and M, I can think of two ways (I might have off-by-one errors here): - (Take N of A) , (Drop M of A) - Bools / A where "Bools" is an array of 1/0 values, and the 1's indicate the elements to keep. As a dyadic verb, "/" means "compress", that is, to keep only the indicated elements from the right-hand object. I'm sure there are other ways! These are the few ways that my limited brain could come up with. :)
- jodrellblank 7y agoI'm also a novice at APL, despite thousands of lines of session scrollback building up basic lines that almost work then I change one character and INSCRUTABLE ERROR, over and over. Your take,B,drop design looks simple and sensible but the repetition of N is bugging me - I tend towards codegolf more than code clarity. The kind of drop I was hoping to find would be like you can index non-contiguous indices and update them: Vector[2 8 5]←100 but instead of them getting value 100, they get deleted. Or like you can do ~ for set subtraction "without some values" like (⍳9)~5 7 but treating the right argument as indices to remove from the array, rather than values to remove from the array. I feel like there's two patterns which work in the same way as the thing I imagine and a space where the thing I imagine could exist but doesn't. Which I've now tried to code up: 4 9 8 7 10 11 {(~(⍳⍴⍵)∊⍺)/⍵}'accessibility' accssty It's not so ugly, but that took me down another rabbit hole of why I can't turn that into a train because there seems to be no way to force monadic iota when the trains design wants it to be dyadic. That is I want 3 4(⍳⍴)'accessibility' to come out the same as (⍳⍴)'accessibility' by somehow blocking the iota from having a left arg. Like 3 4(⍬∘⍳⍴)'accessibility' but Dyalog shoves the numbers in as a left arg then complains that the left arg is unavailable. Is this a problem with having to overload every glyph with a double meaning because of limitations on IBM 1960s printer technology, or is this my misunderstanding of tacit code and limited knowledge of operator behaviour, who knows. Maybe in another thousand errors I'll know a little more. I just enjoy the mental challenge sometimes. There's no accounting for taste ;)
- OJFord 7y agoThat's not an acronym, GP's point is that a single word acronym contains even less information than this (apparently called a 'numeronym').