Strip comments from a string: Difference between revisions

Added 11l
(add Standard ML)
(Added 11l)
Line 29:
{{Template:Strings}}
<br><br>
 
=={{header|11l}}==
<lang 11l>F remove_comments(line, sep)
V? p = line.find(sep)
I p != N
R line[0.<p].rtrim(‘ ’)
R line
print(remove_comments(‘apples ; pears # and bananas’, (‘;’, ‘#’)))
print(remove_comments(‘apples ; pears # and bananas’, ‘#’))
print(remove_comments(‘apples ; pears # and bananas’, ‘!’))</lang>
 
{{out}}
<pre>
apples
apples ; pears
apples ; pears # and bananas
</pre>
 
=={{header|Ada}}==
1,481

edits