I'm new to functional programming and I'm using Kotlin with arrow functional library. I would like to convert below function to pure. Each func*()
call returns a valid string and it's gets appended to mutable string variable returnString
. As far as I know, FP functions should not use any mutable values. So how would I replace those string appending lines?
private fun stringifyValue(): String {
var returnString = String()
returnString = returnString.plus("=")
returnString = returnString.plus(func1())
returnString = returnString.plus("+/")
returnString = returnString.plus(func2())
returnString = returnString.plus("@")
returnString = returnString.plus(func3())
returnString = returnString.plus("#")
returnString = returnString.plus(func4())
returnString = returnString.plus("%")
returnString = returnString.plus(func5())
returnString = returnString.plus("^")
return returnString
}