I'm new to functional programming and as I'm reading this book. It basically says that if you code contains "var" it means that you're still doing in a imperative way. I'm not sure how do I change my code to be functional way. Please suggests.
So basically what this code does is to processText some text and use regular expression to extract a particular text from "taggedText" and add that to a list and convert the list to json.
val text = params("text")
val pattern = """(\w+)/ORGANIZATION""".r
var list = List[String]()
val taggedText = processText(text)
pattern.findAllIn(taggedText).matchData foreach {
m => list ::= m.group(1)
}
pretty(render(list)) // render to json