I am trying to create a procedure that has a user input a non-empty string and then returns a random letter from the input in a substring of length one.
i.e.
(pick-at-random "word")
~"w"
(pick-at-random "word")
~"r"
So far I’ve got:
(define pick-at-random
(lambda (s)
(substring s (random(string-length s)) ())))
This gives me the position of the letter I want to display and I feel like where the () is, I should have some variable representing the start value of the substring and then add one to it. However, I don’t know how to do this. Simply put, I am asking how I can limit the substring to length one while using the random function in the start value.
You may use
letto bind the random number to a variable.