Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

The part about a workaround can, I think, be solved by the same trick as I very recently suggested herehere - prepend an idle rule:

AbsoluteTiming[
   Range[1000000] /. {
      arr_?Developer`PackedArrayQ :> arr, 
      x -> 0, a -> 1, b -> 2, c -> 3, d -> 4, e -> 5, 
      f -> 6, g -> 7, h -> 8, i -> 9, j -> 10};
]

(* {0.001131, Null} *)

This will only work for ReplaceAll though (and not Replace, Cases etc).

The part about a workaround can, I think, be solved by the same trick as I very recently suggested here - prepend an idle rule:

AbsoluteTiming[
   Range[1000000] /. {
      arr_?Developer`PackedArrayQ :> arr, 
      x -> 0, a -> 1, b -> 2, c -> 3, d -> 4, e -> 5, 
      f -> 6, g -> 7, h -> 8, i -> 9, j -> 10};
]

(* {0.001131, Null} *)

This will only work for ReplaceAll though (and not Replace, Cases etc).

The part about a workaround can, I think, be solved by the same trick as I very recently suggested here - prepend an idle rule:

AbsoluteTiming[
   Range[1000000] /. {
      arr_?Developer`PackedArrayQ :> arr, 
      x -> 0, a -> 1, b -> 2, c -> 3, d -> 4, e -> 5, 
      f -> 6, g -> 7, h -> 8, i -> 9, j -> 10};
]

(* {0.001131, Null} *)

This will only work for ReplaceAll though (and not Replace, Cases etc).

Source Link
Leonid Shifrin
  • 114.9k
  • 16
  • 333
  • 424

The part about a workaround can, I think, be solved by the same trick as I very recently suggested here - prepend an idle rule:

AbsoluteTiming[
   Range[1000000] /. {
      arr_?Developer`PackedArrayQ :> arr, 
      x -> 0, a -> 1, b -> 2, c -> 3, d -> 4, e -> 5, 
      f -> 6, g -> 7, h -> 8, i -> 9, j -> 10};
]

(* {0.001131, Null} *)

This will only work for ReplaceAll though (and not Replace, Cases etc).