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

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
主站蜘蛛池模板: 静海县| 英德市| 富锦市| 师宗县| 油尖旺区| 福海县| 彭州市| 四子王旗| 瑞昌市| 屏东县| 巴林右旗| 福贡县| 襄樊市| 鄯善县| 肇东市| 新兴县| 涞水县| 绵竹市| 西青区| 奉化市| 仁怀市| 旬邑县| 土默特右旗| 武胜县| 延寿县| 乐至县| 台南县| 博爱县| 和平区| 临江市| 铁力市| 闽清县| 徐水县| 丘北县| 文安县| 托克逊县| 巨鹿县| 横峰县| 鹰潭市| 伊宁县| 苍山县|