Hi Thorsten,

> ((KEY VAL VAL) (KEY VAL VAL) KEY VAL)
> 
> ((VAL . KEY) KEY VAL KEY))
> 
> #+end_src picolisp
> 
> it does not matter that the cells in the second one are not dotted
> pairs. 

Right. In a certain way, the *are* also dotted pairs, though. You can of
course always write

   ((KEY VAL VAL) (KEY VAL VAL) ...

as

   ((KEY . (VAL VAL)) (KEY . (VAL VAL)) ...



> And property list extracted with 'lget' from a symbol would be 'true'

You mean 'getl'

> alists too if the programmer would simply redefine the VALS as KEYs and
> vice verse in his head before applying 'assoc' or 'asoq'.  

Yes.


> Or if he actually swaps keys and vals, since (Emacs Lisp) functions like
> 'rassoc' and 'rasoq' do not exist in PicoLIsp. 

True. If necessary, you could use 'find' for that

   : (find '((X) (= 'b (cdr X)))
      '((1 . a) (2 . b) (3 . c)) )
   -> (2 . b)


> One last question:
> 
> #+begin_src picolisp
> ((VAL . KEY) KEY (VAL . KEY))
> 
> ((VAL KEY) KEY (VAL KEY))
> 
> ((VAL VAL KEY) (VAL VAL KEY) (VAL . KEY))
> #+end_src picolisp
> 
> would each of the above be a valid property list if assigned with 'lput'
> to a symbol?

Yes (you mean 'getl'), but those cases where the CDRs of the list
elements are not symbolic will result in symbol properties which would
be hard to find.

This is because the 'get' family of symbol property access functions use
'==' (pointer equality) for searching.

Example:

   : (setq PList '(("val1" a b) ("val2" . c)))  # ((VAL VAL KEY) (VAL . KEY))
   -> (("val1" a b) ("val2" . c))

   : (putl 'A PList)                            # New property list for 'A'
   -> (("val1" a b) ("val2" . c))

   : (show 'A)                                  # 'A' has two properties
   A NIL
      c "val2"                                  # one with key 'c'
      (a b) "val1"                              # and one with key '(a b)'
   -> A

   : (get 'A 'c)                                # We can find 'c'
   -> "val2"

   : (get 'A '(a b))                            # But not '(a b)' because they
   -> NIL                                       # are not pointer-equal

   : (get 'A (cdar PList))                      # (cdar PList) is (a b)
   -> "val1"                                    # and pointer-equal

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

Reply via email to