The-Clojure-Workshop
The-Clojure-Workshop copied to clipboard
Changes to code based on customer inquiries
Dear maintainer,
Based on inquiries I changed some code. I think it's now more correct. Let me know if there are any questions.
Kind regards, Erwin
Activity 4.01:
Align and do not use default with apply min
Since (apply min <any-coll> 0) is always 0
Exercise 6.07:
There's a bug in the code for direct routes that are not over multiple hops. min-route expects a collection so we should always return a collection.
This way it works for both direct and indirect routes:
(find-path (grouped-routes routes) :paris :london)
;; => {:cost 236, :best [:paris :london]}
(find-path (grouped-routes routes) :paris :budapest)
;; => {:cost 251, :best [:paris :milan :vienna :budapest]}