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

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
主站蜘蛛池模板: 山阴县| 宣武区| 皮山县| 宜黄县| 岑溪市| 通江县| 新沂市| 灌云县| 道真| 枣阳市| 九江县| 鄂伦春自治旗| 两当县| 石城县| 西盟| 信阳市| 肃南| 咸宁市| 温泉县| 丹巴县| 博野县| 攀枝花市| 宾川县| 四会市| 新昌县| 封开县| 襄樊市| 祁门县| 建阳市| 永济市| 海淀区| 康定县| 焦作市| 金溪县| 安庆市| 嵊泗县| 黄浦区| 专栏| 鄢陵县| 东城区| 章丘市|