如何在Scheme中的列表中使用lambdas(How to use lambdas from a list in Scheme)

我在查找如何使用Scheme中列表中包含的lambda时遇到了一些麻烦。 例如,我有以下代码:

(define abc '((lambda (x) (* x x))))

我想从列表中取出第一个lambda并将其应用于某些数字。 这是我到目前为止:

(map (car abc) '(1 2 3))

但是,我收到以下错误:

;The object (lambda (x) (* x x)) is not applicable.

但是当我直接使用lambda尝试相同的东西时,它的工作原理是:

(map (lambda (x) (* x x)) '(1 2 3))
;Value 15: (1 4 9)

有人能帮我理解我做错了吗?


I'm having some trouble figuring out how to use lambdas that are contained within lists in Scheme. For example, I have the following code:

(define abc '((lambda (x) (* x x))))

I would like to take the first lambda from the list and apply it to some numbers. Here is what I have so far:

(map (car abc) '(1 2 3))

However, I get the following error:

;The object (lambda (x) (* x x)) is not applicable.

But when I try the same thing directly using just the lambda, it works:

(map (lambda (x) (* x x)) '(1 2 3))
;Value 15: (1 4 9)

Can someone help me understand what I am doing wrong?


原文:https://stackoverflow.com/questions/36808259
2022-11-15 15:11

满意答案

您正在推送--header-H参数下的所有内容。 逐个使用。 像这个:

-H "Authorization: OAuth"
-H "oauth_nonce: XXXXXXe8558d961bd398f1"
-H "oauth_timestamp: 1395304620"

Derp... server's system clock was out of sync (couple if minutes into ze future) so after setting it back to the here and now, requests are working again.

相关问答

更多

Twitter API simplexml_load_string停止工作(Twitter API simplexml_load_string stop working)

XML包含HTML实体。 © 在XML中无效。 作为一种解决方法,您可以在将文档交给SimpleXML之前对其进行预过滤: $xml = file_get_contents(...); $xml = strtr($xml, array_flip(array_diff( get_html_translation_table(HTML_ENTITIES), get_html_translation_table(HTML_SPECIALCHARS) ...

Python Tweepy for Twitter API返回'错误401:未授权'(Python Tweepy for Twitter API returns 'error 401 : Unauthorized')

正如@ advance512所述,我不得不再次登录才能解决此问题。 下面的一段代码实现了这个诀窍: auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) def limit_handled(cursor): while True: try: ...

我的Twitter php脚本停止工作了!(My Twitter php script stopped working!)

如果您查看http://en.wikipedia.org/wiki/List_of_HTTP_status_codes错误代码,它会返回错误代码400 Bad Request The request contains bad syntax or cannot be fulfilled. 这将与类的错误有关......但是如果不检查代码就很难看到。 ##确保你拥有该类的最新版本。## Solved. It was my hosting provider's fault. PHP was not p...

Twitter搜索API:通过HTTParty“未经授权”但通过Curl成功(Twitter search API: “Unauthorized” through HTTParty but successful via Curl)

我发现了问题! 我没有对HTTP请求中的查询参数进行百分比编码,就像我在创建签名时所做的那样。 请注意,我发送的查询字符串q=from:plindelauf&include_entities=true 。 这需要明确地是include_entities=true&q=from%3Aplindelauf 。 该死! I found the problem! I did not percent encode the query parameters in my HTTP request, like I...

麻烦通过Python Twitter工具授权Twitter Streaming API(Troubles authorizing Twitter Streaming API through Python Twitter Tools)

事实证明这是一个OAuth问题,我的计算机上的时钟比Twitter服务器的时间超过+/- 5分钟 ,因此出于授权原因,我一直收到HTTP 401错误。 修复:更改计算机的内部时钟以匹配Twitter的内部时钟或更改OAuth时间戳调用。 在python twitter工具的存储库问题中发现的问题 此外,供您参考, OAuth故障排除 - 大约第8点关于时间戳的讨论。 Turns out it was an OAuth problem, my clock on my computer was mor...

Twitter的直播API未经授权(android)(Twitter's live streaming API unauthorized(android))

问题解决了。 这是修改后的代码: protected Integer doInBackground(Integer... params) { try { DefaultHttpClient client = new DefaultHttpClient(); OAuthConsumer consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); ...

Twitter OAuth request_token停止工作(Twitter OAuth request_token stopped working)

您现在必须在URL中包含oauth版本号,否则它将回退到最旧版本(或者可能是最新版本,不记得)。 提供/oath/1.0/或/1.0/oauth/或者什么都解决了我的问题,因为我记得它(已经有一段时间了)。 Apperently you have to include the oauth version number in the URL now, or else it will fall back to the oldest version (or maybe the newest, can't...

Twitter返回未经授权的用户时间表,但不搜索(Twitter returns unauthorized for user timeline but not search)

我现在解决了这个问题,TL; DR:我需要检查我在应用程序管理面板中匹配的应用程序和用户访问级别,并重新生成我的访问令牌/密码。 我收到一封HTTP401回应,说'未经授权'。 通过将此与API错误代码和响应文档进行比较,我发现这必须是“缺少或不正确的身份验证凭据”。 我仔细检查了我的应用程序的“应用程序管理”面板,以检查我是否正确复制了密钥/令牌/机密,但也查看是否有其他差异。 我注意到我的应用程序访问级别被设置为'读取和写入',但是我的用户的访问令牌访问级别仅设置为'读取'。 通过在该页面上重...

tmhOauth twitter api停止使用update_with_media调用(tmhOauth twitter api stopped working with update_with_media call)

我的主要问题是我没有完全阅读文档! 虽然url从1到1.1已经足够了,但我没有看到update_with_media的新url,如文档中所述,是https://api.twitter.com/1.1/statuses/update_with_media.json ,即它是api而不是旧的上传子域。 所以,现在我的api调用看起来像这样,并且所有工作再次起作用: $code = $tmhOAuth->request('POST', 'https://api.twitter.com/1.1/statu...

Twitter API停止工作(未经授权)(Twitter API stopped working (Unauthorized))

您正在推送--header或-H参数下的所有内容。 逐个使用。 像这个: -H "Authorization: OAuth" -H "oauth_nonce: XXXXXXe8558d961bd398f1" -H "oauth_timestamp: 1395304620" Derp... server's system clock was out of sync (couple if minutes into ze future) so after setting it back to the ...

相关文章

更多

Python 列表(list)操作

列表就像java里的collection,所具有的特性也要比元组更多,更灵活,其character总结 ...

FreeMarker集合(List、Map)

我们上一节认识了FreeMarker基本数据类型,接口认识FreeMarker集合(List、Map) ...

A Great List of Windows Tools

Windowsis an extremely effective and a an efficient ...

Become a Master Designer: Rule Three: Contrast, Contrast, Contrast

Part Three of Seven Easy Principles to Becoming a M ...

源码解读Mybatis List列表In查询实现的注意事项

源码解读Mybatis List列表In查询实现的注意事项 在SQL开发过程中,动 ...

Solr4.2迁移到新项目下异常:java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.

由于业务调整,需要将solr搜索项目集成到另一个项目下成为一个模块,原项目运行异常,但是迁移到新项目后 ...

Map、List集合类的清空使用clear还是重新new呢

各位有经验的Javaer,请问使用Map、List这种集合类做缓存时,需要 每天清空一次数据,那么我是 ...

hibernate 对list修改

class A{ private String a; private String b; pri ...

List用完后需要赋null吗

从数据库查询N条记录放在List集合中,然后通过request对象返回给页面,通过循环遍历将List中 ...

java List排序一

java List对象排序有多种方法,下面是其中两种 第一种方法,list中的对象实现Comparab ...

最新问答

更多

您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)

将diff文件复制到存储库的根目录,然后执行以下操作: git apply yourcoworkers.diff 有关apply命令的更多信息, apply 见其手册页 。 顺便说一下:一个更好的方法是通过文件交换整个提交文件是发送者上的命令git format-patch ,然后在接收器上加上git am ,因为它也传送作者信息和提交信息。 如果修补程序应用程序失败,并且生成diff的提交实际上在您的备份中,则可以使用尝试在更改中合并的apply程序的-3选项。 它还适用于Unix管道,如下

将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)

尝试将第二行更改为snprintf(buf1, sizeof buf1, "%.2f", balance1); 。 另外,为什么要声明用该特定表达式分配缓冲区的存储量? EDIT @LưuVĩnhPhúc在下面的评论中提到我的原始答案中的格式说明符将舍入而不是截断,因此根据如何在不使用C舍入的情况下截断小数,您可以执行以下操作: float balance = 200.56866; int tmp = balance1 * 100; float balance1 = tmp / 100.0; c

OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)

这是简单的解决方案 在你需要写的控制器中 BackendMenu::setContext('Archetypics.Team', 'website', 'team'); 请参阅https://octobercms.com/docs/backend/controllers-views-ajax#navigation-context BackendMenu::setContext('Author.Plugin name', 'Menu code', 'Sub menu code'); 你需要在r

页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)

每当发出请求时ASP都会创建一个新的Page对象,并且一旦它将响应发送回用户就不会保留对该Page对象的引用,因此只要你找不到某种方法来保持生命自己引用该Page对象后,一旦发送响应, Page和只能通过该页面访问的所有对象才有资格进行垃圾回收。 ASP creates a new Page object whenever a request is made, and it does not hold onto the reference to that Page object once it

codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)

要在生产服务器中调试这个,你可以临时放 error_reporting(E_ALL); 并查看有哪些其他错误阻止正确的重定向。 您还应该检查生产服务器发送的响应标头。 它是否具有“缓存”,是否需要重新验证标头等 to debug this in production server, you can temporary put error_reporting(E_ALL); and see what other errors are there that prevents the proper

在计算机拍照在哪里进入

打开娥的电脑.在下面找到视频设备点击进去就可以了...

使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)

你是对的。 第一次输入后,换行符将保留在输入缓冲区中。 第一次读取后尝试插入: cin.ignore(); // to ignore the newline character 或者更好的是: //discards all input in the standard input stream up to and including the first newline. cin.ignore(numeric_limits::max(), '\n'); 您必须为#inc

No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)

for (int k = 0; k > 10; k++) { System.out.println(k); } k不大于10,所以循环将永远不会执行。 我想要什么是k<10 ,不是吗? for (int k = 0; k < 10; k++) { System.out.println(k); } for (int k = 0; k > 10; k++) { System.out.println(k); } k is not greater than 10, so loop

单页应用程序:页面重新加载(Single Page Application: page reload)

优点是不注销会避免惹恼用户,以至于他们会想要杀死你:-)。 说真的,如果每次刷新页面时应用程序都会将我注销(或者在新选项卡中打开一个链接),我再也不会使用该应用程序了。 好吧,不要这样做。 确保身份验证令牌存储在刷新后的某个位置,即不在某些JS变量中,而是存储在cookie或本地存储中。 The advantage is that not logging off will avoid pissing off your users so much that they'll want to kill

在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)

EXECUTE IMMEDIATE 'SELECT '||field_val_temp ||' FROM tableb WHERE function_id = :func_val AND rec_key = :rec_key' INTO field_val USING 'STDCUSAC' , yu.rec_key; 和, EXECUTE IMMEDIATE 'UPDATE tablec SET field_val_'||i||' = :field_val' USI