|Bill Allombert on Thu, 18 Oct 2012 15:46:58 +0200|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|Re: reverse of digits()|
On Wed, Oct 17, 2012 at 09:01:08PM -0400, Mathieu Carbou wrote: > Hello, > > I've seen the new digits() and sumdigits() functions. I was wondering if > there was also the reverse function of digits (i.e. > vectonum([1,2,3,4,5], 10) == 12345) plus these functions which could be > useful ;-) Your function can be done in a single line of GP: vectonum(v,b=10)=subst(v,variable(v),b) For ndigits, you can use ndigits(n,b=10)=#ndigits(n,b) for the last one, this is related to mynumtoperm(n,a)=Vec(Vecsmall(numtoperm(n,a))^-1*vectorsmall(n,i,n+1-i)) Cheers, Bill.