Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nrepl-port
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
55107
93 changes: 71 additions & 22 deletions src/structured_data.clj
Original file line number Diff line number Diff line change
@@ -1,70 +1,119 @@
(ns structured-data)

(defn do-a-thing [x]
:-)
(let [numero (+ x x)]
(Math/pow numero numero)))

(defn spiff [v]
:-)
(+ (get v 0) (get v 2)))

(defn cutify [v]
:-)
(conj v "<3"))

(defn spiff-destructuring [v]
:-)
(let [[x y z] v]
(+ x z)
))



(defn point [x y]
[x y])
[x y])

(defn rectangle [bottom-left top-right]
[bottom-left top-right])

(defn width [rectangle]
:-)
(let [[[x1 y1] [x2 y2]] rectangle]
(- x2 x1)
))

(defn height [rectangle]
:-)
(let [[[x1 y1] [x2 y2]] rectangle]
(- y2 y1)
))

(defn square? [rectangle]
:-)
(let [[[x1 y1] [x2 y2]] rectangle]
(if (== (- x2 x1) (- y2 y1)) true false))
)

;(defn area [rectangle]
; (let [[[x1 y1] [x2 y2]] rectangle]
; (* (- x2 x1) (- y2 y1)))
; )

(defn area [rec]
(* ((height (rec))) ((width (rec))))
)


(defn contains-point? [recta poi]
(let [[[x1 y1] [x2 y2]] recta
x3 (get poi 0)
y3 (get poi 1)]
(if(and (<= x1 x3 x2) (<= y1 y3 y2)) true false)
))

(defn area [rectangle]
:-)

(defn contains-point? [rectangle point]
:-)

(defn contains-rectangle? [outer inner]
:-)
(let [[[x1 y1] [x2 y2]] outer
[[xx1 yy1] [xx2 yy2]] inner
]
(if(and (contains-point? (rectangle [x1 y1] [x2 y2]) (point xx1 yy1)) (contains-point? (rectangle [x1 y1] [x2 y2]) (point xx2 yy2))) true false)
))


(defn title-length [book]
:-)
(count (get book :title))
)

(defn author-count [book]
:-)
(count (get book :authors))
)

(defn multiple-authors? [book]
:-)
(if (< 1 (count (get book :authors))) true false)
)


(defn add-author [book new-author]
:-)
(let [auts (get book :authors)
new_auts (conj auts new-author)
]

(assoc book :authors new_auts)
))


(defn alive? [author]
:-)
(if (contains? author :death-year) false true)
)

(defn element-lengths [collection]
:-)
(map count collection)
)

(defn second-elements [collection]
:-)
(let [getsecond (fn[x] (get x 1))]
(map getsecond collection)
))

(defn titles [books]
:-)
(map :title books)
)

(defn monotonic? [a-seq]
:-)


(defn stars [n]
:-)
(apply str (repeat n (str \*))
)
)

(stars 3)

(defn toggle [a-set elem]
:-)
Expand Down