freeCodeCamp/guide/chinese/mathematics/what-is-a-function/index.md

13 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: What Is a Function
localeTitle: 什么是功能
---
## 什么是功能
函数在数学上被定义为一组数字到另一组的映射。例如`f(x) = x*2.`来自某个集合称为域的任何给定输入始终从该范围提供一个特定输出。在加倍函数中输入1,3和5映射到范围中的数字2,6和10这也是所有实数的集合。
相反编程中的“函数”更准确地称为某些语言中的方法或子例程是一种获取一个或多个值并输出一个或多个输出的方法。通常不能保证某些内部状态例如全局变量可以以这样的方式改变即f2可以一次为5或者当你再次运行时为10。在大多数允许的语言中甚至在某些情况下都是预期的但是某些使用_函数式编程的_语言在数学上将函数定义为函数因为没有状态变量可以改变并且具有不一致性从而提供更“可证明正确”的代码。
#### 更多信息:
功能语言: [Haskell](http://learnyouahaskell.com/chapters) [Clojure](https://clojure.org/)