ketxu 发表于 2019-9-30 19:03:15

You can use list in this case :
(while
(not
    (setq h
      (cdr
      (assoc
          (getint "\nPlease enter the numeric number: ")
          '((1 . 250)(2 . 550)(3 . -370)(4 . -740))
      )
      )
    )
)
(print "Requires an integer between 1 and 4.")
)

zxmmelly 发表于 2019-10-5 16:43:30

评估一下需要cond来测试的几个条件,把出现频率高的写在前面,频率低的写在后面,这样可以节省运行时间

写不完的日记 发表于 2019-10-6 09:20:11

你说的葵花宝典在哪里?

写不完的日记 发表于 2019-10-6 09:22:07

ketxu 发表于 2019-9-30 19:03
You can use list in this case :

Are you foreigner?

写不完的日记 发表于 2019-10-6 10:24:11

写不完的日记 发表于 2019-10-6 09:22
Are you foreigner?

牛逼!我还以为我喜欢去看国外的论坛,还是有外国人看我们论坛!

ketxu 发表于 2019-10-8 15:32:05

写不完的日记 发表于 2019-10-6 09:22
Are you foreigner?

Yeah, i am Vietnamese. Sorry for my bad language :(

LPACMQ 发表于 2019-10-8 17:34:17

(VL-FILENAME-DIRECTORY (cond((FINDFILE "TT.vlx"))("")))
也可以这样用,防止FINDFILE返回NIL导致代码出错,可以COND返回""空字符。这样就不会出错

写不完的日记 发表于 2019-10-13 11:46:05

ketxu 发表于 2019-10-8 15:32
Yeah, i am Vietnamese. Sorry for my bad language

lisp is beyond boundries ! Welcome to the forum!

happy336 发表于 2019-10-14 20:11:07

谢谢分享,支持
页: 1 [2]
查看完整版本: 终于搞清楚cond用法了