24
$\begingroup$

Bug introduced in 10.0 and fixed in 11.0.0


Related to Mapping (Query) a function at multiple locations in nested data via All, Span, it seems to me that the behavior of MapAt with Span in 10.1.0, applied to an Association, has a bug:

asc = <|"a" -> 1, "b" -> 2, "c" -> 3|>;

MapAt[f, asc, 1 ;; 2]

(* out=  <|"a" -> f[1], "b" -> f[2]|>             *)

I think it should evaluate the same as:

MapAt[f, asc, {{1}, {2}}]

(* out=  <|"a" -> f[1], "b" -> f[2], "c" -> 3|>   *)

Do others agree that the disappearance of key "c" is a bug, and which versions are affected?

$\endgroup$
  • 7
    $\begingroup$ Definitely looks like a bug to me, I have filed a report. $\endgroup$ – ilian Jun 3 '16 at 0:09
  • $\begingroup$ @ilian Thanks, and thanks. Shall I presume versions 10.0 through 10.4 are affected? $\endgroup$ – Mr.Wizard Jun 3 '16 at 0:14
  • 3
    $\begingroup$ Yes, goes back to 10.0.0 and still present today. $\endgroup$ – ilian Jun 3 '16 at 0:17
4
$\begingroup$

This bug has been fixed in the just released Mathematica 11.0:

MapAt[f, <|"a" -> 1, "b" -> 2, "c" -> 3|>, 1 ;; 2]

(* <|"a" -> f[1], "b" -> f[2], "c" -> 3|> *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.