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

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
主站蜘蛛池模板: 云安县| 株洲县| 长兴县| 巩义市| 西平县| 天柱县| 宿松县| 凤阳县| 寻乌县| 洛扎县| 南皮县| 安图县| 郧西县| 株洲县| 台东县| 上饶市| 威宁| 辉县市| 抚宁县| 宜都市| 铜山县| 蓝田县| 霍山县| 甘谷县| 米易县| 普兰县| 齐齐哈尔市| 建昌县| 宿迁市| 临沭县| 安义县| 木兰县| 方正县| 搜索| 阜康市| 高清| 灵丘县| 白银市| 长治县| 浠水县| 婺源县|