The problem with computing a radix using a non-imperative style of programming is you need to calculate a list of successive quotients, each new entry being the quotient of the last entry divided by the radix. The problem with this is (short of using despicable hacks like log) there is no way to know how many divisions an integer will take to reduce to 0.
I'm fine with doing this with a generator :
def rep_div(n,r): while n != 0: yield n n /= r
But I don't like this for some reason. I feel there must be a clever way of using a lambda, or some functional construction, without building a list like is done here :
def rep_div2(n,r): return reduce(lambda v,i: v+[v[-1]/r],question_mark,[n])
Once the repeated divisions can be generated radix is easy :
def radix2(n,r): return map(lambda ni: ni % r,(x for x in rep_div(n,r)))
So my question is : is it possible to rewrite
rep_div as a more concise functional construction, on one line?