Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to code based on customer inquiries #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
30 changes: 13 additions & 17 deletions Chapter04/Activity4.01/src/packt-clj/game_values.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns packt-clj.game-values)


(def game-users
[{:id 9342
:username "speedy"
Expand Down Expand Up @@ -63,22 +62,19 @@
:experience-level 8
:status :active}])


(defn max-value-by-status [field status users]
(->>
users
;; step 1: use filter to only keep users who
;; have the status we are looking for
(filter #(= (:status %) status))
;; step 2: field is a keyword, so we can use it as
;; a function when calling map.
(map field)
;; step 3: use the apply max pattern, with a default
(apply max 0)))
(->> users
;; step 1: use filter to only keep users who
;; have the status we are looking for
(filter #(= (:status %) status))
;; step 2: field is a keyword, so we can use it as
;; a function when calling map.
(map field)
;; step 3: use the apply max pattern, with a default
(apply max 0)))

(defn min-value-by-status [field status users]
(->>
users
(filter #(= (:status %) status))
(map field)
(apply min 0)))
(->> users
(filter #(= (:status %) status))
(map field)
(apply min)))
2 changes: 1 addition & 1 deletion Chapter06/Exercise6.07/train_routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
(= position destination) path

(get-in route-lookup [position destination])
(conj path destination)
[(conj path destination)]

:otherwise-we-search
(let [path-set (set path)
Expand Down