用表格查找代替功能 [英] Replacing functions with Table Lookups

查看:123
本文介绍了用表格查找代替功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在观看此MSDN视频与Brian Beckman合作,我想更好地理解他所说的一些话: b
$ b


每个不具有挑战性的程序员都要经历这个阶段的学习
函数可以被表查找替换
$ /
$ b现在,我是一个从未上过大学的C#程序员,所以或许我错过了其他人学会了解的东西。



Brian是什么意思:



< blockquote>

函数可以替换为表查找


是否有这样做的实际例子,适用于所有功能?他给出了sin函数的例子,我可以理解这个例子,但是我怎么用更一般的术语来理解这个呢?

解决方案
y = f(x)是集合{x}到集合{y}的映射: F:X-> Y 。这些表格也是映射: [x1,x2,...,xn] - > [y1,y2,...,yn]



如果函数在有限集上运行(这是编程中的情况)可以用代表该映射的表代替。正如Brian所提到的,每个命令程序员都要经历这一阶段的理解,即出于性能原因,函数可以替换为表查找。



但并不意味着全部功能很容易可以或应该被替换为表格。这只意味着你理论上可以为每个功能做到这一点。因此,结论是这些函数是数据,因为表是(在编程过程中)。

I've been watching this MSDN video with Brian Beckman and I'd like to better understand something he says:

Every imperitive programmer goes through this phase of learning that functions can be replaced with table lookups

Now, I'm a C# programmer who never went to university, so perhaps somewhere along the line I missed out on something everyone else learned to understand.

What does Brian mean by:

functions can be replaced with table lookups

Are there practical examples of this being done and does it apply to all functions? He gives the example of the sin function, which I can make sense of, but how do I make sense of this in more general terms?

解决方案

Brian just has showed that functions are data too. Functions in general are just a mapping of one set to another: y = f(x) is mapping of set {x} to set {y}: f:X->Y. The tables are mappings as well: [x1, x2, ..., xn] -> [y1, y2, ..., yn].

If function operates on finite set (this is the case in programming) then it's can be replaced with a table which represents that mapping. As Brian mentioned every imperative programmer goes through this phase of understanding that the functions can be replaced with the table lookups just for performance reason.

But it doesn't mean that all functions easily can or should be replaced with the tables. It only means that you theoretically can do that for every function. So the conclusion would be that the functions are data because tables are (in the context of programming of course).

这篇关于用表格查找代替功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆