Skip to content

Commit b59503e

Browse files
committed
count-uppers
1 parent 951919b commit b59503e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

count-upper.rkt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#lang racket
2+
3+
(define (count-upper s)
4+
(foldr
5+
(lambda (c i) (if (char-upper-case? c) (+ i 1) i))
6+
0 (string->list s)))
7+
8+
(provide count-upper)

main.rkt

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
(require "two-sum.rkt")
55
(require "remove-outer-parens.rkt")
66
(require "remove-dups.rkt")
7+
(require "count-upper.rkt")
78

89
(check-equal? (two-sum 5 '(1 2 3 4)) '(1 2))
910
(check-equal? (two-sum 21 '(0 2 11 19 90)) '(1 3))
@@ -15,3 +16,7 @@
1516

1617
(check-equal? (remove-dups '(1 1 2)) 2)
1718
(check-equal? (remove-dups '(0 0 1 1 1 2 2 3 3 4)) 5)
19+
20+
(check-equal? (count-upper "HeLlO wOrLd") 5)
21+
(check-equal? (count-upper "no uppers") 0)
22+
(check-equal? (count-upper "Some uppers") 1)

0 commit comments

Comments
 (0)