Re: Questions on Using Python to Teach Data Structures and Algorithms



Some of your Lisp translations are subtly off...


Date: 28 Sep 2006 02:49:50 -0700
From: "sturlamolden" <sturlamolden@xxxxxxxx>
Subject: Re: Questions on Using Python to Teach Data Structures and
Algorithms
To: python-list@xxxxxxxxxx

If you want to make a chained structure, then perhaps you know LISP?
This is what the basic machinery of LISP looks like in Python:

def cons(a,b)
return [a,b]

should be:
return [a].extend(b)

def car(structure)
return structure[0]

def cdr(structure)
return structure[1]

should be:
return structure[1:]

B.

--
Brendon Towle, Ph.D. <Brendon@xxxxxxxxxxxxxxxx> +1-412-362-1530
“Debugging is twice as hard as writing the code in the first place. Therefore,
if you write the code as cleverly as possible, you are, by definition, not
smart enough to debug it.” – Brian W. Kernighan


.



Relevant Pages

  • Re: Questions on Using Python to Teach Data Structures and Algorithms
    ... Questions on Using Python to Teach Data Structures and ... If you want to make a chained structure, then perhaps you know LISP? ... Brendon Towle, PhD ...
    (comp.lang.python)
  • How to Write a Spelling Corrector
    ... Peter Norvig wrote a simple spelling corrector in 20 lines of Python 2.5; ... but the Lisp version is going to take me much longer due to ... def train features ...
    (comp.lang.lisp)
  • Re: Python and C
    ... Python, you can call the C functions in the DLL using ctypes. ... redefine some data structures from the header file, ... def unsignedArrayToHex: ...
    (comp.lang.python)
  • Re: Python and C
    ... Python, you can call the C functions in the DLL using ctypes. ... redefine some data structures from the header file, ... def unsignedArrayToHex: ...
    (comp.lang.python)
  • Re: Questions on Using Python to Teach Data Structures and Algorithms
    ... Questions on Using Python to Teach Data Structures and ... If you want to make a chained structure, then perhaps you know LISP? ... This is what the basic machinery of LISP looks like in Python: ...
    (comp.lang.python)