Guile scheme cond ERROR: Wrong type to apply

Guile scheme cond ERROR: Wrong type to apply

我不清楚为什么这个条件会给出 Wrong type to apply 错误。

scheme@(guile-user) [12]>(cond ((等于?"i" "i") => (显示"yay")))

错误:在程序 #:

错误:应用类型错误:#

scheme@(guile-user) [12]>(cond ((string= "i" "i") => (display "yay")))

错误:在程序 #:

错误:应用类型错误:#

cond的常用语法如下:

(cond ((equal? "i" "i")
       (display "yay")))
; prints yay

当我们想将条件的结果作为参数传递给被执行的函数时,我们使用=>,例如:

(cond ((equal? "i" "i") 
       => display))
; prints #t

在上面的代码中,条件的计算结果为 #t,并且 #t 作为参数传递给 display,打印它。