Why does the first reduce not work but the second does?
(reduce (fn [{:keys [minimum maximum]} new-number]
{:minimum (if (and minimum (< new-number minimum))
new-number
minimum)
:maximum (if (and maximum (> new-number maximum))
new-number
maximum)})
{}
[5 23 5004 845 22])
(reduce (fn [{:keys [minimum maximum]} new-number]
{:minimum (if (and minimum (> new-number minimum))
minimum
new-number)
:maximum (if (and maximum (< new-number maximum))
maximum
new-number)})
{} ;; <---- The new argument!
[5 23 5004 845 22])
The first reduce returns nil as the values to the keys; the second reduce works as expected. Why?
New contributor
Antonio Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1