ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Check also http://www.picolisp.com for more information
geo80 has joined #picolisp
<geo80> morning everyone! was out for a while due to work.. btw yesterday I started with advent of code using pil and currently im still at day 2 hehe
<geo80> Btw can anyone please help me understand why my code says cons pair is expected?
<geo80> (setq Data (1 9 10 3 2 3 11 0 99 30 40 50))
<geo80> (let (x 1
<geo80> N (size Data))
<geo80> (loop
<geo80> (let e (get Data x)
<geo80> (cond
<geo80> ((== e 1)(put Data (get Data (+ x 3)) (+ (get Data (+ x 1)) (get Data (+ x 2)) ) ) )
<geo80> ((== e 2)(put Data (get Data (+ x 3)) (* (get Data (+ x 1)) (get Data (+ x 2)) ) ) )
<geo80> ((== e 99)(set x (+ N 1))) ) )
<geo80> (inc 'x 4)
<geo80> (T (> x N) Data) ) )
<Regenaxer> Hi geo80! Welcome back!
<Regenaxer> How is the exact error? There is a context usually
<Regenaxer> Also, please use upper case local variables
<Regenaxer> 'e' is a function for example
<Regenaxer> The code is hard to read in IRC, especially on my phone screen, I cannot check the indentation. Can you pastebin it?
<Regenaxer> But even so I can see that (inc 'x 4) and (T (> x N) Data) are on the same level
<Regenaxer> So the 'cond' is misformed
<geo80> Hi Regenaxer! sorry was occupied. Oh! ok all noted, unfortunatelly i cannot open pastebin.com here at the office, might be blocked.. anyway I tried to move the (inc 'X 4) but still it shows the same message
<geo80> its says
<geo80> !? (put Data (get Data (+ X 3)) (* (get Data (+ X 1)) (get Data (+ X 2))))
<geo80> NIL -- Cons pair expected
<geo80> ?
<Regenaxer> So 'Data' seems not to be a list
<Regenaxer> If 'get' has a number (+ X 3), it expects a lisw
<Regenaxer> hmm, you said (setq Data (1 9 10 ...
<Regenaxer> I think 'Data' is modified meanwhile
<geo80> ? Data
<geo80> -> (1 9 55 3 2 3 11 0 99 30 40 50)
<geo80> ?
<Regenaxer> hmm, ok
<Regenaxer> Did you fix the 'cond'?
<geo80> and yes, the code will modify the list
<geo80> ah wait
<Regenaxer> btw, seems it could be 'case' instead of 'cond' anyway
<Regenaxer> Also, (T (> x N) Data) seems wrong
<Regenaxer> (> x N) has no effect
<Regenaxer> hmm, it is all strange ;)
<Regenaxer> (get Data X)
<Regenaxer> 'X' is a number
<Regenaxer> ah, ok, forget that
<Regenaxer> What exactly do you want to do?
<Regenaxer> I now see that the code is not so much wrong
<Regenaxer> I thought (T ...) refers to 'cond'
<Regenaxer> but it is to 'loop'
<Regenaxer> I really cannot decipher the code here ;)
<geo80> hehe sorry, im still finding way to pastebin brb
<Regenaxer> I use ix.io - never pastebin
<Regenaxer> Vip even has an ix.io command built-in
<Regenaxer> Can paste the current edit buffer directly
<Regenaxer> It is easy, just do,
<Regenaxer> $ cat file | curl -F 'f:1=<-' ix.io
<Regenaxer> This returns an URL
<geo80> oh! cool! ok will use that in the future
<geo80> btw can you try this
<Regenaxer> ok
<Regenaxer> ? Data
<Regenaxer> -> (1 9 64 3 2 3 11 0 99 30 40 50)
<Regenaxer> ? X
<Regenaxer> -> 5
<Regenaxer> ? (get Data (+ X 3))
<Regenaxer> -> 0
<Regenaxer> ?
<Regenaxer> 0 means the value of a symbol
<Regenaxer> What do you want to do?
<geo80> I want to add the value and store it on the Data list
<Regenaxer> confusing
<Regenaxer> I think you should map over the list
<Regenaxer> Indexing into a List with numeric indexes is not the normal Lisp wyy
<Regenaxer> way
<Regenaxer> eg instead of (inc 'X 4) you do (setq Data (cdddr Data))
<Regenaxer> and use 'set' instead of 'put'
<Regenaxer> (set (cddr Data) (+ (car Data) (cadr Data))) or something like that
<Regenaxer> Not sure :)
<Regenaxer> What algorithm is that?
<geo80> Sorry Regenaxer i have to go but will come back and read your recommendation, hehe the goal for this code is to solve this problem:
<geo80> ok brb, thanks for your advices!
<Regenaxer> ok, see you :)
geo80 has left #picolisp [#picolisp]
orivej has quit [Ping timeout: 240 seconds]
<DKordic> Could [[https://sites.google.com/site/e3editor/][e3]] be used as *Led: [de *Led `[... [call 'e3em Exp.txt]]]?
<DKordic> Also in ""$ apt show e3"".
stultulo has joined #picolisp
f8l has quit [Ping timeout: 252 seconds]
stultulo is now known as f8l
freemint has joined #picolisp
orivej has joined #picolisp
freemint has quit [Remote host closed the connection]
freemint has joined #picolisp
freeemint has joined #picolisp
freemint has quit [Ping timeout: 265 seconds]