Sigh. The formatting button in Gmail is directly next to the “Send” button.
Apologies, list.
> It seems like most of the overhead comes from fixed-point arithmetic,
> actually. Here’s a translation to Kitten with locals:
def meanStd (float float float → float float):
→ sum2 sum invLen;
sum ×. invLen → μ;
μ (sum2 ×. invLen −. μ square) sqrt
You can write this in postfix:
def meanStd (float float float → float float):
→ sum2 sum invLen;
sum invLen (×.) → μ;
μ sum2 invLen (×.) μ square (−.) sqrt
Then easily eliminate μ:
def meanStd (float float float → float float):
→ sum2 sum invLen;
sum invLen (×.) dup
{ sum2 invLen (×.) } dip
square (−.) sqrt
I see no need to eliminate the named parameters, and if this were using
fixed-point arithmetic, I would make separate arithmetic words to handle
the shifting. It’s worth noting that swapping “sum” and “sum2” could give a
nicer translation, since “sum” is used first; and that multiplying by the
inverse-length is repeated.
Also, not all Kitten is so Unicode-heavy, but in toy code, why not? :)
------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk