The-Clojure-Workshop icon indicating copy to clipboard operation
The-Clojure-Workshop copied to clipboard

Changes to code based on customer inquiries

Open transducer opened this issue 5 years ago • 0 comments

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]}

transducer avatar Jan 20 '21 22:01 transducer