Skip to content

Commit 3057fac

Browse files
authored
Create 21.clj
1 parent 99a5838 commit 3057fac

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

21.clj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
;; Title: Nth Element
2+
;; Link: http://www.4clojure.com/problem/21
3+
;; Description: Write a function which returns the Nth element from a sequence.
4+
5+
;; QUESTION/TEST CODE
6+
7+
;; (= (__ '(4 5 6 7) 2) 6)
8+
;; (= (__ [:a :b :c] 0) :a)
9+
;; (= (__ [1 2 3 4] 1) 2)
10+
;; (= (__ '([1 2] [3 4] [5 6]) 2) [5 6])
11+
12+
;; SOLUTION CODE
13+
14+
#(last (take (inc %2) %))

0 commit comments

Comments
 (0)