[cl-containers-devel] newbie problem with search-for-item wihtout :key & :test.

Szymon ssbm2 at o2.pl
Tue Oct 28 22:10:46 UTC 2008


;;; Hi,
;; I just asdf-ed cl-containers, and my first example failed ;(
;; Imho according to docs this should work

(require :cl-containers)

(use-package :metabang.cl-containers)

(defclass x ()
   ((letter :accessor x-letter :initarg :letter :type string)
    (name   :accessor x-name   :initarg :name   :type string)))

(defparameter *container-of-x*
   (make-container 'list-container :key #'x-letter :test #'string=))

(insert-list *container-of-x*
              (map 'list
                   (lambda (c) (make-instance 'x :letter (string c) :name (char-name c)))
                   "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"))
;;
;; OK:
;;

(search-for-item *container-of-x* "Ж" :test #'string= :key #'x-letter)

;;
;; FAILs:
;;

(search-for-item *container-of-x* "Ж")

;; The value #<X {BC9CDC9}>
;; is not of type
;;   (OR (VECTOR CHARACTER) (VECTOR NIL) BASE-STRING SYMBOL
;;       CHARACTER).
;;    [Condition of type TYPE-ERROR]
;;
;; Restarts:
;;  0: [ABORT] Return to SLIME's top level.
;;  1: [TERMINATE-THREAD] Terminate this thread (#<THREAD "worker" RUNNING {B59BB21}>)
;;
;; Backtrace:
;;   0: (STRING= "Ж" #<X {BC9CDC9}>)[:EXTERNAL]
;;   1: (FIND "Ж" (#<X {BC9CDC9}> #<X {BC9CDD9}> #<X {BC9CDE9}> #<X {BC9CDF9}> #<X {BC9CE09}> #<X {BC9CE19}> ...))[:EXTERNAL]
;;       Locals:
;;         SB-DEBUG::ARG-0 = 6
;;         SB-DEBUG::ARG-1 = "Ж"
;;         SB-DEBUG::ARG-2 = (#<X {BC9CDC9}> #<X {BC9CDD9}> #<X {BC9CDE9}> #<X {BC9CDF9}> #<X {BC9CE09}> #<X {BC9CE19}> ...)

;; Regards, Szymon.




More information about the cl-containers-devel mailing list