my function checks simple values and should have output/return depending on the result. I have 2 problems:
1. when I replace the let value (-1) of runner with the expression (randint (-5 10)), where randint is another procedure that returns a random number between -5 and 10, it doesnt work
- I want to return/print a string for the first two if statements if they are true, dont know how to do that in scheme.
Here is the code:
(define (check)
(let (runner(randint -5 10)
(cond ((and (< runner 1) (> runner -3))
(display "yes"))
((and (< runner -2) (> runner -6))
(display "no"))
((> runner 0)
(display runner))))))
Here is the code for randint:
(define random
(let ((a 69069) (c 1) (m (expt 2 32)) (seed 19380110))
(lambda new-seed
(if (pair? new-seed)
(set! seed (car new-seed))
(set! seed (modulo (+ (* seed a) c) m)))
(/ seed m))))
(define (randint . args)
(cond ((= (length args) 1)
(floor (* (random) (car args))))
((= (length args) 2)
(+ (car args) (floor (* (random) (- (cadr args) (car args))))))
(else (error 'randint "usage: (randint [lo] hi)"))))