質問

In a Wikipedia article about CPS there is the following code snippet, ostensibly from Scheme:

(define (pyth& x y k)
 (*& x x (lambda (x2)
          (*& y y (lambda (y2)
                   (+& x2 y2 (lambda (x2py2)
                              (sqrt& x2py2 k))))))))

I cannot find any other examples, or an explanation for the usages of "pyth&", "*&", and "+&". Much Googling has turned up only that there are other forms such as "=&" and "/&".

役に立ちましたか?

解決

Those are just function names, pyth& is the CPS pythagoras procedure, *& is a CPS multiplication procedure and +& is a CPS addition procedure, different from their usual counterparts because they receive a continuation in the last parameter, the & at the end is simply a naming convention to remind you of this, which is stated at the beginning of the linked paragraph:

In CPS, each procedure takes an extra argument representing what should be done with the result the function is calculating

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top