It is not clear to me why this cond gives Wrong type to apply error.
scheme@(guile-user) [12]>(cond ((equal? "i" "i") => (display "yay")))
yay
ERROR: In procedure #:
ERROR: Wrong type to apply: #
scheme@(guile-user) [12]>(cond ((string= "i" "i") => (display "yay")))
yay
ERROR: In procedure #:
ERROR: Wrong type to apply: #
The usual syntax for cond
is as follows:
(cond ((equal? "i" "i")
(display "yay")))
; prints yay
We use =>
when we want to pass the result of the condition as a parameter to a function that gets executed, for instance:
(cond ((equal? "i" "i")
=> display))
; prints #t
In the above code the condition evaluates to #t
, and #t
is passed as a parameter to display
, which prints it.