18. 函数组合-结合律

1/27/2023 js

# 函数组合-结合律

  • 函数的组合要满足结合律
  • 我们既可以把 g 和 h组合,还可以把f和g组合,结果都是一样的
const _ = require('lodash')

// const f = _.flowRight( _.toUpper, _.first, _.reverse)
// 结合前两个函数
// const f = _.flowRight( _.flowRight(_.toUpper, _.first), _.reverse)
// 结合后两个函数
const f = _.flowRight( _.toUpper, _.flowRight(_.first, _.reverse))
console.log(f(['one', 'two', 'three']))  // THREE
1
2
3
4
5
6
7
8
最近更新时间: 2/4/2023, 10:01:08 AM
강남역 4번 출구
Plastic / Fallin` Dild