The previous mail quizzed me about, the (set (nth u 5) 1000) part.
 I understand it basically setting a value at a certain place like u[5] = 1000 
in c like languages. nth returns a list starting from count and set evaluates 
then sets the value of variable. But, not sure why this is actually possible to 
do.
: (setq u (range 1 10)
-> (1 2 3 4 5 6 7 8 9 10)
: (set (nth u 5) 1000)
-> 1000
: u
-> (1 2 3 4 1000 6 7 8 9 10)


That also reminded me of a similar question I had about (0)
: (de incM ()
   (do 8
      (printsp 0)
      (inc (cdadr (cdadr incM))) ) )
: (cdadr (cdadr incM))-> (0)

: (incM)
0 1 2 3 4 5 6 7 -> 8
: (incM)
8 9 10 11 12 13 14 15 -> 16

How does the number get modified if it's not a symbol? [(sym? (0))-> returns 
NIL]
I have seen it for symbols and their values but don't understand this one.
  Does it have something to do with the basic cell structure? (0)->(0  . 
NIL)->(car . cadr)
 The cadr of the current cell points to the next cell and we modify the value 
at car of the current cell in list.
That probably also explains the 1st code

#The below code also reinforces it, I think.
Modifing the number inside the function if it is '(0)' works but not when it's 
'0'. Is it due to the (0 . NIL) cell distinction?
: (cdadr (cdadr incM))
-> (0)
: (set @ 60)
-> 60
: (cdadr (cdadr incM))
-> (60)
: (set (car @) 90)
? error variable expected 

# It's worth noting i can modify the counter for do loop without any issue like 
the 1st nth example.
: (set (cdr (cadr incM)) 5)
-> 5
: incM
-> (NIL (do 5 (printsp 60)(Inc (cdadr (cdadr incM)))))

JmageK
-- 
Securely sent with Tutanota

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

Reply via email to