All pastes #20227 Raw Edit

Someone

public text v1 · immutable
#20227 ·published 2005-08-17 02:58 UTC
rendered paste body
(defun bad-range (number-list) 
    (remove-if-not
        #'(lambda (number) 
            (and 
                (< number 5) 
                (> number 1)))
        number-list))

(defun count-the (word-list) 
    (length 
        (remove-if-not
            #'(lambda (word)
                (equal word 'the))
            word-list)))

(setf database 
    '((b1 shape brick) 
        (b1 color green) 
        (b1 size small) 
        (b1 supported-by b2) 
        (b1 supported-by b3) 
        (b2 shape brick) 
        (b2 color red) 
        (b2 size small) 
        (b2 supports b1) 
        (b2 left-of b3) 
        (b3 shape brick) 
        (b3 color red) 
        (b3 size small) 
        (b3 supports b1) 
        (b3 right-of b2) 
        (b4 shape pyramid) 
        (b4 color blue) 
        (b4 size large) 
        (b4 supported-by b5) 
        (b5 shape cube) 
        (b5 color green) 
        (b5 size large) 
        (b5 supports b4) 
        (b6 shape brick) 
        (b6 color purple) 
        (b6 size large)))

(defun match-element (x y) 
    (or 
        (equal y '?)
        (equal x y)))

(defun match-triple (x y)
    (every #'match-element x y))

(defun fetch (x)
    (remove-if-not 
        #'(lambda (y) (match-triple y x))
        database))

(defun color-ask (x)
    (list x 'color '?))

(defun supporters (x)
    (mapcar
        #'first
        (fetch (list '? 'supports x))))