In this particular case, I'd probably treat a
nil value of
search as being "always match" in the
(filter (fn [comment] (or (nil? search)
(s/includes? (s/upper-case (:thread comment))
and then you could just have the 0-arity version of the function call the 1-arity version with
"Get all urls threads"
( (get-threads nil))
(let [comments ...]
(filter ... comments))))
Another option here would be to use
(cond->> (distinct (map (fn [comment] ...) @db))
(filter (fn [comment] (s/includes? ...)))
This will pass the comments into the
filter call, only if
search is non-nil, else it will return all the comments, unfiltered.
Typically, if I have multiple arities due to optional arguments, I will pick an "empty" value for the optional arguments and just have the lower arities call the full arity, passing those "empty" values -- zero,
nil, empty list, etc. Then the full arity version will conditionally handle those "empty" values as appropriate.