

albin
Forum Replies Created
-
Thank you for the suggestion . That’s an elegant solution.
I’m struggling to understand it though. Could you please help explain the following?
q) reverse sums 1 2 3 6 3 1 / This makes sense. q) (reverse sums) 1 2 3 1 3 6 / Why did we lose the reverse? q) (reverse sums::) 1 2 3 6 3 1 / Why did this recover the reverse? q) q) sums + / Makes sense. q) reverse |: / Reverse is a combination of the max and assignment operators? q) reverse sums + / Reverse was lost. q) reverse sums:: |+ / Max operator combined with sums?
I suspect the issue is I don’t understand the meaning of | and ::. I had thought | was just the max operator but maybe is also has other meanings? I know :: has at least these meanings:
- Defining a view.
- Assignment in-place.
- Assignment to a global variable.
- The generic null.
- The identity function.
- An elided index used to select everything.
Does :: have yet another meaning here or does one of the above apply?
-
It’s perhaps nicer to always fill the entire input array instead of taking the number of values to generate as an argument.
fibn:{[s] n: count get s; @[s; 0 1; :; 0 1]; f: {[s; i]; @[s; i; :; @[s; i-2] + @[s; i-1]]; i+1}; (f[s]/)[n-2; 2]; s} x: zeros[`long; 1000000] ts fibn[`x] / 319 576
Interestingly, this reduces the number of bytes allocated by 352, but seems to be slightly slower.