Поскольку переменная type
не используется, я исключил ее из кода и произвел рефакторинг:
;; find
(define (find item pb)
(let* ((first-pb (first pb))
(name (contact-name first-pb))
(phone (contact-phone first-pb)))
(cond
[(empty? pb) #f]
[(equal? (string->symbol item) name) phone]
[(equal? (string->number item) phone) name]
[else (find item (rest pb))])))
;; Controller
(define (check-callback pb)
(let ((res (find (text-contents a-text-field) pb)))
(draw-message a-msg
(cond
[(number? res) (number->string res)]
[(symbol? res) (symbol->string res)]
[else "Not found"]))))
Или вы можете сразу преобразовать свое имя и телефон в строку:
;; find
(define (find item pb)
(let* ((first-pb (first pb))
(name (contact-name first-pb))
(phone (contact-phone first-pb)))
(cond
[(empty? pb) #f]
[(equal? (string->symbol item) name) (number->string phone)]
[(equal? (string->number item) phone) (symbol->string name)]
[else (find item (rest pb))])))
;; Controller
(define (check-callback pb)
(let ((res (find (text-contents a-text-field) pb)))
(draw-message a-msg
(if (res)
res
"Not found"))))