Closed bigyihsuan closed 2 years ago
At this point I doubt I'll provide special syntax for this. Needing to repeat a rule a specific number of times just isn't a common situation for evolving languages in my experience.
If you really need to limit propagation, you can use temporary symbols, e.g.:
class digit {\0,\1,\2,\3,\4,\5,\6,\7,\8,\9}
class digitPlusOne {\1,\2,\3,\4,\5,\6,\7,\8,\9,^\0}
increment-three:
* => \~\~\~ / @digit _ // _ @digit
then propagate:
(
@digit \~ => @digitPlusOne *
then propagate:
@digit ^ => @digitPlusOne *
then:
^ => \1
)
I wish to be able to propagate a rule a maximum number of times.
I suggest the following syntax: Whenever a
propagate
appears, it can an optionalX
modifier to limit the maximum number of times the propagating rule will run:where
X
is some number signifying the maximum number of times that this rule will run before going to the next one.Here's an example, which takes an input string and would double itself, three times:
Here is another example, where, when given a string with some marker, in this case a tilde, will move it to the right two places:
You can (ab)use this for an incrementor: