Seems to work just fine for me:

user> (defn make-user-nice-name [map-of-profile]
  (let [user-nice-name
        (if-not (or (nil? (:first_name map-of-profile)) (nil?
(:last_name map-of-profile)))
          (apply str (:first_name map-of-profile) " " (:last_name
map-of-profile))
          (:username map-of-profile))]
    user-nice-name))
#'user/make-user-nice-name
user> (make-user-nice-name {:username "seanc"})
"seanc"
user> (make-user-nice-name {:username "seanc" :first_name "Sean"})
"seanc"
user> (make-user-nice-name {:username "seanc" :first_name "Sean"
:last_name "Corfield"})
"Sean Corfield"
user> (make-user-nice-name {:username "seanc" :last_name "Corfield"})
"seanc"

FWIW, I think it would be more readable (and more idiomatic) like this:

(defn make-user-nice-name [map-of-profile]
  (if (and (:first_name map-of-profile) (:last_name map-of-profile))
    (str (:first_name map-of-profile) " " (:last_name map-of-profile))
    (:username map-of-profile)))


On Fri, Jan 4, 2013 at 8:12 PM, larry google groups
<[email protected]> wrote:
>
> This function gives me a nicely formatted name if the user has supplied a
> first_name or a last_name, however, if there is no first_name and no
> last_name then I get nothing at all. But the username is there in the
> record. Can someone tell me what I did wrong? Why is the username not
> getting set as the value of user-nice-name?
>
>
> (defn make-user-nice-name [map-of-profile]
>   (let [user-nice-name
>         (if-not (or (nil? (:first_name map-of-profile)) (nil? (:last_name
> map-of-profile)))
>           (apply str (:first_name map-of-profile) " " (:last_name
> map-of-profile))
>           (:username map-of-profile))]
>     user-nice-name))
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to