> Roughly inspired by a writeup of some guy's python
> implementation[2] of a generator, I threw one together this
> afternoon in rc and hoc: [3]
> 
>       :; sparkline 0 2 4 7 12 16 3 11 9 0 4 
>       ▁▂▃▄▇█▂▆▅▁▃:; 
> 
> The internet has noted that in some contexts the baseline gets
> messed up, but they're still a fun toy.
> 
> Also, thanks to lmnop in #plan9 for this:
> 
>       fn moustache { sparkline `{seq 0 1 10} `{seq 9 -1 0} ; echo }

thanks for the toy!

in addition to being naturally fun, it was interesting to play with.
i initially ran your program directly from sources.  since my path
is the default, one could see each character print.  (1985 says hi!)

just for fun, i decided to modify sparkline to do a constant number
of execs by pipelining most of the work.  /n/sources/contrib/quanstro/sparkline.
(yes, this is pointless.)

since run time should be dominated by execs, the fewer the better.
here's the comparison.  n is the number of input numbers.
orig    5n + 0
mod     0 + 12  (or 11 if you don't add the trailing \n.)

and here's the actual run time for moustache (on an atom)
        local                           from sources
orig    0.03u 0.12s 0.37r                       0.03u 0.12s 5.26r
mod     0.02u 0.02s 0.06r                       0.01u 0.03s 0.86r

exercize for bored reader: replace one sed with a hoc function.

- erik

Reply via email to