-
Notifications
You must be signed in to change notification settings - Fork 1
/
fib.clj
83 lines (66 loc) · 1.28 KB
/
fib.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
((fn
[mylist index]
(first
(reverse
(take index mylist)))) '(4 5 6 12 1) 4)
(let [x y]
(inc x)
(print x)
x)
((fn [[x y]]
(if (> x y)
x
y
)
) [10 8])
(defn comparor
[[x y]] (if (> x y) x y))
(comparor [1 2])
(partition 2 [ 1 8 3])
(vec (map comparor (map vec (partition 2 [ 1 8 3]))))
((fn compareVals [[x y]] (if (> x y) x y)) [8 90])
((fn [x] (take x (map first (iterate (fn [[a b]] [b (+ a b)]) [1 1])))) 10)
(def l [1 2 3 2 1])
(count l)
(defn counter [len callingFunc]
(loop [x 0]
(if (< x len)
(do
(print (str " : " x))
(callingFunc x)
(recur (inc x))
)
(print "done")
)
))
;(counter 10 #(print %))
(defn pal2
[coll]
(let [x (count coll)]
(do
(println (take (/ (count coll) 2) coll))
(println (drop (/ (count coll) 2) coll))
(=
(list (take (/ (count coll) 2) (list coll)))
(list (nthrest coll (/ (count coll) 2)))
)
)
)
)
;(take [ 1 2 ] 2)
(pal2 l)
(pal2 "bahadir")
(pal2 [:foo :bar :foo])
(defn pallindrome
[coll]
(map
(fn [x]
(= (nth coll x)
(nth coll
(dec
(- (count coll) x)
))))
coll ))
(pallindrome "racecar")
(pallindrome l)
(pallindrome [1 2 3 2 1])