I have a function that wants to pull a value out of a map based on a prioritized order. Currently I’m doing it as a nested if structure which is horrible. I have to believe there is a better way.
While this works is there a better way?
(defn filter-relatives [relatives]
(if(contains? relatives :self)
(relatives :self)
(if(contains? relatives :north)
(relatives :north)
(if(contains? relatives :west)
(relatives :west)
(if(contains? relatives :east)
(relatives :east)
(relatives :south)
)
)
)
)
)
)
)
1 Answer