Re: Questions on Using Python to Teach Data Structures and Algorithms
- From: "MonkeeSage" <MonkeeSage@xxxxxxxxx>
- Date: 28 Sep 2006 09:42:36 -0700
Bruno Desthuilliers wrote:
Brendon Towle wrote:
Some of your Lisp translations are subtly off...
Seems correct to me. Lisp lists are linked lists, not arrays.
Actually, Brendon was correct. In lisp / scheme:
(cons 1 '(2 3)) -> (1 2 3)
(car '(1 2 3)) -> 1
(cdr '(1 2 3)) -> (2 3)
But Brendon's code also needs a correction: [a].extend(b) is wrong,
because extend is in-place and returns None, and [a] is anonymous...it
needs to be something like:
def cons(a, b):
b.insert(0, a)
return b
Regards,
Jordan
.
- References:
- Re: Questions on Using Python to Teach Data Structures and Algorithms
- From: Brendon Towle
- Re: Questions on Using Python to Teach Data Structures and Algorithms
- From: Bruno Desthuilliers
- Re: Questions on Using Python to Teach Data Structures and Algorithms
- Prev by Date: Re: XSLT speed comparisons
- Next by Date: Re: License / Registration key enabled software
- Previous by thread: Re: Questions on Using Python to Teach Data Structures and Algorithms
- Next by thread: Re: Questions on Using Python to Teach Data Structures and Algorithms
- Index(es):
Relevant Pages
|