On Thu, Mar 27, 2014 at 4:32 AM, Rustom Mody <rustompm...@gmail.com> wrote:
> Now actual python
>
> def sumjensen(i_get, i_set,lower,upper,exp):
>     tot = 0
>     i_set(lower)
>     while i_get() <= upper:
>         tot += exp_get()
>         i_set(i_get() + 1)
>     return tot
>
>
> i=0
> a=[3,4,5]
> i_get = lambda : i
> def i_set(val):
>    global i
>    i = val
>
> exp_get = lambda : a[i_get()]
>
>
> call as sumjensen(i_get, i_set, lower, upper, exp_get)
>
> [Note that because of lambda's restriction to being only an expression
> I have to make it a def because of need for  global]

You prove here that Python has first-class expressions in the same way
that 80x86 assembly language has garbage collection. Sure, you can
implement it using the primitives you have, but that's not support.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to