Re: How to implement function like this?

2007-10-23 Thread Loic Mahe
even shorter: def funcA(tarray): s = min(len(tarray), 3) return [2, 3, 4][0:s] + [e for e in funcB(3-s)[0:3-s]] -- http://mail.python.org/mailman/listinfo/python-list

Re: How to implement function like this?

2007-10-23 Thread Loic Mahe
Marc 'BlackJack' Rintsch a écrit : > On Tue, 23 Oct 2007 11:48:08 +0200, Loic Mahe wrote: > >> even shorter: >> >> def funcA(tarray): >> s = min(len(tarray), 3) >> return [2, 3, 4][0:s] + [e for e in funcB(3-s)[0:3-s]] > > Why the lis

Re: Some "pythonic" suggestions for Python

2007-11-09 Thread Loic Mahe
Frank Samuelson a écrit : > foo = function(x,y) x+y*2 # Example S language code > bar = foo > bar(3,4) > m = lapply( s, foo ) > bb = lapply(s, function(t) t[3]*4 ) Here you want all functions to be lambda functions: you can get something very close to what you want, just like this: foo = lambd

Re: Some "pythonic" suggestions for Python

2007-11-12 Thread Loic Mahe
Chris M write : > Multi-return value lambda? Just so you know, there is no concept of > returning more than one value from a function. I wrote: > * multi return value lambda I meant: multiple return statement, not return multiple values pseudo code here: lambda x: if A return B, if C return D,

Re: Equivalent of TCL's "subst" ?

2007-11-14 Thread Loic Mahe
gamename a écrit : > Hi, > > In TCL, you can do things like: > set foobar "HI!" > set x foo > set y bar > subst $$x$y > HI! > > Is there a way to do this type of evaluation in python? > > TIA, > -T > you can also try using eval: >>> foobar = "HI!" >>> x = 'foo' >>> y = 'bar' >>> print eva

Re: Convert some Python code to C++

2007-11-14 Thread Loic Mahe
[EMAIL PROTECTED] a écrit : > For those that understand algorithms and can talk Python, I want to > convert the Python code in the section "Reading out all LCSs" into C++ > code but I don't understand some of the syntax. Can anyone give me a > hand? > > def backTrackAll(C, X, Y, i, j): > if i