4 ms·
As an array language fan I also feel like a lot of the reasons people give for why array languages are powerful are outdated, and sometimes (not all the time) t
by rak1507 3y ago
As an array language fan I also feel like a lot of the reasons people give for why array languages are powerful are outdated, and sometimes (not all the time) that's because someone tried both APL and C in the 1970s and their opinions haven't changed since.
However I still find them useful (and fun!) because of the terseness, not in spite of it. Terseness means array languages are very mathematical in nature + can be really ergonomic to write, especially with the repl. If someone said "learn an array language, they're easy to write on paper" everyone would think they were insane... but there is something to it, in certain cases. The idea of "fearless refactoring" is popular in the FP world, but it can also be true in the array language world too.
- bear8642 3y ago> "learn an array language, they're easy to write on paper" everyone would think they were insane... but there is something to it, in certain cases. Indeed, and sometimes not needing a computer to quickly splash out an idea you're thinking/talking about is extremely useful! Over Christmas, I showed my brother {+⌿⍤2(∘.≤)⍤1⍨⍵} as a small expression to explore attribute to pick playing Top-Trumps admist a discussion. Not something you'd be able to do in many other languages!
- Affric 3y agoCould you explain the expression to us?
- bear8642 3y agoSure - idea is you've got a 6×30 matrix of the 6 card attributes for each of the 30 cards, and want to know for each attribute how many other cards they'd beat. {+⌿⍤2(∘.≤)⍤1⍨⍵} { ⍵} ⍝ single argument (monadic) function with argument ⍵ { ⍨⍵} ⍝ "selfie" - ⍵ f ⍵ where f is (∘.≤)⍤1 { ⍤1⍨⍵} ⍝ on each row (1 dimensional element) { (∘. )⍤1⍨⍵} ⍝ cartesian (outer) product of each row with itself { (∘.≤)⍤1⍨⍵} ⍝ ≤ comparison of those elements - produces 6 30×30 boolean matrices { ⍤2(∘.≤)⍤1⍨⍵} ⍝ on each of those matricies (2 dimensional element) {+⌿⍤2(∘.≤)⍤1⍨⍵} ⍝ sum the columns leading to: {+⌿⍤2(∘.≤)⍤1⍨⍵} ⍝ compare each row (⍤1) to itself (⍨) and count (+⌿) how many cards that beats That make sense?
- Affric 3y agoThat's great and you have sent me down the rabbit hole. So, usage would be something like: CardPower ← {+⌿⍤2(∘.≤)⍤1⍨⍵} CardPower cardMatrix
- bear8642 3y agoYep, or even apply inline as {+⌿⍤2(∘.≤)⍤1⍨⍵}cardMatrix
- Affric 3y agoThinking about your comment further (and having read TFA and some of the comments) inline usage does seem to make more sense as it's only a few more characters. In that way it's transparent. Decreasing indirection (assuming that the operators always function simply and plainly. Thanks for that follow up comment.