如何在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
最满意答案
您正在推送
--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.
相关问答
更多-
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')[2023-10-12]
正如@ 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: ... -
如果您查看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 proper ...
-
我发现了问题! 我没有对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 did ...
-
事实证明这是一个OAuth问题,我的计算机上的时钟比Twitter服务器的时间超过+/- 5分钟 ,因此出于授权原因,我一直收到HTTP 401错误。 修复:更改计算机的内部时钟以匹配Twitter的内部时钟或更改OAuth时间戳调用。 在python twitter工具的存储库问题中发现的问题 此外,供您参考, OAuth故障排除 - 大约第8点关于时间戳的讨论。 Turns out it was an OAuth problem, my clock on my computer was more tha ...
-
问题解决了。 这是修改后的代码: protected Integer doInBackground(Integer... params) { try { DefaultHttpClient client = new DefaultHttpClient(); OAuthConsumer consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); ...
-
您现在必须在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 reme ...
-
我现在解决了这个问题,TL; DR:我需要检查我在应用程序管理面板中匹配的应用程序和用户访问级别,并重新生成我的访问令牌/密码。 我收到一封HTTP401回应,说'未经授权'。 通过将此与API错误代码和响应文档进行比较,我发现这必须是“缺少或不正确的身份验证凭据”。 我仔细检查了我的应用程序的“应用程序管理”面板,以检查我是否正确复制了密钥/令牌/机密,但也查看是否有其他差异。 我注意到我的应用程序访问级别被设置为'读取和写入',但是我的用户的访问令牌访问级别仅设置为'读取'。 通过在该页面上重新生成Ac ...
-
我的主要问题是我没有完全阅读文档! 虽然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/statuses/u ...
-
您正在推送--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 ...