Higher Order Functions in Scala Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report A function is called Higher Order Function if it contains other functions as a parameter or returns a function as an output i.e, the functions that operate with another functions are known as Higher order Functions. It is worth knowing that this higher order function is applicable for functions and methods as well that takes functions as parameter or returns a function as a result. This is practicable as the compiler of Scala allows to force methods into functions. Some important points about Higher order functions: The Higher order functions are possible, as Scala programming language acts towards the functions as first-class values, which implies that analogous to some other values, functions can even be passed as a parameter or can be returned as an output, which is helpful in supplying an adjustable method for writing codes. It is beneficial in producing function composition where, functions might be formed from another functions. The function composition is the method of composing where a function shows the utilization of two composed functions. It is also constructive in creating lambda functions or anonymous functions. The anonymous functions are the functions which does not has name, though perform like a function. It is even utilized in minimizing redundant lines of code from a program. Now, lets see some examples. Example : Scala // Scala program of higher order // function // Creating object object GfG { // Main method def main(args: Array[String]) { // Displays output by assigning // value and calling functions println(apply(format, 32)) } // A higher order function def apply(x: Double => String, y: Double) = x(y) // Defining a function for // the format and using a // method toString() def format[R](z: R) = "{" + z.toString() + "}" } Output: {32.0} Here, the apply function contains an another function x with a value y and applies the function x to y. Example : Scala // Scala program of higher order // function // Creating object object GfG { // Main method def main(args: Array[String]) { // Creating a list of numbers val num = List(7, 8, 9) // Defining a method def multiplyValue = (y: Int) => y * 3 // Creating a higher order function // that is assigned to the variable val result = num.map(y => multiplyValue(y)) // Displays output println("Multiplied List is: " + result) } } Output: Multiplied List is: List(21, 24, 27) Here, map is a function that takes another function i.e, (y => multiplyValue(y)) as a parameter so, it is a higher order function. Comment N nidhi1352singh Follow 1 Improve N nidhi1352singh Follow 1 Improve Article Tags : Scala Scala Scala-Method Explore OverviewScala Programming Language3 min readIntroduction to Scala7 min readSetting up the environment in Scala3 min readHello World in Scala2 min readBasicsScala Keywords2 min readScala Identifiers3 min readData Types in Scala3 min readVariables in Scala3 min readControl StatementsScala | Decision Making (if, if-else, Nested if-else, if-else if)5 min readScala | Loops(while, do..while, for, nested loops)5 min readBreak statement in Scala3 min readScala | Literals4 min readOOP ConceptsClass and Object in Scala5 min readInheritance in Scala5 min readOperators in Scala11 min readScala Singleton and Companion Objects3 min readScala Constructors4 min readScala | Polymorphism5 min readScala | Multithreading3 min readScala this keyword2 min readMethodsScala | Functions - Basics3 min readAnonymous Functions in Scala2 min readScala | Closures3 min readRecursion in Scala4 min readMethod Overloading in Scala5 min readMethod Overriding in Scala8 min readLambda Expression in Scala4 min readScala Varargs2 min readStringsScala String4 min readScala | String Interpolation3 min readScala | StringContext2 min readRegular Expressions in Scala5 min readStringBuilder in Scala4 min readScala PackagesPackages In Scala4 min readScala | Package Objects3 min readChained Package Clauses in Scala3 min readFile Handling in Scala3 min readScala TraitScala | Traits7 min readScala | Sealed Trait4 min readScala | Trait Mixins3 min readTrait Linearization in Scala5 min readCollectionsScala Lists5 min readScala ListBuffer6 min readListSet in Scala6 min readScala Map5 min readScala | Arrays6 min readScala | ArrayBuffer4 min readScala | Tuple5 min readSet in Scala | Set-13 min readSet in Scala | Set-27 min readBitSet in Scala5 min readHashSet In Scala4 min readStack in Scala3 min readHashMap in Scala3 min readTreeSet in Scala4 min readIterators in Scala5 min readScala | Option3 min read Like