Reputation: 821
How do I get around this problem, I've been at it for a while. It keeps giving me this error: check-expect: expects 2 arguments, but found only 1
Its not counting the list as one argument by itself, I think that is the error, but how would I go about fixing this? I've tried doing (count-in cell (list cells)) but it then gives me an error saying define: expected a variable, but found a part
Definitions
(define-struct Cell (x y)
(define (count-in cell cells)
(cond [(member? cell cells) 1]
[else 0]))
Check-expect, here is where the error comes in
(check-expect (count-in (make-Cell 100 123)
(list
(make-Cell 104 123) (make-Cell 45 67))
(cond [(member? (make-Cell 100 123)
(list
(make-Cell 104 123) (make-Cell 45 67)))1]
[else 0])1)
Upvotes: 0
Views: 4954
Reputation: 18917
This passes your test
(define-struct Cell (x y))
(define (count-in cell cells)
(cond
[(member? cell cells) 1]
[else 0]))
(check-expect
(count-in (make-Cell 100 123)
(list (make-Cell 104 123)
(make-Cell 45 67)))
(cond
[(member? (make-Cell 100 123) (list (make-Cell 104 123) (make-Cell 45 67))) 1]
[else 0]))
You should really learn how to indent Scheme code, and use the DrRacket's indentation feature and parenthesis coloring.
Upvotes: 2