Hey Alex,
Since json.l is available in standard library, I'd prefer to use it :)
Regards,
Kashyap
On Thu, May 9, 2019 at 1:08 AM Alexander Williams
wrote:
> If you're just trying to work with the decimal numbers in PicoLisp, then
> why not just use fixed-point?
>
> You can modify my json.l and s
On Fri, May 10, 2019 at 07:19:06AM -0700, C K Kashyap wrote:
> Interestingly sub? also seems to work like member?
Ah, right. I forgot. 'sub?' is rather tolerant, it accepts also non-symbolic
values and converts them silently to transients ;)
> member? is clearly the appropriate one.
Yes, and has
Thanks Alex,
"apply" is what I was looking for :)
Interestingly sub? also seems to work like member? for list of chars - but
member? is clearly the appropriate one. I think trim is required because
this is valid {"K1": 10 , "K2": 20}
Regarding the download logic - the idea is to cache the outp
On Fri, May 10, 2019 at 07:38:22AM +0200, Alexander Burger wrote:
>(de getJson (Spl File Url Oln)
> (when (or Oln (not (info File)))
> (wget Url) )
> (pipe
> (in File
I think this whole construct is not wise. What if the file fetched with 'wget'
has a different na
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 "," "}"))
>
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
If you're just trying to work with the decimal numbers in PicoLisp, then
why not just use fixed-point?
You can modify my json.l and specify a 20 digit decimal, and then parse
your file. The result will be strings instead of numbers, but it works fine. Here's a
patch:
diff --git a/json.l b/j
Perfect - It is pure bliss to see such concise code.
Regards,
Kashyap
On Wed, May 8, 2019 at 6:59 AM Alexander Burger 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
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 individ
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
>
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.
(setq J
(pipe
(in '("sh" "-c" "curl -s
https://api.iextrading.com/1.0/stock/aapl/chart/3m";)
(while
(case (echo "close" "volume" "unadjus
You would also include "[" in the 'echo' arguments, then check it with
(use S
(while
(prin
(setq S
(echo "[" "volume" "unadjustedVolume") ) )
(if (= "[" S)
(... step through the elements ...)
(echo ",")
(pri
Oh yes ... I can see how that would work!!! ... thanks Alex.
echo seems like a nice function - I don't think I've seen it anywhere
before :) (I mean, I've seen echo that's equivalent of printf ... but not
this)
Regards,
Kashyap
On Tue, May 7, 2019 at 8:49 AM Alexander Burger wrote:
> On Tue, May
On Tue, May 07, 2019 at 08:13:32AM -0700, C K Kashyap wrote:
> Actually my point about array was to read the numbers in the array as fixed
> points decimals :) - 1, 2.0,3 -> with correct scaling.
Ah, ok, this must be handled separately.
You would also include "[" in the 'echo' arguments, then che
(and (echo "," "}") (prin ".0" @) is so cool!
Actually my point about array was to read the numbers in the array as fixed
points decimals :) - 1, 2.0,3 -> with correct scaling.
Regards,
Kashyap
On Tue, May 7, 2019 at 8:05 AM Alexander Burger wrote:
> On Tue, May 07, 2019 at 06:30:15AM -070
On Tue, May 07, 2019 at 06:30:15AM -0700, C K Kashyap wrote:
> 1. use (echo "\"volume\"") - this way any "volume" inside a string will not
> be confused
Yes, or even better include the colon "\"volume\":".
> 2. use (echo "," "}") so that it works with values that are the last entry
> in the dict
Yeah ... and each line is lot fewer than 80 characters :)
just to confirm that I got it - I believe that a couple of changes are
needed to make it work better -
1. use (echo "\"volume\"") - this way any "volume" inside a string will not
be confused
2. use (echo "," "}") so that it works with values
Some also call it "REST" and have written mighty libraries in other
languages.
In PicoLisp it's a 5 - liner! ;-)
Alexander Burger schrieb am Di., 7. Mai 2019, 07:04:
> On Mon, May 06, 2019 at 02:06:56PM -0700, C K Kashyap wrote:
> > My mind is blown - yet again. I love it just looking at it. I'
Thanks Alex,
After looking at the docs for echo I can follow what's going on. it's
pretty nifty!
Since all the numbers I need are values of dictionary keys, this technique
would work perfectly!
Regards,
Kashyap
On Mon, May 6, 2019 at 2:06 PM C K Kashyap wrote:
> My mind is blown - yet again. I l
On Mon, May 06, 2019 at 02:06:56PM -0700, C K Kashyap wrote:
> My mind is blown - yet again. I love it just looking at it. I'll have to
> look a little more to see what's going on.
>
> How do I capture the output though - I mean this does not capture the
> output in J
I used 'pretty' in the examp
My mind is blown - yet again. I love it just looking at it. I'll have to
look a little more to see what's going on.
How do I capture the output though - I mean this does not capture the
output in J
(setq J (pipe
(in '("curl" "-s" "https://api.iextrading.com/1.0/stock/aapl/chart/3m
")
On Mon, May 06, 2019 at 10:21:34PM +0200, Alexander Burger wrote:
>(pipe
> (in '("curl" "-s" "https://api.iextrading.com/1.0/stock/aapl/chart/3m";)
> (while
> (prin
>(echo "volume" "unadjustedVolume") )
> (echo ",")
> (prin ".0,
On Mon, May 06, 2019 at 12:20:24PM -0700, C K Kashyap wrote:
> Thanks Alex,
> I am not so concerned by number being the day of the week since the
> assumption is that there is an implicit understanding of all the "types" in
> the consuming code - I mean, it will be understood that all the numbers
>
Thanks Alex,
I am not so concerned by number being the day of the week since the
assumption is that there is an implicit understanding of all the "types" in
the consuming code - I mean, it will be understood that all the numbers
need to be either used in mathematical expression or divided by the sc
On Mon, May 06, 2019 at 07:22:05AM -0700, C K Kashyap wrote:
> I'm afraid, the generating side is outside my control :( - I am looking at
> this - https://api.iextrading.com/1.0/stock/aapl/chart/3m
There is a way, I do this usually by reading from a pipe and modify the data
along the way as necess
I'm afraid, the generating side is outside my control :( - I am looking at
this - https://api.iextrading.com/1.0/stock/aapl/chart/3m
In this case, scaling everything does not seem so bad - infact, the
solution i was trying was to simply add a ".0" to all the numbers that did
not have it.
Also, wou
Hi Kashyap,
> I still have a question - if my
> program gets its input from two json strings -
> {"V": 10} and {"V" : 10.1}, and I need to sum up all the Vs - how can I do
> it?
I think there is no generic solution. It all depends on what the numbers *mean*.
We cannot simply scale up every numb
Thanks for the link to Rick's introduction. I still have a question - if my
program gets its input from two json strings -
{"V": 10} and {"V" : 10.1}, and I need to sum up all the Vs - how can I do
it?
Perhaps, I would have to suppress the . reader macro before calling
parseJson and then do a pass
On Sun, May 05, 2019 at 08:00:18AM -0700, C K Kashyap wrote:
> : (scl 2)
> -> 2
> : (parseJson "{\"a\": 10.1}")
> -> (("a" . 1010))
> : (parseJson "{\"a\": 10}")
> -> (("a" . 10))
>
> Shouldn't 10 be scaled to 1000? Did I miss something here or is there
> something I need to do so that all the num
Interesting ... for some reason, I believed that PicoLisp did not contain a
json parser !!! - perhaps because, a search for json on
https://picolisp.com/wiki/?Documentation takes me to the external
repositories section :)
pipe is awesome :) - I was looking for just that.
It occurred to me that th
On Sat, May 04, 2019 at 11:27:28PM -0700, C K Kashyap wrote:
> Thank you so much Alex ... What would it take to transform this code to
> handle string as input instead of file stream?
There are two ways:
1. To parse strings directly, then a different code is needed. As an example,
see 'parseJs
Thank you so much Alex ... What would it take to transform this code to
handle string as input instead of file stream?
On Sat, May 4, 2019 at 11:17 PM Alexander Burger
wrote:
> On Sun, May 05, 2019 at 07:58:16AM +0200, Alexander Burger wrote:
> > Hi Kashyap,
> >
> > > Gentle reminder :)
> > ...
On Sun, May 05, 2019 at 07:58:16AM +0200, Alexander Burger wrote:
> Hi Kashyap,
>
> > Gentle reminder :)
> ...
> > > (while (not (= (peek) "\""))
>
> Better (until (= (peek) "\"")
Like what I said about 'prog', also 'not' should seldom be necessary. At least
*never* in conditionals.
☺/ A!ex
Hi Kashyap,
> Gentle reminder :)
Yeah, good! :)
I think it looks good, not much to say on a short glance.
*If* anything at all, I would only mention minor stuff like
> > (while (not (= (peek) "\""))
Better (until (= (peek) "\"")
> > (case (peek)
> >("\\" (char) (link (char
Gentle reminder :)
On Fri, May 3, 2019 at 6:24 PM C K Kashyap wrote:
> Hi all,
> I've made an attempt at JSON parsing. I did this since json.l at
> https://github.com/aw/picolisp-json does not handle floating numbers and
> that is something I need. I also took it as an opportunity to implement
>
35 matches
Mail list logo