Search NKS | Online
21 - 30 of 56 for ReplaceAll
All are of the so-called parabolic type, so that, unlike my equation, they have no limit on the rate of information propagation, and thus a solution in any region immediately depends on values on the boundary—which in the pictures below is taken to be periodic. … Note that Abs[u] is plotted in the second picture, while for the last equation a common less symmetrical form replaces the last term by u[t, x] ∂ x u[t, x] .)
By replacing the addition and multiplication that appear in the first picture by other operations one can then get other representations for numbers. … And the representations of ≃ 2.718 and all its roots also show definite regularity.
And by using rules such as s[x___, 1, 0, y___] {s[x, 0, 1, 0, y], Length[s[x]]} one can keep track of the positions at which substitutions are made. ( StringReplace replaces all occurrences of a given substring, not just the first one, so cannot be used directly as an alternative to having a flat function.)
And in general, the presence of regularities makes it possible to replace literal descriptions of data by shorter descriptions that are based on procedures for reproducing the data.
… But the basic goal in all cases is the same: to reduce raw data to a useful summary form.
Conditions for convergence [in string rewriting]
One way to guarantee that there is convergence after one step is to require as in the previous section that blocks to be replaced cannot overlap with themselves or each other. … Note that a rule such as {"A" "B", "A" "C", "B" "A", "B" "D"} exhibits convergence for all paths that have diverged for only one step, but not for all those that have diverged for longer. In general it is formally undecidable whether a particular multiway system will eventually exhibit convergence of all paths.
Substitution systems in which all replacements are done that are found to fit in a left-to-right scan can be implemented as follows
GSSEvolveList[rule_, s_, n_] := NestList[GSSStep[rule, #] &, s, n]
GSSStep[rule_, s_] := g[rule, s, f[StringPosition[s, Map[First, rule]]]]
f[{ }] = { }; f[s_] := Fold[If[Last[Last[#1]] ≥ First[#2], #1, Append[#1, #2]]&, {First[s]}, Rest[s]]
g[rule_, s_, { }] := s; g[rule_, s_, pos_] := StringReplacePart[ s, Map[StringTake[s, #] &, pos] /. rule, pos]
with rules given as {"ABA" "BAAB", "BBBB" "AA"} .
But what if one replaces some of these hexagons by pentagons? … But if one tries to keep all edges the same length the surface will inevitably become curved—like a soccer ball or a geodesic dome.
Because only a single element is removed at each step, the systems effectively just cycle through all elements, replacing each one in turn.
At first one might think that one could set up some kind of analog of a cellular automaton and just replace all relevant clusters of nodes at once.
Huffman coding
From a list p of probabilities for blocks, the list of codewords can be generated using
Map[Drop[Last[#], -1] &, Sort[ Flatten[MapIndexed[Rule, FixedPoint[Replace[Sort[#], {{p0_, i0_}, {p1_, i1_}, pi___} {{p0 + p1, {i0, i1}}, pi}] & , MapIndexed[List, p]] 〚 1, 2 〛 , {-1}]]]] -1
Given the list of codewords c , the sequence of blocks that occur in encoded data d can be uniquely reconstructed using
First[{{}, d} //. … If all 2 b possible blocks of length b occur with equal probability, then the Huffman codewords will consist of blocks equivalent to the original ones.