官术网_书友最值得收藏!

Functions and Closures

In the previous chapter, we had an overview of Functional Programming (FP) and the Swift programming language. It introduced some of the key concepts of functions. As functions are the fundamental building blocks in FP, this chapter pes deeper into the subject and explains all the aspects related to the definition and usage of functions in Swift and FP, together with coding examples.

This chapter starts with the Swift function and method syntax, continues with other related topics such as function types and tuples, and finally concludes with FP topics such as first-class functions, higher-order functions, function composition, closures, currying, recursion, and memoization.

This chapter will cover the following topics by coding examples:

  • General syntax of functions
  • Defining and using function parameters
  • Setting internal and external parameters
  • Setting default parameter values
  • Defining and using variadic functions
  • Returning values from functions
  • Defining and using nested functions
  • Function types
  • Pure functions
  • First class functions
  • Higher-order functions
  • Function composition
  • Custom operator definition
  • Defining and using closures
  • Function currying
  • Recursion
  • Memoization
主站蜘蛛池模板: 紫金县| 博野县| 邛崃市| 崇礼县| 镇宁| 余姚市| 孝感市| 大连市| 兴仁县| 柘荣县| 墨江| 濮阳市| 新竹县| 遂平县| 凉山| 荔波县| 包头市| 铜鼓县| 大荔县| 大田县| 泰兴市| 工布江达县| 祁东县| 延庆县| 丽水市| 乌恰县| 陕西省| 石嘴山市| 泉州市| 喀喇沁旗| 寿光市| 巫溪县| 南部县| 海阳市| 东乌珠穆沁旗| 林口县| 万安县| 嘉鱼县| 大田县| 五家渠市| 玛多县|