Scheme error “except: misuse of unit import keywor

2019-09-06 20:12发布

I'm writing a function that returns elements which appear in one list and not in another. For example,

(except '(a b c) '(a d b e f))

will return '(c). The first argument can be an atom, and both are assumed to be flat. Here's my code:

(define (except lm ln)
  (cond ((null? ln) lm)
        ((not (list? lm))
         (cond ((in? lm ln) '())
               (#t lm)))
        ((null? lm) '())
        ((in? (car lm) ln) (except (cdr lm) ln))
        (#t (cons (car lm) (except (cdr lm) ln)))))

Then an error returns saying "except: misuse of unit import keyword in: (except (cdr lm) ln)".

Why this is happening?

1条回答
做自己的国王
2楼-- · 2019-09-06 20:38

Looks like you're running into some problem with the unit library which has an except keyword defined. But it should still be possible to use it as a name for your function, so I'm guessing that something else is wrong. It'll be possible to say more if you provide the complete code that you're trying to run.

查看更多
登录 后发表回答