A mysterious way to see a difference in how the order of mixing operations with recursion matters is list construction.


Two List Constructions

F = [8,4,3,1,5]
def one(S):
  if len(S) > 0:
     return one(S[1:]) + [S[0]]
  else:
     return S
def two(S):
  if len(S) > 0:
     return [S[0]] + two(S[1:])
  else:
     return S
print one(F)
print two(F)


Though the difference seems quite small between one and two, the effect is significant. This example should be discussed and studied. What do you think is the simplest explanation of what is happening?