Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function 为什么cond功能未在方案中打印?_Function_Conditional Statements_Scheme_Racket - Fatal编程技术网

Function 为什么cond功能未在方案中打印?

Function 为什么cond功能未在方案中打印?,function,conditional-statements,scheme,racket,Function,Conditional Statements,Scheme,Racket,我对scheme非常陌生,我很难获得在DrracketIDE中打印的简单cond函数。当我运行这两个函数时: (define (test x) (cond [(zero? x) (error "doesn't get here, either")] [(positive? x) 'here])) (define (compare x y) (cond [(equal? x y) "Is Equal"])) 它打印: > tes

我对scheme非常陌生,我很难获得在DrracketIDE中打印的简单cond函数。当我运行这两个函数时:

(define (test x)
  (cond
   [(zero? x) (error "doesn't get here, either")]
   [(positive? x) 'here]))

(define (compare x y)
  (cond [(equal? x y) "Is Equal"]))
它打印:

> test 12
#<procedure:test>
12
> compare 12 12
#<procedure:compare>
12
12
>测试12
#
12
>比较12
#
12
12
为什么它不输出任何错误,或者“是相等的”?如果我直接运行cond语句并替换变量,效果会很好。

您实际上不是在调用新过程,您必须将过程名称及其参数括在括号中,就像您在解决方案中使用的所有其他过程一样!这是一种方式:

(test 12)
=> 'here

(compare 12 12)
=> "Is Equal"
实际上,您并不是在调用新过程,您必须将过程名称及其参数括在括号中,就像您在解决方案中使用的所有其他过程一样!这是一种方式:

(test 12)
=> 'here

(compare 12 12)
=> "Is Equal"