Note that there are some explanatory texts on larger screens.

plurals
  1. POA more elegant way for this python decorator
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COBe careful going too far with the Scheme analogies. You _can_ write anything recursively in Python, just as in Scheme… but Python doesn't have tail-call optimization, so you often don't want to. For a half-dozen levels of recursion, that's not a problem, but when you start thinking of recursive folding to map over a list of arbitrary length, you're probably doing it wrong.
      singulars
    2. CO@abarnert, so how do you deal with tree structures then? A list, contained within a list, which is in itself an embedded list and so on, the one of arbitrary depth? My solution for now: def tree_printer(a_tree): for item in a_tree: if type(item) is list or type(item) is tuple: tree_printer(item) else: print(item, end=' ')
      singulars
    3. COIn Scheme, if your trees are known to be not very deep, you can use naive recursion, but if they may be arbitrarily deep, you have to transform that into tail recursion. In Python, transforming to tail recursion doesn't help, so you instead have to transform into iterative code. (That's the most important difference, but not the only one. For example, Python has comprehensions, iterative map/filter/reduce, all the stuff in itertools, etc. to make it easier to write iterative code, so often, even when recursion would work, it's not the easiest way to do it.)
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload