Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不清楚为什么这个条件会给出错误的类型来应用错误。
scheme@(guile-user) [12]>(cond ((equal? "i" "i") => (display "yay")))
耶
错误:在程序#中:
错误:应用错误的类型:#
scheme@(guile-user) [12]>(cond ((string= "i" "i") => (display "yay")))
通常的语法cond如下:
cond
(cond ((equal? "i" "i") (display "yay"))) ; prints yay
当我们=>想将条件的结果作为参数传递给被执行的函数时,我们会使用,例如:
=>
(cond ((equal? "i" "i") => display)) ; prints #t
在上面的代码中,条件计算为#t,并#t作为参数传递给display,然后打印出来。
#t
display