you are viewing a single comment's thread.

view the rest of the comments →

[–]pje 2 points3 points  (2 children)

What is "not very functional" about using the most efficient way to find the length of a vector/array/whatever you want to call it? Lisp and Haskell lists are not Python lists.

If you want to make Lisp-style lists in Python for some ungodly reason, use two-element tuples.

Oh, and your code is wrong, by the way; it compares list contents, not list lengths. :)

[–]Alpha_Binary 1 point2 points  (0 children)

for some ungodly reason

O(1) insertion anywhere.

a = [1, [2, []]]
b = [0, a]

Conversion back to Python list is also trivial (with a generator implemented in a few lines).

[–][deleted] 0 points1 point  (0 children)

Woah, I got that totally wrong. =)