Strip block comments: Difference between revisions

(add Ada)
Line 448:
}`))
}</lang>
 
=={{header|Haskell}}==
Comment delimiters can be changed by calling stripComments with different start and end parameters.
 
<lang Haskell>import Data.List
 
stripComments :: String -> String -> String -> String
stripComments start end = notComment
where notComment :: String -> String
notComment "" = ""
notComment xs
| start `isPrefixOf` xs = inComment $ drop (length start) xs
| otherwise = head xs:(notComment $ tail xs)
inComment :: String -> String
inComment "" = ""
inComment xs
| end `isPrefixOf` xs = notComment $ drop (length end) xs
| otherwise = inComment $ tail xs
 
main = interact (stripComments "/*" "*/")</lang>
Output:
<pre>
function subroutine() {
a = b + c ;
}
 
function something() {
}
 
</pre>
 
=={{header|J}}==
Anonymous user