On Mon, 1 Mar 2010 11:01:36 -0800 (PST)
ataggart <alex.tagg...@gmail.com> wrote:

> No, but if you need to do that, then you can do what deftype sort-of
> does:
> 
> user=> (defstruct St :a :b)
> #'user/St
> user=> (defn st ([a] (struct St a 0.0)) ([a b] (struct St a b)))
> #'user/st
> user=> (st 5)
> {:a 5, :b 0.0}
> 
> 

Thanks for this. 

Now I tried a different way:

(defstruct st :a :b)

(defn my-struct-map [s & inits]
  (let [sm (struct-map s inits)]
    (if (= nil (sm :b))
      (assoc sm :b 0.0)
      sm))
  )            



Unfortunately, the part sm (struct-map s inits) doesn't work. I have no
idea what is wrong with my code.


-- 
Manfred 


-- 
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