I am not sure if I should start a new thread for this question - but since it's building off of reading json, I decided to continue this thread :)
(de getJson (Spl File Url Oln) (unless (info File) (on Oln)) (when Oln (out File (wget Url))) (pipe (in File (while (prin (run (list (cons 'echo Spl)))) (when (till (list "," "}")) (ifn (sub? "." @) (prin (pack (trim (chop @))) ".0") (prin @))))) (readJson))) The question I have is about the way I've used the "Spl" parameter to accept a list of special words to look for in the call to echo. Is this the right approach? On Wed, May 8, 2019 at 7:25 AM C K Kashyap <ckkash...@gmail.com> wrote: > Perfect!!!! - It is pure bliss to see such concise code. > Regards, > Kashyap > > On Wed, May 8, 2019 at 6:59 AM Alexander Burger <a...@software-lab.de> > wrote: > >> On Wed, May 08, 2019 at 09:17:54AM +0200, Alexander Burger wrote: >> > Yes, "123.0.0" is not a legal number. >> > > I am sure there must a better way to do the lengthy "0"..."9" that >> I've >> > > done :) >> >> The best is to avoid at all looping over the characters, because >> built-ins are a >> lot faster than individual function calls in a loop. >> >> What I would do here is >> >> (pipe >> (in '("curl" "-s" " >> https://api.iextrading.com/1.0/stock/aapl/chart/3m") >> (while >> (prin >> (echo "close" "volume" "unadjustedVolume") ) >> (when (prin (till "," "}")) >> (or (sub? "." @) (prin ".")) ) ) ) >> (readJson) ) >> >> The trick is to read the digits with 'till', print them, and *then* check >> if a >> dot is needed. >> >> ☺/ A!ex >> >> -- >> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >> >