def qs4(ls): ''' And we can even take away the accum. Notice, however, the final comma, making the statement a tuple. ''' pivot = middle(ls) iff(len, (qs4, {_ < pivot}) + [pivot] + (qs4, {_ > pivot})),
def fib4(x): ''' And last but not least, we are enclosing this in a singleton tuple with no reference to x (note the , at the end). We can do this because the compiler infers that _ can only refer to x, since there are no other variables in the scope of the function. ''' iff(_ > 1, (fib4, _ - 1) + (fib4, _ - 2)),
def qs3(ls): ''' And we can also take away the call to p. ''' pivot = middle(ls) (ls, iff(len, (qs3, {_ < pivot}) + [pivot] + (qs3, {_ > pivot})))
def qs2(ls): ''' Now, we take away the return statement for space. ''' pivot = middle(ls) p(ls, iff(len, (qs2, {_ < pivot}) + [pivot] + (qs2, {_ > pivot})))
def fib1(x): ''' Here, however, we use the iff macro. So for a conditional fArg cond, and a statement, iff(cond,statement) evaluates as: {cond:statement, 'else':_} So, we only apply the sum to x if it's above 1. ''' return p(x, iff(_ > 1, (fib1, _ - 1) + (fib1, _ - 2)))
def qs1(ls): ''' Now, we are going to apply the iff macro. So for a conditional fArg cond, and a statement, iff(cond,statement) evaluates as: {cond:statement, 'else':_} . So, if len evaluates as True (nonzero), then we return the statement, otherwise we return the empty list. ''' pivot = middle(ls) return p(ls, iff(len, (qs1, {_ < pivot}) + [pivot] + (qs1, {_ > pivot})))
def fib3(x): ''' And now, we are even stripping out the pype call, which the compiler can handle. ''' (x, iff(_ > 1, (fib3, _ - 1) + (fib3, _ - 2)))
def fib2(x): ''' Now, we are stripping out the return statement, since the compiler includes it. ''' p(x, iff(_ > 1, (fib2, _ - 1) + (fib2, _ - 2)))