Thanks for the help guys , I did it like this.<br><br>;question in a given list find out how many times a symbol occurs in the list.<br>;contract : fun-with-lists s-list * symbol -> number<br>;purpose : this function takes an s-list and a symbol as input and finds out how many times the symbol occurs in the list.<br>
;examples 'a -> () =0 , ('a) =1 , ('b) = 0 , ('b 'c 'a 'a) = 2 , ('b 'c 'd) =0<br>;template (define fun-with-lists (lambda s-list sym) (cond [(empty? s-list)] [ else (first s-list) fun-with-lists(rest s-list])))<br>
(define fun-with-lists (lambda (s-list sym )<br> (cond<br> [(empty? s-list) 0]<br> [else (+( more-fun-with-lists(first s-list) sym) ( fun-with-lists(rest s-list) sym))]))) <br>
<br>;contract more-fun with lists (symbol * symbol -> number)<br>;purpose : this function returns 1 if the (first s-list) = sym otherwise 0<br>(define more-fun-with-lists (lambda (sym1 sym2)<br>
(cond<br> [(symbol=? sym1 sym2) 1]<br> [else 0])))<br> <br>Earlier i was thinking of having a counter which i would increment whenever an occurrence is found .Any suggestions on how to think in more of a functional paradigm.<br>
<br>Aditya<br><br><br><br><br>