Re: A Puzzle in Eu -- what would you do?
- Posted by D. Newhall <derek_newhall at yahoo.com> Aug 05, 2005
- 515 views
I didn't feel like using match so I wrote this. This is one of the few times I'll agree that GOTOs could be useful... function strip_comments(sequence code) integer index, -- index of letter in code in_string -- "boolean" in_string = 0 -- Replicate for loop index = 1 while length(code) >= index do if code[index] = '\"' and code[index - 1] != '\\' then if in_string then in_string = not in_string else in_string = 1 end if end if if not in_string -- What you search for goes here and code[index] = '-' and code[index + 1] = '-' then return code[1..index - 1] end if index += 1 end while return code end function The Euphoria Standard Library project : http://esl.sourceforge.net/ The Euphoria Standard Library mailing list : https://lists.sourceforge.net/lists/listinfo/esl-discussion