I want to find a way to use a counter within a function where the counter is also a variable within the recursive function. An example of this is with a program that takes a list and then "sifts" through it until it finds all the numbers within it that are multiples of i:
(define (multiples-of lst) (lambda (i) (if (> i 3))
'()
(multiplefilter (ismultipleof (+ i 1)) (lst)))))
where ismultipleof
checks if the car of each list is a multiple of i + 1
(with i starting at 1) and then the multiplefilter
is a separate function that scraps any values of the list that are not multiples of i
. So that if I put in the list (1 2 3 4 5 6 7 8 9 10 11 12)
the output would just be (6 12)
. The biggest issue is getting said counter to work within the function.