English 中文(简体)
Lisp s application and fun打字
原标题:Lisp s apply and funcall vs Python s apply

Lisp s AppLY负责在名单上保留有计算依据的职能。 (摘自兰经评论)

例如,以下法典改动(清单1 2 3)至(+1 23)。

(apply # +  (1 2 3)) 

然而,除了某些细小的差别外(投入作为图/清单提供),Zahurys的申请确实适用。

(defun add (x y) (+ x y))
(funcall # add 1 2) 
or
(funcall # (lambda (x y) (+ x y)) 10 2)
apply(lambda x,y : x+y, [1,2])

你认为什么? Lisp s funrest和Adhurs之间是否有更大的差别?

最佳回答

难道有理由为什么斯图尔特选择这个名字,却不进行点名?

因为它是沙捞的,而不是LISP。 没有必要有相同的名称,fun calls<>t/code> 是LISP的指挥,apply是Salph中不同的。

apply is deprecated in-030, use the延用 syntax.

老年yn:

apply(foo, args, kwargs)

New syntax:

foo(*args, **kwargs)
问题回答

在共同列席<代码>(第1号(清单2 3 4))中,与<代码>(fun 1 (清单2 3 4)完全相同,而<代码>(适用编号1 fun 1(清单2 3 4))则意味着根据 fun的大小而有所不同。

* (defun bleargh (a &rest b) (cons a b))

BLEARGH
* (funcall # bleargh 1 (list 1 2 3))

(1 (1 2 3))
* (apply  # bleargh 1 (list 1 2 3))

(1 1 2 3)

因此,FUNCALL和APLY与过去一样,情况非常不同。

见附注:

。 改用“条码”和“条码”

移至py3k。

我看不出,为什么你要求Lisp sapply(<>>/code>将做任何与Sharma不同的事情。 这两项职能都具有职能和一份清单,然后将职能与清单要素作为理由。 ((+ 1 2 3)is an calls to +, with debate 1,2 and 3, isn t it?) 我看上去的是<条码> 适用 确实如此。

Lisp s和Ashhurc两种应用功能相同——鉴于功能 f和参数清单,p.适用于f。 唯一的区别是,沙尔的申请也接受关键词的词典。 在Lisp,这些内容将列入作为的参数清单:关键词论点。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...