Hacker News new | ask | show | jobs
by Avshalom 1858 days ago
okay so it's not really smaller because it uses UTF8 also it relies on order of operations to get rid of the parens around ⍵≡'*' but

us←{('_'@(1+⍸2{(⍺≡⊃K)∧⍵≡'*'}/⍵))⍵}

is one(1) character shorter.

2 comments

⍵≡'*' should be ⍵≡,'*' like in the original k

us←⊃,⍥⊆2{(⍺≡⊃K)∧⍵≡,'*':,'_'⋄⍵}/⊢ is shorter anyway

    us←{'_'@{¯1⌽⍵⍷⍨(⊂⊃K),'*'}⍵}
Ah, ⍷, clever, don't even need the outer {...⍵},

  us←'_'@{¯1⌽⍵⍷⍨(⊂⊃K),'*'}
Yes!

You could also do: ⌽'*',⊂⊃K to save another character. I don't know if that's "better" though.

Or alternatively '*',⍨⊂⊃K which I think I prefer over ⌽, but neither seem that 'better' in my mind anyway.
Is this the same language or a different one?
This is APL, k is a descendant of APL.