(define (f-acc pred? op id term a next b)
  (cond ((> a b) id)
        ((pred? a)
         (op (term a)
             (f-acc pred? op id term (next a) next b)))
        (else (f-acc pred? op id term (next a) next b))))

(define (thing a b)
  (f-acc (lambda (x) (integer? (sqrt x)))
	*
	1
	(lambda (x) x)
	a
	(lambda (x) (+ x 1))
	b))

(thing 3 5)