On Sun, 2013-03-24 at 10:32 -0700, N8Dawgrr wrote:
> Is there a mechanism in Clojure to say apply f to all the values of a
> record and return me a new record of the same type?
You can add one via the wonderful `into' function:
(into your-record (map (fn [k v] [k (f v)]) your-record))
--
Steph
Hi,
I'm transforming a recursive form structure to an equivalent structure
represented by Clojure records. I want polymorphic dispatch across my newly
created structure of records. I also want to be able to apply a function to
transform the structure of records, in much the same way as say
clo
On Jul 29, 11:51 pm, Ryan Twitchell wrote:
> Hi all,
>
> I noticed (with a very recent git pull) the following asymmetric
> behavior regarding = and records:
>
> (defrecord my-record [a])
>
> (def r (new my-record 1))
> (def s (new my-record 1))
>
> (= r s) ;; true
> (= s r) ;; tru
On Fri, Jul 30, 2010 at 4:51 AM, Ryan Twitchell wrote:
>
> (= r s) ;; true
> (= s r) ;; true
> (= r {:a 1}) ;; false
> (= {:a 1} r) ;; true
>
> Is this intentional? (I hope not)
>
The three first are documented in (doc defrecord)
"In addition, defrecord will define type-and-valu
I'm sure it's not intentional, but it makes sense. In the first case, the
comparison delegates to `r`'s equals() method, which would return false because
{:a 1} isn't a `my-record`. In the second case, the comparison delegates to
`{:a 1}`'s equals() method, which is a PersistentArrayMap, which w
Hi all,
I noticed (with a very recent git pull) the following asymmetric
behavior regarding = and records:
(defrecord my-record [a])
(def r (new my-record 1))
(def s (new my-record 1))
(= r s);; true
(= s r);; true
(= r {:a 1}) ;; false
(= {:a 1} r) ;; true
Is this intentio