If i wanted my string that I entered to be less than a certain number for example 10. If it is less than 10 i would assign it the value 25. How would I go about doing so?
(define (name n) (cond [(< (string-length nom) 10) 25])) n not defined
1 Answer
You're looking for set! (for "assignment") in conjunction with when (for the condition).
#lang racket (define (name i) (when (<= (string-length i) 10) (set! i 10)) (displayln i)) (name "sustainability") ; => sustainability (name "diversity") ; => 10