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

[Rees: ALIKE? bug and question]

*** Forwarded Message Follows ****
Date: Wednesday, 14 July 1982  15:35-EDT
From: Jonathan Rees <Rees at YALE-CS>
To: Meehan at YALE-RES
Cc: T-Bugs
Subject: ALIKE? bug and question

    Date: 14-Jul-82 9:07AM-EDT (Wed)
    From: James R. Meehan <Meehan at YALE-RES>
    Re:   ALIKE? bug and question

    Cullingford and I tried (ALIKE? = '(1 2 3) '(1 2 3))
    and T blew up, saying that something wasn't a fixnum.

ALIKE? is fixed in the source now.  The predicate argument will only be
applied to the leaves, thus it doesn't need to be a "universal"
(i.e. it doesn't need to defined in the case where either arg is a pair).

    Am I correct in assuming that the difference between ALIKE?
    and a two-arg-list EVERY is that ALIKE? looks at all the leaves
    whereas EVERY look only at the CARs? I.e.,

            (ALIKE? = '(1 2 (3 4) 5) '(1 2 (3 4) 5)) => T   but

            (EVERY = '(1 2 (3 4) 5) '(1 2 (3 4) 5)) => ERROR (can't use
                    = on non-numbers)

Yes ALIKE? and EVERY? are similar but I think ALIKE? assumes that the
"predicate" is an equality predicate, because it "optimizes" the case
where its two args are EQ? (it is assumed that (PRED x y) => (EQ? x y)
no matter what PRED is, as long as PRED is an "equality predicate").
E.g. (EVERY? < '(1 2) '(1 2)) returns false while
(ALIKE? < '(1 2) '(1 2)) returns true (!) (only because = fixnums happen
to be EQ?).

The list-manipulation routines and the s-expression manipulation
routines are not parallel sets, but they probably should be, to the
extent possible.  E.g. there should be things equivalent to ANY and
EVERY for s-expressions.  As I said before, this part of the system is
quite incomplete and poorly-thought-out at the moment.
*** End of Forwarded Message ****

OK. It looks like (ANY pred . lists) and (EVERY pred . lists)
should default to elements of lists (i.e., top-level CARs), and there
should be (ANY-LEAF pred . lists) and (EVERY-LEAF pred . lists) that
work on atomic CARs (i.e., they keep taking CARs until they reach an atom,
then they call the predicate).

Problems: 1. What if the lists aren't isomorphic, so that one has an atom
             where another has a list? Options: define that as an error
             (probably too draconian), or define that as having a NIL result.

          2. Do we also need a version of ANY and EVERY that allow
             non-isomorphic parameters? Maybe not -- let the user write
             his own.