I have large list of rules, I would like to use list/.rule
, but assume that rule is a set of rules rule 1, rule2 rule...
I want the Replace All to find first match of rule 1 then apply rule,and so go over to look for match of rule two. This would speed up the process in a very large dataset.
I want the first rule on only the first match found, then continue with the next rule from start of the list, if there are any cases of no match go to to next rule. Result would be the list but with applied rules where matches of patterns have been found.If a rule changes a value, and that new value is matched by a later rule, then leave it untouched.(Do not apply rule on al ready changed value)
Example:
list={{"02jan2001", "A", 47.98, ""}, {"03jan2001", "A", 52.9312,
""}, {"04jan2001", "A", 54.9353, ""}, {"05jan2001", "A", 51.9292,
""}, {"08jan2001", "A", 50.2198, ""}, {"09jan2001", "A", 49.9841,
""}}
Rules= {{"02jan2001", "A", q$___} -> 0.815473`, {"03jan2001", "A", q$___} ->
0.840296`, {"04jan2001", "A", q$___} -> 0.833659`}
Wanted output {0.815473, 0.840296, 0.833659, {"05jan2001", "A", 51.9292,
""}, {"08jan2001", "A", 50.2198, ""}, {"09jan2001", "A", 49.9841,
""}}
ReplaceRepeated
andReplaceList
. Also for speeding up replacements generally seeDispatch
and note that if you know the structure of your list then try replacing to a specific levelspec rather than all levels. $\endgroup$Rules
) in the same order as they are matched within yourlist
; is this always the case? $\endgroup$