Re: Constructing a number from digits in an arbitrary base

2020-11-02 Thread Brad Gilbert
I believe this is what you were looking for sum 46, 20, 26, 87, 11 Z* (1, 101, 101² … *) sum 1234567890.polymod(101 xx *) Z* (1, 101, 101² … *) On Mon, Nov 2, 2020 at 2:12 PM Sean McAfee wrote: > On Fri, Oct 30, 2020 at 2:19 PM Elizabeth Mattijsen > wrote: > >> > On 30 Oct 2020, at 22

Re: Constructing a number from digits in an arbitrary base

2020-11-02 Thread Sean McAfee
On Fri, Oct 30, 2020 at 2:19 PM Elizabeth Mattijsen wrote: > > On 30 Oct 2020, at 22:11, Sean McAfee wrote: > > With polymod, I can get the values of digits even in large bases like > 101: > > > > > 1234567890.polymod(101 xx *) > > (46 20 26 87 11) > > > > Given a list of digit values li

Re: Constructing a number from digits in an arbitrary base

2020-10-30 Thread yary
> So you'd basically need a sub that takes a List, and a base factor, and does the necessary arithmetic for you. I don't think that's in core. If that were to exist, would that be an inverse of "polymod"- maybe "polymul"? - with this property @decomposed-num = $some_number.polymod(@a-sequence) i

Re: Constructing a number from digits in an arbitrary base

2020-10-30 Thread Sean McAfee
On Fri, Oct 30, 2020 at 2:19 PM Elizabeth Mattijsen wrote: > > On 30 Oct 2020, at 22:11, Sean McAfee wrote: > > > sum <46 20 26 87 11> Z* (1, * * 101 ... *) > > 123456789 > > > > ...but I'm hoping there's something more concise, shorter, and/or > readable. > > Ah, so it's not about parsi

Re: Constructing a number from digits in an arbitrary base

2020-10-30 Thread Bruce Gray
> On Oct 30, 2020, at 3:25 PM, Sean McAfee wrote: > > I want to construct a number from its digits in some arbitrary base. That > is, to essentially do the inverse of this kind of polymod call: > > my @digits = $number.polymod($base xx *); > > I have a nagging feeling that I've seen a

Re: Constructing a number from digits in an arbitrary base

2020-10-30 Thread Elizabeth Mattijsen
> On 30 Oct 2020, at 22:11, Sean McAfee wrote: > > Sorry, it seems I wasn't explicit enough. > > With polymod, I can get the values of digits even in large bases like 101: > > > 1234567890.polymod(101 xx *) > (46 20 26 87 11) > > Given a list of digit values like that, and the base, I

Re: Constructing a number from digits in an arbitrary base

2020-10-30 Thread Sean McAfee
Sorry, it seems I wasn't explicit enough. With polymod, I can get the values of digits even in large bases like 101: > 1234567890.polymod(101 xx *) (46 20 26 87 11) Given a list of digit values like that, and the base, I want to reconstruct the original number. One way would be the one

Re: Constructing a number from digits in an arbitrary base

2020-10-30 Thread Elizabeth Mattijsen
$ raku -e 'dd "g".parse-base(17)' 16 > On 30 Oct 2020, at 21:25, Sean McAfee wrote: > > I want to construct a number from its digits in some arbitrary base. That > is, to essentially do the inverse of this kind of polymod call: > > my @digits = $number.polymod($base xx *); > > I have a n