I used map and filter to calculate the length of a certain items in a list of triples in Dr.Racket. I want to return the number of times an item is repeated in my list of triples. However, my code returns the actual length of the triples not the number of times an item is repeated.
(define (countStatus lst item)
(map length (filter(lambda (x) (not(equal? x item))) lst)))
(define lst '((joe 21 “employed”) ( ann 19 “unemployed”) (sue 18 “employed” ) ) )
The following procedure should return 2 but instead returns the length of the triples.
> (countStatus lst "employed")
'(3 3 3)