If I define some function like:
toISOdate[data_List]:=DateString[data,{"Year","-","Month","-","Day"}]
and try to applicate it in an Association
ass = <|"date" -> {{2014, 1, 1}, {2014, 1, 2}}|>
as:
Replace[ass, a:{_, _, _} :> toISOdate[a], ∞]
I get, the non calculated form:
<|"date" -> {toISOdate[{2014, 1, 1}], toISOdate[{2014, 1, 2}]}|>
instead of
<|"date" -> {"2014-01-01", "2014-01-02"}|>
If I use Normal
into ass
as:
Replace[Normal@ass, (a : {_, _, _}) :> toISOdate[a], ∞]
I get the correct calculation, but lose the association form.
Is this a bug? How can I get it evaluated with Association
?
Using Mathematica V10.1 on Mac
PS: I can't loose the association structure, the real case is more complex.
Update:
ass /. a : {_, _, _} :> toISOdate[a]
Works as expected.
Replace
function to a variable, and recall it, it's correct (v 10.2 Mac OS X).a = Replace[....]; a["date"]
$\endgroup$