<div>Hi All,</div>
<div> </div>
<div>I wrote a piece of code to count the occurrance of a letter in a list. But it gave me an error saying "#<procedure:...uments..."</div>
<div> </div>
<div>The code is below:</div>
<div> </div>
<div>(define (count-matches s l)<br> (cond<br> [(empty? l) 0] <br> [(equal? s (first l)) (lambda (i)(+ i 1))]<br> [else (count-matches s (rest l))]))</div>
<div> </div>
<div>Where the s is a letter and l is a list. To use it as an example, I typed</div>
<div> </div>
<div>(count-matches 'f '(f )) </div>
<div> </div>
<div>and got the error. The right result should be 1.</div>
<div> </div>
<div>Do I need to initialize i? If so, how can I do it?</div>
<div> </div>
<div>Note that the keywords that I can use are pretty much used in the code. If the solution needs keywords outside this post, it may not be useful to me.</div>
<div> </div>
<div>Thank you very much. </div>