Re: Generalized slicing and a question on lambdas

Ulf Bartelt (stub@pce60.rz.tu-clausthal.de)
17 Sep 1994 10:19:00 GMT

Anton Hartl (hartl@Informatik.TU-Muenchen.DE) wrote:
: * Generalized slicing, projection facility

: What about having a way to specify an arbitrary number of
: arbitrary elements of a sequence? E.g.

: sequence_object [ 4:2 ; 1 ; 1 ; 8 ]

: I came across that when I tried to extract just year and day from
: the call to localtime() (which yields a tuple year,month,day,... )
: and would have prefered to write

: year, month = localtime(time())[0;2]

: instead of

: x = localtime(time())
: year, month = x[0], x[2]

I like this idea but...
...ask Guido... ;-)

: * How is the syntax for calling a lambda expression with arguments?

: I.e. what is the python equivalent of the following Scheme expression?

: ((lambda (n) (+ n 1)) 10)

I donnow Scheme...

A guess: (lambda n: n+1)(10)

: I actually tried that in the context of converting a list to tuple
: and I tried to get something like that to work

: lambda l: l[0], l[1] ( [1, 2] )

(lambda l: (l[0],l[1]))([1,2])

Bye,
Ulf.

--
Ulf Bartelt | 2:2437/120.666@fidonet.org | bartelt@sun2.isaf.tu-clausthal.de
            |                            | stub@linux.rz.tu-clausthal.de