Timeline for Replace vs. ReplaceAll involving Flat
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 21, 2022 at 4:03 | vote | accept | Acacia | ||
| Sep 18, 2022 at 17:11 | comment | added | Lukas Lang | @MichaelE2 Sorry for the confusion - I meant to say that while the levelspec behavior is the same for Map and Replace (as far as I know), it's more obvious that you get the correct behavior if you do actually use Replace | |
| Sep 18, 2022 at 16:25 | comment | added | Michael E2 | I didn't realize there was any difference in how they handled the level spec. (Or I've forgotten the difference.) | |
| Sep 18, 2022 at 15:55 | comment | added | Lukas Lang | @MichaelE2 I guess a minor advantage is the fact that it is more explicit that the level specification is applied correctly. On the other hand, I do find it slightly harder to mentally parse. Other than that, they should indeed behave equivalently as far as I can tell | |
| Sep 18, 2022 at 14:53 | comment | added | Michael E2 | Nice. (+1) I've used this trick in other situations. Somehow if replacement is on my mind, I usually do myReplace like this: myReplace[expr_, rules_, level_ : {0}] := Replace[expr, e_ :> (e /. Flatten@{rules, x_ :> x}), level]. I can't think of any advantage of one over the other, though. | |
| Sep 18, 2022 at 10:07 | history | answered | Lukas Lang | CC BY-SA 4.0 |