def defines a global binding (i.e. you can reach the symbol from
everywhere).
defn does the same thing, but always binds the symbol to a function.

Therefore, you only need either def OR defn.

(defn string-maker [the-string]
  (str the-string))

OR

(def string-maker (fn [the-string] (str the-string)))

Jonathan

On Thu, Jul 14, 2011 at 8:41 AM, Tuba Lambanog <tuba.lamba...@gmail.com>wrote:

> Hello,
> Total noobie here. I'm trying to create a sort of a string maker
> function. Something like:
>
> (defn string-maker [string-name the-string]
>  (def string-name (str the-string)))
>
> so that I can call the function like so:
>
> (string-maker "friend" "Peter")
>
> which I expect to give me the variable:   friend
> with the value: Peter
>
> But alas, no luck. Can anybody point me in the right direction?
> Thanks!
> tuba
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Reply via email to