On Thu, May 09, 2019 at 03:39:32PM -0700, C K Kashyap wrote:
> (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?
Building a new list is not the best. You can evaluate it directly with 'apply'.
I would also do some other minor tunings, let me suggest this:
(de getJson (Spl File Url Oln)
(when (or Oln (not (info File)))
(wget Url) )
(pipe
(in File
(while (prin (apply echo Spl))
(unless (member "." (prin (trim (till "," "}"))))
(prin ".") ) ) )
(readJson) ) )
Is the 'trim' needed? In any case I see that my last proposal using 'sub?' was
wrong, but I would avoid the 'pack' and use 'member' instead.
Instead of appending ".0", a single dot should suffice, as "123." will be read
as a fixpoint number.
Again, I have not tested - please forgive any errors ;)
☺/ A!ex
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe