Complexity of splits
phil hunt
philh at cabalamat.org
Mon May 12 20:15:01 EDT 2003
On Mon, 12 May 2003 15:57:02 +0200, Jean-Guillaume Pyraksos <jeapy at free.fr> wrote:
>As I am digging into my Python studies, I started translating some
>elementary Lisp recursive algorithms...
>
>def length(L):
> if not(L):
> return 0
> return 1 + length(L[1:len(L)])
It seems a bit silly to call the built-in length-of-list function
when writing your own. Better is:
def length(L):
if not(L):
return 0
return 1 + length(L[1:])
--
Philip Hunt <philh at cabalamat.org>
Interested in adventure holidays in Spain?
Look at: <http://www.cabalamat.org/advcon/>
More information about the Python-list
mailing list