help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with elisp


From: Tom Capey
Subject: Re: Help with elisp
Date: 31 Jul 2003 12:59:18 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

* David Chadd <d.chadd@uea.ac.uk> writes:

> Apologies for a question demonstrating beginner's total Elisp
> incompetence.  I want to make lists out of series of
> attribute-values in an xml file.  (The values are sigla of
> manuscripts.)  These are e.g. in the form:

>   wit="CAO-C Alb2 Hyd" 

> Having found the string of values (CAO-C Alb2 Hyd) with a regexp
> search, I simple-mindedly thought I would be able to do something like

>   (setq wits (split-string (match-string 1)))

> This does indeed make a list --- (listp wits) returns T --- but the
> lists don't behave as I would expect.  For instance, they don't
> respond correctly to (set-difference), (intersection) etc.  And for
> reasons I can guess at, but don't know enough to do anything about,
> the lists are in the form ("CAO-C" "Alb2" "Hyd") rather than (CAO-C
> Alb2 Hyd).


  change the test in the set functions from `eq':

(setq a (list "CAO-C" "Alb2" "Hyd")
      b (list "CAO-C" "Alb2" "Hyd" "foo"))

(intersection a b :test 'string-equal)
=> ("Hyd" "Alb2" "CAO-C")

(set-difference b a :test 'string-equal)
=> ("foo")

(set-difference a b :test 'string-equal)
=> nil


/Tom
-- 
Mais, à part ça, Madame la Marquise,
Tout va très bien, tout va très bien.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]