Professional Documents
Culture Documents
Scala Functions Examples
Scala Functions Examples
object PAFExample {
def main(args: Array[String])={
val str="StreamA"
val classlevel="4th year"
//A variable to hold the results . The stresult function is partially applied.
val printstresults=stresult(str,classlevel,_ :Int)
printstresults(56)
printstresults(34)
printstresults(67)
// A higher order function API. It recieves a function fn whose argument is an Int and returns a
string. It also recives an Int argument (mark). Then it applies the fn function to the argument
mark
def result(fn: Int=>String, mark: Int) = fn(mark)