Hi again folks! Could somebody walk me through "eval"ing a tree structure? I'm re-reading Aaron Hsu's paper but it still didn't click yet. Here's the rough description: is.gd/mjtree
I'm thinking I need something recursive, like (fn¨⍣≡) v
Either way, but if you didn't tell him so, he'll not realise he can converse with you here. He has been here extensively on occasion, and is quite happy to explain at length.
Anyways to rubber-duck explain my train of thought, it seems to me the fn should have guards and based on a) whether result has been calculated already and b) the t of the node + all children are calculated, it would do some calculation or keep it as is. The power fixpoint operator would then call it until all levels have been walked and calculated
Does that sound reasonable or like a common practice?
Hi, I have a question about ⎕FX - if I have a dfn and a name I want to assign it to, how do I add a function with that name to the current namespace? ⎕FX seems to assume I've already made a function and assigned it to a variable so I can use its name.
Right now I'm on Windows. (But would be interested in RIDE@Linux options too.) But ultimately this is just a question out of curiosity, I can work with )ed if need be.
One lingering question in my head. Will :If etc. control structures hurt performance? Are they eg. less parallelizable? (They seem not as idiomatic, if anything)
It at least seems to me that "APL, the good parts" is tacit definitions and dfns
I'm not sure where you expect your code to run in parallel, but in general conditions are bound to slow down code due to branch prediction errors.
If you want good performance, then use flat (non-nested) homogenous (all-character or all-number) arrays of the smallest possible type, and use array operations instead of loops and conditions.
From a language implementor perspective, does Dyalog go through the arrays to check what minimal type can it pack the arrays with, or is it eg. just enforced by the operations? (× on array previously known to contain integers -> guarantees array of bools)
It tends to squeeze, but it isn't guaranteed. ⎕WA will force a squeeze of everything, and ⎕DR will force a squeeze of the given argument.
@MartinJaniczek Here's an example: {+/0>,⍵} counts the number of negative elements of a flat numeric array.
However, ,⍵ needs to copy the array in memory to ravel it, and only then is it replaced a Boolean array of the same dimensions (but using down to a 64th of the memory).
If instead you use {+/,0>⍵} then the whole array is never copied. Instead, all elements are traversed, and only one bit is written to memory per element. This new Boolean array is obviously not referenced anywhere, so , can act in-place, at basically 0 cost.
My web philosophy: If you think you need a server call back, you can probably just use a JavaScript library. If you think you need a JavaScript library, you can probably just use vanilla JavaScript. If you think you need JavaScript, you can probably just use CSS. If you think you need CSS, you can probably just use HTML's default formatting.
But HTML's default formatting is different across browsers (IIRC). Supported CSS features are also different across browsers, and the same goes to JS features. So I use JS library, which lets me abstract away from individual browsers. Server callback is probably too much.
@Razetime For whom to do? This is already on my list of possibilities for this year, but if someone external to Dyalog is willing to have a go it makes the APL video landscape more diverse - of course if you'd prefer them to come from Adam's mouth that would make sense too
@Adám assume I have a regex I apply using ⎕R, I'd like to perform replacement only if the regex matched at least one capture group - how would I do that? I stumbled upon documentation of the object passed to the dfn on the right, but it doesn't help much
@KamilaSzewczyk I'm not entirely sure I understand. How can your regex (with capture groups) match if no capture group matched?
@Konrad'Unrooted'Klawikowski You were on the path to define IsDivisibleBy. For that, you have to figure out what it means for a number to be divisible by another number.
@KamilaSzewczyk Ah, I often do that. Simply use two regexes instead of | syntax, and let the first replacement pattern be '&' (or the equivalent '\0' which will work better for you).
can we have guards in dops? I wanted to refactor ((lhs'%')⎕R{(≢⍵.Offsets)=1:⍵.Match⋄' (Percent) '})⍵ to ((lhs'%')⎕R{' (Percent) '}{(≢⍵.Offsets)=1:⍵.Match⋄⍺⍺0}) 'abc', but it doesn't seem to like the guard
Also, you don't need the parenthesis here. While not a function, ← in some ways behave like one, so it also sees everything on its right as its value to be assigned. Furthermore, the result of an assignment is always the value on the right.
@KamilaSzewczyk The guard isn't the problem. ⎕R is a dyadic operator, so it binds {' (Percent) '} as its right argument, and the derived replacement function becomes the operand to your operator.
Solution: just move the leftmost ( to the right of ⎕R.