Author: Stan Eisenstat
Subject: Re: [Cs223] Detecting infinite expansion (staff solution doesn't
Date: Thursday, 27 Feb 2020, 14:07:16
> Message Posted By: Unknown > > When I run the staff solution on the following > > /c/cs223/Hwk3/strwrs -Rs a aa > > with input > > ab > > the program does not seem to terminate. This is because it keeps adding an > a to the string, so the string technically does change, yet this process > never terminates. Are we supposed to detect cases like this? How should > these be handled? As stated in the specification: 4. Some substitutions (e.g., "strwrs -s a a" applied to "a") would not normally terminate. To make your program more useful, it should detect the following such cases: a) If the r or s flag has been specified and the replacement of some Fi by Ti leaves the line unchanged, then pretend that this rule was not applied successfully and continue to the next rule. b) If the R flag has been specified and a successful substitution leaves the line unchanged, then pretend that the substitution was UNsuccessful and continue to the next rule. Thus this is not one of the cases that strwrs must deal with. --Stan-PREV INDEX NEXT