博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
函数式编程基础_函数式编程基础知识
阅读量:2523 次
发布时间:2019-05-11

本文共 2408 字,大约阅读时间需要 8 分钟。

函数式编程基础

功能编程 (Functional Programming)

Functional programming is the process of building software by composing pure functions, avoiding shared state, mutable data, and side-effects. Functional programming is declarative (telling the computer what you want to do) rather than imperative (telling the computer exactly how to do that), and application state flows through pure functions. Contrast it with object-oriented programming, where application state is usually shared and co-located with methods in objects.

函数式编程是通过组合纯函数 ,避免共享状态可变数据副作用来构建软件的过程。 函数式编程是声明性的 (告诉计算机您想做什么),而不是命令性的 (确切地告诉计算机如何执行操作),并且应用程序状态通过纯函数流动。 与面向对象编程相反,后者通常将应用程序状态与对象中的方法共享并放置在同一位置。

为什么要进行函数式编程? (Why Functional Programming?)

  • It’s generally more concise

    通常更简洁
  • It’s generally more predictable

    通常更可预测
  • It’s easier to test than object-oriented code

    比面向对象的代码更容易测试

通过编程语言采用 (Adoption by Programing Languages)

Many programming languages support functional programming like Haskell, F#, Common Lisp, Clojure, Erlang, OCaml. JavaScript also has the properties of an untyped functional language.

许多编程语言都支持功能编程,例如Haskell,F#,Common Lisp,Clojure,Erlang,OCaml。 JavaScript还具有非类型化功能语言的属性。

用途 (Uses)

Functional programming has long been popular in academia, but with few industrial applications. However, recently several prominent functional programming languages have been used in commercial or industrial systems. For example, the Erlang programming language, which was developed by the Swedish company Ericsson in the late 1980s, is used for building a range of applications at companies such as T-Mobile, Nortel, Facebook, Électricité de France and WhatsApp.

函数式编程在学术界很久以来一直很流行,但是很少有工业应用。 但是,最近在商业或工业系统中使用了几种著名的功能编程语言。 例如,由瑞典爱立信公司在1980年代后期开发的Erlang编程语言用于在T-Mobile,Nortel,Facebook,Électricitéde France和WhatsApp等公司构建一系列应用程序。

高阶函数 (Higher-Order Functions)

Higher-order functions are a big part of functional programming. A higher-order function is a function that either takes a function(s) as a parameter or returns a function.

高阶函数是函数编程的重要组成部分。 高阶函数是将一个或多个函数作为参数或返回一个函数的函数。

地图 (Map)

map is a higher-order function that calls a function to each element of a list, and returns the results as a new list.

map是一个高阶函数,它调用一个函数到列表的每个元素,并将结果作为列表返回。

Here is an example of map:

这是map的示例:

const myList = [6, 3, 5, 29];let squares = myList.map(num => num * num); // [36, 9, 25, 841]

有关函数式编程的更多信息: (More Information on Functional Programming:)

翻译自:

函数式编程基础

转载地址:http://jxzzd.baihongyu.com/

你可能感兴趣的文章
新生舞会
查看>>
c++实现单向链表的一些操作
查看>>
Vim中无法用Alt键来映射
查看>>
ubuntu硬件配置查看命令
查看>>
第十二周作业
查看>>
Javascript之UI线程与性能优化
查看>>
实现toggleClass功能
查看>>
设计Web2.0图--Aeromatex
查看>>
nginx动静分离配置
查看>>
jQuery 两种方法实现IE10以下浏览器的placeholder效果
查看>>
poj2253 最短路 floyd Frogger
查看>>
springboot:session集中存储到redis
查看>>
《Python编程快速上手+让繁琐工作自动化》第12章实践项目:空行插入程序
查看>>
POJ 2986 A Triangle and a Circle(三角形和圆形求交)
查看>>
css3最新技术教程
查看>>
【tool】测试驱动开发全攻略
查看>>
VIM命令图---可定制版
查看>>
《坐热板凳》第八次团队作业:Alpha冲刺(第三天)
查看>>
关于wxWidgets
查看>>
codevs 1160 蛇形矩阵
查看>>