Scheme error “except: misuse of unit import keywor

2019-09-06 20:41发布

问题:

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:

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.