首页 \ 问答 \ 在方案中使用多个lambda表示意味着什么?(What does the use of multiple lambdas in scheme mean?)

在方案中使用多个lambda表示意味着什么?(What does the use of multiple lambdas in scheme mean?)

我目前正在学习计划,并且我遇到了这些功能:

(define t (lambda (x) (lambda (y) x))) 
(define f (lambda (x) (lambda (y) y))) 

显然它们是作为功能的真假的表示。 我不知道为什么!

我有两个问题:

1)连续的lambda表示什么意思? 我只习惯看到一个用来传递参数给函数的lambda函数; 即

(define add
  (lambda (x y)
    (+ x y)))

并通过调用(add 1 5)我将提供6作为输出。

2)如何使用这些真假功能?


I am currently learning scheme and I came across these functions:

(define t (lambda (x) (lambda (y) x))) 
(define f (lambda (x) (lambda (y) y))) 

Apparently they are representations of true and false as functions. I have no idea why!

I have two questions:

1) What do the successive lambdas mean? I am only used to seeing a single lambda which is used to pass arguments to a function; i.e.

(define add
  (lambda (x y)
    (+ x y)))

And by calling (add 1 5) I would be provided with 6 as output.

2) How would these true and false functions be used?


原文:https://stackoverflow.com/questions/14145789
更新时间:2023-09-01 20:09

最满意答案

您无法获得对该asp:Content的引用的原因asp:Content控制是因为它在页面与主页面结合时不会停留。 基本上,ASP从这些asp:Content部分中获取所有控件,并使它们成为ContentPlaceholder内的ContentPlaceholder控件的子项。

正如MSDN所说: 在运行时不会将内容控件添加到控件层次结构中。 相反,内容控件中的内容直接合并到相应的ContentPlaceHolder控件中。

这意味着如果您想要为该部分添加更多控件,则必须在主页面中引用ContentPlaceholder控件并将其添加到该控件中。 就像是:

ContentPlaceHolder myContent = (ContentPlaceHolder)this.Master.FindControl("ContentPlaceHolder1");
myContent.Controls.Add(??);

注意你正在使用ContentPlaceHolderID值,而不是asp:Content部分的ID


The reason you can't get a reference to that asp:Content control is because it does not stay around when the page is combined with the masterpage. Basically ASP takes all the controls from inside these asp:Content sections and makes them children of the ContentPlaceholder controls inside the masterpage.

As MSDN says: A Content control is not added to the control hierarchy at runtime. Instead, the contents within the Content control are directly merged into the corresponding ContentPlaceHolder control.

That means that if you want to add more controls to that section, you will have to get a reference to the ContentPlaceholder control in the masterpage and add them to it. Something like:

ContentPlaceHolder myContent = (ContentPlaceHolder)this.Master.FindControl("ContentPlaceHolder1");
myContent.Controls.Add(??);

Notice you are using the ContentPlaceHolderID value, NOT the ID of the asp:Content section.

相关问答

更多