also i guess i should've said that ∇∇ is only for operator definitions
you can abstract out the + of that fib definition with fib←{⍵≤1:⍵ ⋄ (∇ ⍵-1) ⍺⍺ ∇ ⍵-2}, now its usage being +fib 10. Equivalently, you can {⍵≤1:⍵ ⋄ (∇ ⍵-1) ⍺⍺ (⍺⍺ ∇∇) ⍵-2}
I do agree that there is a sense in wanting ∇ to always refer the dfn/dop itself without any additions always, but I think the other arguments overpower that
@ElectricCoffee yeah, it makes it become one if there isn't already any ⍺⍺/⍵⍵
@ElectricCoffee Btw, RIDE is "dumb"; it is little more than an HTML renderer connected to the interpreter (which is also the actual IDE), and it knows next to nothing about the language.
but just to get back on topic to see if I got this right `∇` refers to the dfn as it exists with all operands applied (if any) `∇∇` refers to the dfn as a naked operator (a dop?), allowing me to change the operands should I need to
I think it is important to understand that internal operator code is never run before the eventual derived function is applied to one or two arguments.
I guess that's a matter of semantics, coming from Haskell, writing foo (+) for function foo :: (Int -> Int -> Int) -> Int -> Int is partially applying + to foo
Prelude> take 20 ['\1114000'..]
"\1114000\1114001\1114002\1114003\1114004\1114005\1114006\1114007\1114008\1114009\1114010\1114011\1114012\1114013\1114014\1114015\1114016\1114017\1114018\1114019"
Prelude> ['\1114100'..'\1114112']
<interactive>:10:22: error:
numeric escape sequence out of range at character '2'
Prelude> ['\1114100'..'\1114111']
"\1114100\1114101\1114102\1114103\1114104\1114105\1114106\1114107\1114108\1114109\1114110\1114111"
Prelude>
a lot of stuff I worry about when programming is data representation, as in how data is stored, and more importantly accessed. Is there a general best-practice way to do records/structs in APL? Or is it more of a try-to-cram-it-into-arrays-and-hope-for-the-best like it is in Lisp?
like, suppose I want to make a deck of playing cards. Each card has three different components: A suit, a rank, and (often) a value (like Kings being worth 10 points for example)
@ElectricCoffee As an initial model, I'd represent each card as an enclosed vector in the most natural form, using Unicode symbols and a number. Then, when your algorithm is done, convert to all-integer flat representation.
Adám’s approach is better and more idiomatic in every way, but namespaces are the closest concept to a record or named tuple in a traditional language.
that reminds me of how Erlang handles records: it's merely a macro which defines a series of tuple accessors. The tuples themselves aren't really named at all. Metaprogramming is cool when it works
typically I'd want to do this on a card-by-card basis, you're almost never dealing with the entire deck all at once, unless each card has a unique index in the deck
though I'm not sure if representing a hand of cards as a list of indices is more efficient than just a list of strings. I suppose it would be
goes to show how far merely skimming the nuvoc gets me
unrelated: is there a better way of doing this: `+/∨⌿1 3∘.=roll`? my initial idea was to use an inner product, but it doesn't work with vectors of uneven length
counting the number of dice rolls that are either 1s or 3s, where roll is a vector containing the outcomes of n rolled dice