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

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
主站蜘蛛池模板: 罗平县| 丹棱县| 胶州市| 外汇| 密山市| 砚山县| 图们市| 普定县| 南昌市| 永寿县| 阿巴嘎旗| 延吉市| 南木林县| 乌拉特前旗| 察哈| 巴彦县| 慈溪市| 华池县| 武冈市| 榆中县| 永善县| 黄山市| 张家港市| 乐至县| 秦皇岛市| 新乐市| 高碑店市| 衡阳市| 建阳市| 顺昌县| 平乡县| 宁城县| 昌都县| 临夏市| 丹寨县| 柳河县| 天等县| 平遥县| 邻水| 宜城市| 开阳县|