Scheme #!在方案中打印值时出现非特定错误

Scheme #!在方案中打印值时出现非特定错误,scheme,lisp,racket,mit-scheme,Scheme,Lisp,Racket,Mit Scheme,我一直以以下方式获得我的输出: Exam Avg: 50.#!unspecific 每当我试图在scheme中打印我的程序时。我使用了两个函数print和secprint,我认为可能会发生错误: (define (print cnt List) (if (= cnt 1) (printEmp (car List)) (secprint cnt List ))) (define (secprint cnt List) (printEmp (car List))

我一直以以下方式获得我的输出:

Exam Avg: 50.#!unspecific
每当我试图在scheme中打印我的程序时。我使用了两个函数print和secprint,我认为可能会发生错误:

(define (print cnt List)
    (if (= cnt 1) (printEmp (car List))
        (secprint cnt List )))

(define (secprint cnt List)
    (printEmp (car List))
    (newline)
    (print (- cnt 1) (cdr List)))

Could someone please help with this? I am new to scheme and can't seem to figure out where I am going wrong.

Edit: Other code that might be useful.


(define (avg List)
  (cond ((string=? "std" (car (split List)))
  (display (/ (examTotals List) 3.0)))
  (else 0))
)




display
过程写入输出,然后返回一个未指定的值。您使用
display
是为了它打印数据的副作用,而不是为了它的返回值

(define (avg List)
  (cond ((string=? "std" (car (split List)))
         (display (/ (examTotals List) 3.0)))
        (else 0)))
avg
过程返回最后计算的表达式的值;当
显示
分支求值时,会将未指定的值返回给调用者。但是调用者,
printEmp
不需要
avg
来显示其结果,它只需要一个返回值,然后由
printEmp
过程打印

通过从
avg
程序中取出
display
进行修复:

(define (avg List)
  (cond ((string=? "std" (car (split List)))
         (/ (examTotals List) 3.0))
        (else 0)))

什么是
avg
avg2
?几乎可以肯定
#!unspecific
是打印未指定返回值的方式。我不知道为什么它不在一行上,因为我希望它是
newline
@molbdnilo avg和avg2的返回值,我使用这些函数来获得考试分数,我可以编辑原始的函数以包含它们