I am new to scheme and have been given this problem as homework. I don't know how to keep a running count in scheme, and that's the part I need help with.
Here's the problem again:
Function count should accept two arguments: an atom and a simple list. The function should return the number of times the atom is found in the list.
Here's what I have so far:
(define (count atm lst)
(cond
((null? lst) 0)
((eq? atm (car lst)) (i don't know how to make a count) (count atm (cdr lst)))
(else (count atm (cdr lst)))))
Any help would be very appreciated!
I still don't understand what needs to happen to increment the number of times the atom is found in the list for each iteration of the function.
This is the test case my teacher gave me: (count 'john '(john paul george ringo))
which should return 2.
I've been staring at this problem long enough, please explain how to make the count work.