Skip to content

Commit 96787f8

Browse files
authored
Create 22.clj
1 parent 3057fac commit 96787f8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

22.clj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
;; Title: Count a sequence
2+
;; Link: http://www.4clojure.com/problem/22
3+
;; Description: Write a function which returns the total number of elements in a sequence.
4+
5+
;; QUESTION/TEST CODE
6+
7+
;; (= (__ '(1 2 3 3 1)) 5)
8+
;; (= (__ "Hello World") 11)
9+
;; (= (__ [[1 2] [3 4] [5 6]]) 3)
10+
;; (= (__ '(13)) 1)
11+
;; (= (__ '(:a :b :c)) 3)
12+
13+
;; SOLUTION CODE
14+
15+
#(reduce (fn [value coll] (inc value)) 0 %)

0 commit comments

Comments
 (0)