Skip to main content
8 events
when toggle format what by license comment
May 7, 2017 at 9:33 comment added Gaby Fleurov Thanks for all the answers! I'll try them out, @mikado, the question indicated was exactly what I was looking for, probably I haven't been clear enough.
May 5, 2017 at 20:18 comment added mikado I'm not sure that this is a duplicate of the question indicated. If it isn't, I suggest editing the question to give 1) an example input 2) an example set of rules and 3) the output desired.
May 5, 2017 at 19:22 comment added andre314 In some cases ReplaceList[exp,rule,1]can do the job. The problem is that the rule is only applied at level 0 of exp. Example : to replace 1 by 2 only one time in {1,1,1}, do ReplaceList[{1,1,1},{a___,1,b___}:> {a,2,b},1]. Result : {{2, 1, 1}}
May 5, 2017 at 18:58 history closed Jason B.
CommunityBot
Duplicate of How to replace the first occurence in an expression instead of replacing all?
May 5, 2017 at 18:53 comment added Jason B. Or, much more hacky, replacement = "A"; {"a", "b", "a", "c"} /. x : "a" :> With[{res = replacement}, replacement = x; res]
May 5, 2017 at 18:51 comment added Bob Hanlon replaceFirst[expr_, old_, new_] := ReplacePart[expr, Position[expr, old][[1]] -> new]
May 5, 2017 at 18:37 review First posts
May 5, 2017 at 18:39
May 5, 2017 at 18:32 history asked Gaby Fleurov CC BY-SA 3.0