Scheme: Mysterious void in pattern match.

Posted by Schemer on Stack Overflow See other posts from Stack Overflow or by Schemer
Published on 2011-02-27T07:19:02Z Indexed on 2011/02/27 7:24 UTC
Read the original article Hit count: 211

Filed under:
|
|

Hi.

I am writing a function called annotate that uses match-lambda -- often with recursive calls to annotate. Here is one of the pattern matches:

(`(lambda (,<param1> . ,<params>) ,<stmts>)
 `(CLOSURE ENV (,<param1> . ,<params>) (lambda (ENV) ,(map annotate (map (lambda (x) (append `(,<param1> . ,<params>) (list x))) `(,<stmts>))))))

However, when this pattern is matched this is what returns:

'(CLOSURE
  ENV
  (x)
  (lambda (ENV)
    ((CLOSURE
      ENV
      (x y)
      (lambda (ENV) ((+ x y))))))
  #<void>)

Specifically I can't figure out where "void" is coming from. In fact, if I include the line:

,(displayln (map annotate (map (lambda (x) (append `(,<param1> . ,<params>) (list x))) `(,<stmts>))))

it prints:

((CLOSURE ENV (x y) (lambda (ENV) ((+ x y)))))

notably without "void".

If someone could tell me what the problem is it would be greatly appreciated.

Thanks.

© Stack Overflow or respective owner

Related posts about Scheme

Related posts about pattern-matching