一个函数,它返回一个将x添加到其参数的函数 [英] A function that returns a function that adds x to its argument

查看:80
本文介绍了一个函数,它返回一个将x添加到其参数的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JoS的一个帖子中,Quickie问道,


在C中编写一个函数,它返回一个函数,将x添加到它的

参数中。

http://discuss.fogcreek.com/joelonso...&ixPost=146457


这是我的理由。它编译,链接,但打印垃圾。所以它b / b
基本上没有做它应该做的事情。欢迎评论。

In a thread on JoS, Quickie asked,

"Write a function in C that returns a function that adds x to its
argument."

http://discuss.fogcreek.com/joelonso...&ixPost=146457

Here''s my go at it. It compiles, links, but prints junk. So it
basically doesn''t do what it was supposed to do. Comments welcome.

展开 | 选择 | Wrap | 行号

推荐答案

2004年6月10日18:09:28 - 0700, Vi **************** @ yahoo.com

(Sathyaish)写道:
On 10 Jun 2004 18:09:28 -0700, Vi****************@yahoo.com
(Sathyaish) wrote:
在一个关于JoS的帖子中,Quickie问,

;在C中编写一个函数,返回一个将x添加到其
参数的函数。

http://discuss.fogcreek.com/joelonso...&ixPost=146457

这是我的目标。它编译,链接,但打印垃圾。所以它基本上没有做它应该做的事情。欢迎评论。


如果语法错误,你怎么声称它编译?

In a thread on JoS, Quickie asked,

"Write a function in C that returns a function that adds x to its
argument."

http://discuss.fogcreek.com/joelonso...&ixPost=146457

Here''s my go at it. It compiles, links, but prints junk. So it
basically doesn''t do what it was supposed to do. Comments welcome.
How can you claim it compiles when it has a syntax error?

展开 | 选择 | 换行 | 行号

< br>

2004年6月10日18:09:28 -0700, Vi * ***************@yahoo.com

(Sathyaish)在comp.lang.c中写道:
On 10 Jun 2004 18:09:28 -0700, Vi****************@yahoo.com
(Sathyaish) wrote in comp.lang.c:
在JoS的一个帖子中,Quickie问,

在C中写一个函数,返回一个函数,将x添加到它的
参数中。
In a thread on JoS, Quickie asked,

"Write a function in C that returns a function that adds x to its
argument."




[snip]


这个q的作者uestion不知道C.不能用
返回C中的函数。


-

Jack Klein

主页: http://JK-Technology.Com

常见问题解答

comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html

comp.lang.c ++ http://www.parashift.com/c++-faq-lite/

alt.comp.lang.learn.c-c ++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html



[snip]

The author of this question is ignorant of C. It is not possible to
return a function in C.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html


Jack Klein写道:
Jack Klein wrote:
2004年6月10日18:09:28 -0700, Vi **************** @ yahoo.com
(Sathyaish)在comp.lang中写道。C :
On 10 Jun 2004 18:09:28 -0700, Vi****************@yahoo.com
(Sathyaish) wrote in comp.lang.c:
在JoS的一个帖子中,Quickie问,

在C中编写一个函数,返回一个向其添加x的函数
论证。
In a thread on JoS, Quickie asked,

"Write a function in C that returns a function that adds x to its
argument."



[snip]

这个问题的作者对C.一无所知。
返回一个函数是不可能的C。



[snip]

The author of this question is ignorant of C. It is not possible to
return a function in C.




你只是比作者更挑剔

函数和函数指针之间的区别。或许作者(或OP)

犯了错字。无论如何,你的挑剔让你可以避免实际和有趣的问题及其近乎变化的问题。那是

你的意图吗?


[我的答案是问题中的漏洞细节 - 显而易见的

一般问题有答案不在C,但有各种

限制表格可能会服务。]


-

Chris" Lisp ,Pop11,Smalltalk [ish]都可以做一般情况 Dollin

C常见问题解答: http://www.faqs.org/faqs/by-newsgrou...mp.lang.c.html

C欢迎: http://www.angelfire.com/ms3/bchambl...me_to_clc.html


这篇关于一个函数,它返回一个将x添加到其参数的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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