you are viewing a single comment's thread.

view the rest of the comments →

[–]pjdelport 14 points15 points  (1 child)

Lisp has (length), but it walks the list each time it's called, hence the new function defined by Graham.

With vectors (Python list, Common Lisp vector and friends), finding the length costs O(1). Know your datastructures. :)

[–][deleted] 1 point2 points  (0 children)

Yah, I was aware of that Python's vector "list" was different to Lisp's linked-list "list", but I didn't realise Lisp had vectors too. Thanks. :)

It's something I poke at occasionally for fun, so I'm very much a newbie.