The max function returns the maximum of the arguments that it passed:
(max 1 2 3 4 5)
To call it using a sequence that you can use, follow these steps:
(apply max boxes)
Dao Wen is well aware that if the sequence can be empty, then the abbreviation allows you to specify the default value:
(reduce max -1 [])
and the same work for application:
(apply max -1 [])
Otherwise, the application will explode:
user=> (apply max []) ArityException Wrong number of args (0) passed to: core$max clojure.lang.AFn.th rowArity (AFn.java:437)
source share