On Tue, May 07, 2019 at 05:26:57PM -0700, C K Kashyap wrote:
> I ended up making the code less pretty. Looks like the suffix ".0" must
> only be added if the number is not already in floating point format.

Yes, "123.0.0" is not a legal number.


> (setq J
>  (pipe
>    (in '("sh" "-c" "curl -s 
> https://api.iextrading.com/1.0/stock/aapl/chart/3m";)
>      (while
>       (case (echo "close" "volume" "unadjustedVolume")
>         (("close" "volume" "unadjustedVolume")
>           (prin @)
>           (prin (echo "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"))
>           (setq Sfx ".0")
>           (while (member (peek) (list "0" "1" "2" "3" "4" "5" "6" "7" "8" > 
> "9" "."))
>             (if (= "." (peek)) (setq Sfx ""))
>             (prin (char)))
>           (prin Sfx)
>           T)
>        )))
> 
> I am sure there must a better way to do the lengthy "0"..."9" that I've
> done :)

You could check

   (while (or (>= "9" (peek) "0") (= "." (peek)))

but that is not better.

I would go with

   (while (sub? (peek) ".0123456739")

Note that 'Sfx' is not bound locally. Either

   (use Sfx
      (while
         (case ...
            ...
            (setq Sfx ...

or

   (let Sfx ".0"
      ...

Side note: (setq Sfx "") could be (off Sfx)

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to