You intend to execute two expressions inside the next part of if , but if allows only one expression in the following and one in the alternative.
Rounding both expressions between brackets (like you) will not work: the resulting expression will be evaluated as a function application of the first expression with the second expression as its argument, creating an error "application: not a procedure; expected a procedure that can be applied to arguments ..." because (time-prime-test n) does not evaluate the procedure, it evaluates #<void> .
You can fix this problem either with cond :
(define (search-for-primes nm) (cond ((< nm) (time-prime-test n) (search-for-primes (+ n 1) m)) (else (display " calculating stopped. "))))
Or a begin :
(define (search-for-primes nm) (if (< nm) (begin (time-prime-test n) (search-for-primes (+ n 1) m)) (display " calculating stopped. ")))
Γscar LΓ³pez
source share