Scheme homework help
- by John
Okay so I have started a new language in class. We are learning Scheme and i'm not sure on how to do it. When I say learning a new language, I mean thrown a homework and told to figure it out. A couple of them have got me stumped.
My first problem is:
Write a Scheme function that returns true (the Boolean constant #t) ifthe parameter is a list containing n a's followed by n b's. and false otherwise.
Here's what I have right now:
(define aequalb (lamda (list)
(let ((head (car list)) (tail(cdr list)))
(if(= 'a head)
((let ((count (count + 1)))
(let (( newTail (aequalb tail))))
#f
(if(= 'b head)
((let ((count (count - 1)))
(let (( newTail (aequalb tail))))
#f
(if(null? tail)
(if(= count 0)
#t
#f)))))))))))
I know this is completely wrong, but I've been trying so please take it easy on me. Any help would be much appreciated.