Continued in python

is there an equivalent construct for extensions in python. I read about the sequels, and I'm just curious and want to know, because there is nothing in the documents.

+3
source share
1 answer

my question is more on the line if extensions are supported in python, then how can they be expressed?

They are expressed in the same way in Python as in any other language, without call / cc : passing a function as an argument to continue another function. Consider a very silly continuation example that applies to the sum of two numbers. In ML you can write

fun plus(x, y, k) = k(x + y)

plus(2, 4, print o Int.toString)

which prints 6.

but in Python you can write

def plus(x, y, k):
    return k(x + y)

plus(2, 4, lambda n: print '%d' % n)

which also prints 6.

-1
source

All Articles