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

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
主站蜘蛛池模板: 宁阳县| 从化市| 苏尼特右旗| 太仓市| 交口县| 平遥县| 广德县| 寻甸| 嘉峪关市| 儋州市| 克山县| 色达县| 东辽县| 巴塘县| 棋牌| 全南县| 保德县| 临桂县| 南涧| 阳曲县| 垫江县| 信阳市| 榕江县| 威信县| 奈曼旗| 大洼县| 蒙阴县| 乐昌市| 洞口县| 天全县| 基隆市| 永仁县| 昌宁县| 万年县| 德化县| 宁武县| 射洪县| 兴仁县| 海口市| 日照市| 临汾市|