Learning lisp by doing, but stuck on something simple...



Hi all,

Sorry to bother you - if you hate n00b stuff don't read further.

I'm writing a simple application that must read/modify/write
s-expressions, the obvious technology is Lisp (although a version was
written in Python).

At the moment I have reading/writing completed, but I'm stuck on
modifying a value from a p-list. My current function looks like:

;;; modify a value
(defun modify-value (field value)
(setf *config*
(mapcar
#'(lambda (x) (if (equal field x)
(setf (getf x field) value) <-- this is the problem
x))
*config*)))

Now I can simply overwrite any value by using (setf x value), but that
means that I overwrite the key from my p-list, not the value pointed to
by the key (ie (setf (:stuff) :test) - not what I'm after)

(getf :stuff *config*) is currently breaking with 'GETF: A proper list
must not end with :STUFF'

Any help would be appreciated.

Thanks,
Kev

envirnoment :lispbox 0.7

.



Relevant Pages

  • Re: unexpected behaviour
    ... So modifying it ... once /apparently/ dynamically modifies it forever. ... the same dynamic pointer sees the modified storage. ... Unfortunately, introductory lisp texts (and the hyperspec, I have ...
    (comp.lang.lisp)
  • Re: CL vs. K/KDB or efficient analysis of financial time series
    ... > You've not read my lisp very closely, ... > 1M data points is peanuts for today memories. ... > Modifying an adjustable displaced array doesn't cost anything spacewise. ...
    (comp.lang.lisp)
  • Re: How do Lisp Compilers handle Code as Data and vice-versa?
    ... == All lisp application include a compiler. ... == powerfull things at run-time, like modifying themselves, ... master Lisp then I don't know what is, ... purpose language that describes something specialised, ...
    (comp.lang.lisp)
  • Re: correct problem.
    ... > modifying your structures, so it copies them for you. ... > Lisp defaults for applicative programming. ... > be computing functions of the contents of your structures, ... In Lisp, the copy function of a struct is defined to create a new ...
    (comp.lang.lisp)
  • Re: vt100 Terminal Control Escape Sequences
    ... Assuming your Lisp uses ASCII or some superset as its character code: ... you should also note that modifying a literal object such as ...
    (comp.lang.lisp)