Re: How do I shorten or split this function
- From: TomSW <tom.weissmann@xxxxxxxxx>
- Date: Mon, 2 Feb 2009 09:04:31 -0800 (PST)
On Feb 2, 5:10 pm, "An[z]elmus" <some...@xxxxxxxxxxxxx> wrote:
(defun field-matches-p (string field-type)
"Predicate to test if STRING could be a field of type FIELD-TYPE"
(let ((regex (cdr (assoc field-name *bib-regexes*)))) ;<<<<<<
(if regex
(scan regex string)
t)))
Here you are using SCAN from the CL-PPCRE package.
Instead of field-name you mean field-type.
oops
I don't understand (yet) why the function returns true (if (not
regex))
If there's no regular expression associated with the field type, then
it doesn't test the string to see if it's of the suitable form for the
field, it just assumes that it is.
Back again to FIELD-MATCHES-P (and EVERY): in this case EVERY returns
true if and only if each element of record FIELD-MATCHES-P each
element of pattern.
Exactly. So you only test patterns of the same length as the input,
and you find the first one where every string in the input matches the
corresponding field of the pattern. The patterns are ordered so that
the more specific fields (author, title3) take precedence over the
less specific ones.
If you want to change the type of the records created, you just need
to change MAKE-BIB-ENTRY, similarly, you can set up various ways to
handle unmatched inputs (have a look at the section on error handling
in "Practical Common Lisp".
btw I had a look at the catalogue files & can only commiserate :)
.
- Follow-Ups:
- Re: How do I shorten or split this function
- From: An[z]elmus
- Re: How do I shorten or split this function
- References:
- Re: How do I shorten or split this function
- From: TomSW
- Re: How do I shorten or split this function
- From: An[z]elmus
- Re: How do I shorten or split this function
- From: TomSW
- Re: How do I shorten or split this function
- From: An[z]elmus
- Re: How do I shorten or split this function
- Prev by Date: Re: JVM vs CLR
- Next by Date: Re: how to tokenize a string in Lisp
- Previous by thread: Re: How do I shorten or split this function
- Next by thread: Re: How do I shorten or split this function
- Index(es):
Relevant Pages
|
Loading