3 ms·
Could you explain the expression to us?
by Affric 3y ago
Could 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.