Using doall with an if contion inside

Hi all, I’m trying doall and don’t know why the true condition, in this case, isn’t working at all.

(doall (map (fn [age working exit]
                (let [info (if present
                             {:name "Wags", :age 50, :working true, :exit nil}
                             (if-not (nil? working)
                               {:Name "Mafee", :is-left (cond (= exit -1) true (= exit -2) false)
                                :working working, :age age}
                               {:name "Wags", :age 50, :working true, :exit nil}))]
                  (println "info" info)
                  )) age working exit))

Only when present is false it returns as per the false condition but when the present is true, it doesn’t return anything. What’s going on?

There is nothing special about doall with an if. println returns nil so the value of the whole doall will be a seq of nil. I assume you are doing that to debug the lambda. I assume the arguments to map are sequences outside of the lambda. Not sure where present is introduced. Seems like it should print different values based on what you have. Experiment with the doall as you have above but outside of the context of your code to verify that it works as intended. My guess is there’s some bug in the application logic, but there’s not enough information to help you debug this.

The problem I guess is the 3 arity function. Changing the above to:

(doall (map (fn [[age working exit]]
                (let [info (if present
                             {:name "Wags", :age 50, :working true, :exit nil}
                             (if-not (nil? working)
                               {:Name "Mafee", :is-left (cond (= exit -1) true (= exit -2) false)
                                :working working, :age age}
                               {:name "Wags", :age 50, :working true, :exit nil}))]
                  (println "info" info)
                  )) [[age working exit]]))

Worked fine. Thanks @xfthhxk