小编Ели*_*кая的帖子

检查字符串中是否存在小写字符

我需要返回True或False

  • True 如果至少一个小写字符
  • False 没有小写字符

我试图用循环和lambda函数做到这一点

(defun check-lower-word (word)
    (loop
        for ch across word 
        ((lambda (c) (if (lower-case-p c) return T) ch)
    )
)
Run Code Online (Sandbox Code Playgroud)

如果从未使用过“如果”,我需要False

string common-lisp lowercase

3
推荐指数
1
解决办法
82
查看次数

从通用方法返回实例列表

我需要在通用方法中返回矩形的坐标列表。坐标是类“购物车”实例。

我尝试用make-instance将其退回

(defclass line ()
  ((start :initarg :start :accessor line-start)
   (end   :initarg :end   :accessor line-end)))

(defmethod print-object ((lin line) stream)
  (format stream "[LINE ~s ~s]"
          (line-start lin) (line-end lin)))

(defclass cart ()
  ((x :initarg :x :reader cart-x)
   (y :initarg :y :reader cart-y)))

(defmethod print-object ((c cart) stream)
  (format stream "[CART x ~d y ~d]"
          (cart-x c) (cart-y c)))

(setq lin (make-instance 'line
             :start (make-instance 'cart :x 4 :y 3)
             :end (make-instance 'cart :x 7 :y 5)))

(defgeneric containing-rect (shape))

(defmethod …
Run Code Online (Sandbox Code Playgroud)

evaluation common-lisp quote

2
推荐指数
1
解决办法
51
查看次数

标签 统计

common-lisp ×2

evaluation ×1

lowercase ×1

quote ×1

string ×1