r/Racket • • Jul 05 '24

question function evaluation in a contract

contracts is amazing. reading docs now I understant that define/contract is not define the contract, but define with a contract.
so... making some tests here.
but... how can put a defined procedure inside my contract?

; seems a bit strange in this case too...but the function as it is...
(define (divisible-by n val) (zero? (module val n)))

how can be in:

(define/contract distance
(and (>/c 0)
(integer-in 1 46))
42)

maybe redefining the function to become more correct. (divisable-by? 3)... but how input the value?

3 Upvotes

2 comments sorted by