Re: how to speed up some lisp code?
From: Joe Marshall (jrm_at_ccs.neu.edu)
Date: 02/20/04
- Previous message: Edi Weitz: "Re: Advantages of Lisp?"
- In reply to: John H Palmieri: "Re: how to speed up some lisp code?"
- Next in thread: John H Palmieri: "Re: how to speed up some lisp code?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 20 Feb 2004 15:15:20 -0500
John H Palmieri <palmieri@math.washington.edu> writes:
>> (defun lex-less-than (left right)
>> (and (not (eq left right)) ; short circuit EQ lists
>> (consp right) ; right must be at least as long as left
>> (or (not (consp left)) ; either left is shorter
>> (< (car left) (car right)) ; the first element is smaller
>> (and (= (car left) (car right)) ; the first elements are same
>> (lex-less-than (cdr left) (cdr right))))))
>
> I think I made a mistake when coding this; I actually can't think of a
> time when I need to compare monomials of different lengths. So I
> could probably simplify this more. Anyway: I don't think eq is the
> right thing to use: (eq '(1 2 3) '(1 2 3)) is nil, so it probably
> won't save any time.
(eq '(1 2 3) '(1 2 3)) may be nil, but you use this function in many
places, not just for user input.
> Does equal traverse the lists, or is it efficient enough to use as a
> replacement here?
EQUAL will traverse the entire list, you definitely don't want that
here.
- Previous message: Edi Weitz: "Re: Advantages of Lisp?"
- In reply to: John H Palmieri: "Re: how to speed up some lisp code?"
- Next in thread: John H Palmieri: "Re: how to speed up some lisp code?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|