samedi 24 décembre 2016

Generate random ASCII character

I need to generate a random ASCII letter (upper or lowercase) or character (but not number) in scheme, and I was wondering what the appropriate way to do that was. Currently I've got the code

(define a 1)
(define b 16)
(define (s8 a b)
  (when (<= a b)
    (if (= (mod a 8) 0)
      (write "h")
      (write a))
    (s8 (+ a 1) b)))
(s8 a b)

which works (no errors) but instead of printing a random ascii letter/character, I get "h", because I didn't know how to do that. I googled around but couldn't find a thing. Any help would be appreciated. Thanks!




Aucun commentaire:

Enregistrer un commentaire