Re: Questions on Using Python to Teach Data Structures and Algorithms
- From: "sturlamolden" <sturlamolden@xxxxxxxx>
- Date: 28 Sep 2006 10:04:37 -0700
Brendon Towle wrote:
def cons(a,b)
return [a,b]
should be:
return [a].extend(b)
I seem to remember that a cons joins two items, it doesn't grow a
strait list. A lisp list is a special case of a binary tree. How would
you build a tree structure with your cons? I think you are wrong here.
def car(structure)
return structure[0]
def cdr(structure)
return structure[1]
should be:
return structure[1:]
With your cons yes. With mine no, as there is only two elements in each
array aka "cons cell".
.
- Follow-Ups:
- Re: Questions on Using Python to Teach Data Structures and Algorithms
- From: Fredrik Lundh
- Re: Questions on Using Python to Teach Data Structures and Algorithms
- 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
- Prev by Date: Re: Questions on Using Python to Teach Data Structures and Algorithms
- Next by Date: help tranlating perl expressions
- 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):