I'm aware that in newlisp one takes more of a functional approach, but it seems to me
that the execution of 'assoc in the native C code would have some sort of offset recorded, thus
it would be an additional (and valuable) resource to have the offset (index) provided in a system variable.
The specific case that prompts me to ask this question is where I would have an "associative" list whose
members would need to be
1)accessed
2)Any number of possible logical branches executed based on the contents of the member.
3)changed
I've written this:
Code Select
;; With 'all, return indexes for all occurances of 'key in 'lst. Without 'all return the index of the first occurance.
(define (getAssocPos key lst all)
(letn((cmp (fn(x) (= (x 0) key)))
(res (index cmp lst)))
(if (empty? res)
nil
(if all
res
(first res)))))
Thus (I think) getAssocPos will allow me to retrieve, then store an offset/index which will reference a member-list
and then allow me to easily reset it in the outer list via 'setf.
I hope this answers your question.
Thanks for the 'find example. I have use for that.
cheers
tim