Skip to main content
9 events
when toggle format what by license comment
Mar 12, 2019 at 15:00 history tweeted twitter.com/StackMma/status/1105483747753971712
Mar 12, 2019 at 13:52 vote accept Chris K
Mar 12, 2019 at 13:29 answer added Leonid Shifrin timeline score: 4
Mar 12, 2019 at 11:54 comment added Lukas Lang @b3m2a1 The HoldFirst of Table doesn't seem to be the issue: 1 /. x_ -> ((var_ -> var) -> x) returns (var$_ -> var) -> 1, which is already broken. From a few quick tests, it seems that all the rules in the example are needed for it to return strange results.
Mar 12, 2019 at 9:20 comment added b3m2a1 might be a place where something like Thread[Replace[Keys[#], log[n_]:>n, {1}]->Values[#]]& might be the least likely to have side effects. Alternately create your replacement rules first with Dispatch to get most of the benefit of vectorizing the call.
Mar 12, 2019 at 9:04 comment added Chris K @b3m2a1 Don't assume anything about my programming knowledge! But in my real problem, I've already got something like {log[n] -> some stuff, log[m] -> some other stuff} that I need to transform to {n -> some (slightly different) stuff, m -> some other (slightly different) stuff}.
Mar 12, 2019 at 8:34 comment added b3m2a1 Also just gonna throw it out there since I think chances are good you know it already, but you're good on the fact that this is probably not the most less efficient way to do this, right? Better would be to do a more targeted Replace[..., rule, {1}] on unks first I imagine. Or if you need it deeper just to the /. there first or do a Replace[..., rule, {1, Infinity}] or something along those lines.
Mar 12, 2019 at 8:33 comment added b3m2a1 Looks like the x_ is causing the lexical scoping mechanism to come into play but the HoldFirst on Table is breaking that. Check out this: foo3[x_] := With[{reps={log[var_] :> var}}, Table[(unk/.reps)->x, {unk, unks}]]
Mar 12, 2019 at 8:07 history asked Chris K CC BY-SA 4.0