开发者

scheme continue

i am new at scheme and at this site. i write a scode like

(define function 
  (lambda (liste)
   (do ((k 0 (+ k 1))) ((> k 3))
     (do ((l 0 (+ l 1))) ((> l 3))
       (do ((m 0 (+ m 1))) ((> m 3))
         (do ((n 0 (+ n 1))) ((> n 3))             
            (if(not(equal? k l))
              (if(not(equal? k m)) 
                 (if(not(equal? k n))
                   (if(not(equal? l m))
                     (if(not(equal? l n))
                       (if(not(equal? m n))  ((display k)(d开发者_运维知识库isplay l)(display m)(display n)) 

                                                         )))))))))))) 

  (trace function)
  (function '(1 2 3 4 ))     

It stoped error=

0123. . procedure application: expected procedure, given: #<void>; arguments were: #<void> #<void> #<void>

When the last if run, it stops, how can i continue it?


You need to replace

((display k)(display l)(display m)(display n))

by

(begin (display k)(display l)(display m)(display n))

Lisp usually evaluates a lisp by evaluating each list entry and calling the first entry with the results of the later entries, but (display k) doesn't evaluate to a function!

begin tells Scheme to simply evaluate each of the following terms.

It's like coding

(System.out.println(k))(System.out.println(l),System.out.println(m),System.out.println(n))

in Java.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜