F
Franck Ditter
Hi, I'm just wondering about the complexity of some Python operations
to mimic Lisp car and cdr in Python...
def length(L) :
if not L : return 0
return 1 + length(L[1:])
Should I think of the slice L[1:] as (cdr L) ? I mean, is the slice
a copy of a segment of L, or do I actually get a pointer to something
inside L ? Is the above function length O(n) or probably O(n^2) ?
Where are such implementation things (well) said ?
Thanks,
franck
to mimic Lisp car and cdr in Python...
def length(L) :
if not L : return 0
return 1 + length(L[1:])
Should I think of the slice L[1:] as (cdr L) ? I mean, is the slice
a copy of a segment of L, or do I actually get a pointer to something
inside L ? Is the above function length O(n) or probably O(n^2) ?
Where are such implementation things (well) said ?
Thanks,
franck