On Nov 16, 2015, at 2:58 PM, Merve Tektaş <mervetektas1...@gmail.com> wrote:
> > Example Output: > “PsPe4-3 ds** 9kKt??” > numbers: 3 > symbols: 5 > letters: 9 > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. Here is your homework solution: #lang htdp/isl (define DIGITS (explode "0123456789")) (define SYMBOLS (explode "?!@#$%^&*()-")) (define LETTERS (append (explode "qwertyuiopasdfghjklzxcvbnm") (explode "QWERTYUIOPASDFGHJKLZXCVBNM"))) ;; String -> [List N N N] ;; count how often a DIGIT SYMBOL or LETTER appears in this string (str) (check-expect (main "PsPe4-3 ds** 9kKt??") (list 3 5 9)) (define (main str) (local ((define exp (explode str))) (list (count exp DIGITS) (count exp SYMBOLS) (count exp LETTERS)))) ;; [Listof 1String] [Listof 1String] -> N ;; count how often a member of s appears in this string (str) (define (count str s) (cond [(empty? str) 0] [else (local ((define result (count (rest str) s))) (if (member? (first str) s) (add1 result) result))])) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.