具有高阶函数的 Web 编程

发布于 2024-10-03 14:28:04 字数 166 浏览 9 评论 0原文

我们在课堂上学习高阶函数,我们的教授提到它们对于网络编程很有用。我不确定在什么情况下这是正确的,并且想知道是否有人在一些常见的 Web 编程任务中拥有高阶函数的经验,以及它们在什么情况下有用。

我读了我们的书,但没有提到网络编程,我想这只是教授提到的题外话,但这激发了我的兴趣。

谢谢!

We are learning higher-order functions in our class and our professor mentioned that they can be useful for web programming. I'm unsure as to what cases in which that would be true and was wondering if anyone had any experiences with higher-order functions in some common web programming tasks, and in what situations they would be useful.

I read through our book, but web programming wasn't mentioned, I suppose it was just something the professor mentioned off topic, but it sparked my interest a bit.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寻找我们的幸福 2024-10-10 14:28:04

我不太确定你的教授可能谈论的是哪些情况,但 JavaScript 中大量使用了高阶函数。高阶函数的一个简单示例(将函数作为参数和/或返回函数作为结果的函数)将是 jQuery read() 函数:

$(document).ready(function(){
    alert('The DOM is ready for manipulation!');
});

一个简单的示例,是的...但它演示了更高阶函数的有用性命令功能即可。

I'm not exactly sure which cases your professor might have been talking about, but higher order functions are used heavily in JavaScript. A simple example of a higher order function (a function taking a function as a parameter and/or returning a function as a result) would be the jQuery ready() function:

$(document).ready(function(){
    alert('The DOM is ready for manipulation!');
});

A simple example, yes...but it demonstrates how useful higher order functions can be.

生生不灭 2024-10-10 14:28:04

播放,(Scala) Lift (Scala) 、 SeaSide (Smalltalk) 和 Webmachine (< a href="http://bitbucket.org/justin/webmachine/wiki/Home" rel="nofollow">Erlang)
三个 Web 框架严重依赖函数理念,例如高阶函数。

Play, (Scala) Lift (Scala) , SeaSide (Smalltalk) and Webmachine (Erlang)
are three web frameworks the rely heavily on functional ideoms such as higher-order-functions.

冰火雁神 2024-10-10 14:28:04

Clojure 在优秀的 Ring 框架中广泛使用高阶函数进行 Web 开发。请观看这段出色的视频,其中解释了一些概念。

基本思想是:

  • Web 应用程序实际上只是一个将请求映射到响应的函数,
  • 因此您可以使用高阶函数组成整个 Web 应用程序

Clojure makes extensive use of higher order functions for web development in the excellent Ring framework. See this excellent video which explains some of the concepts.

The basic idea is:

  • A web application is really just a function that maps a request to a response
  • You can therefore compose the entire web application using higher order functions
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文