Re: how to speed up some lisp code?

From: Joe Marshall (jrm_at_ccs.neu.edu)
Date: 02/20/04

  • Next message: Joe Marshall: "Re: how to speed up some lisp code?"
    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.


  • Next message: Joe Marshall: "Re: how to speed up some lisp code?"

    Relevant Pages

    • Re: Men are too frightened to give women the compliments they need
      ... So Groucho never said it? ... Hell, for that matter, John didn't even bother to show how or when GBS ... I admit that I made the mistake by citing Groucho Marx as saying ... making an honest mistake or in admitting to it. ...
      (soc.men)
    • Re: BUSH WINS!
      ... >>does Bush read? ... >>Tell me, dear John, tell me. ... > fix the mistakes. ... Indeed, fix the mistake. ...
      (sci.electronics.design)
    • Re: "Doctor Who" Matt Smith signs 5 year deal to play The Doctor
      ... whenjohn smith wrote in message ... wrote in message john ... you missed the "s" off it, or is that not a spelling mistake? ... NOT a spelling mistake like the OP ...
      (rec.arts.drwho)
    • Re: Two Attempts to Capture of the Essence of Yoko Ono
      ... saying that these selfish aspects are necessary, ... I think most people would agree that John was ... lacking as a father to Julian, and I can understand Julian being ... because he felt genuine remorse and realized his mistake. ...
      (rec.music.beatles)
    • Re: Multiple date formats in a Table
      ... Andrew (and John): ... In regard to your most recent reply and the ... easy way to do this by coding, ...
      (microsoft.public.access.tablesdbdesign)