Re: how do I turn a real into and array of Integers?

2021-11-01 Thread William Michels via perl6-users
Maybe my favorite example of the differential applications of `comb` vs `split`. Below, sometimes you want to precisely tease-apart text, and `comb` works towards that end. Other times you want to destructively blast-away at text--eliminating the destractions--so you use `split`, until you see the

Re: how do I turn a real into and array of Integers?

2021-11-01 Thread ToddAndMargo via perl6-users
On 11/1/21 19:07, Patrick R. Michaud wrote: If you want only the first 10 digits, then: How about if I want 64 or more digits?

Re: how do I turn a real into and array of Integers?

2021-11-01 Thread Patrick R. Michaud
This is a place where .comb() is likely much better than .split() -- .comb() allows you to specify what you're wanting instead of what you're wanting to avoid: $ raku -e "say sqrt(2).comb(/\d/).join(', ');" 1, 4, 1, 4, 2, 1, 3, 5, 6, 2, 3, 7, 3, 0, 9, 5, 1 If you want only the first 10 di

Re: how do I turn a real into and array of Integers?

2021-11-01 Thread William Michels via perl6-users
You did great for not knowing Raku! ~$ raku -e "say sqrt(2).split(/\.|''/);" ( 1 4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1 ) ~$ raku -e "say sqrt(2).split(/\.|''/).raku;" ("", "1", "", "4", "1", "4", "2", "1", "3", "5", "6", "2", "3", "7", "3", "0", "9", "5", "1", "").Seq ~$ raku -e "say sqrt(2).split(/\.|

Re: how do I turn a real into and array of Integers?

2021-11-01 Thread Sean McAfee
On Mon, Nov 1, 2021 at 1:53 AM sisyphus wrote: > Note that what you have there is a 200-decimal-digit (around 658-bit) > precision representation of the square root of 2 - which is quite different > to the (53-bit precision) Real sqrt(2). > Always gotta be careful with reals. I also attempted

Re: how do I turn a real into and array of Integers?

2021-11-01 Thread sisyphus
On Mon, Nov 1, 2021 at 2:35 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 10/31/21 19:39, Sean McAfee wrote: > > > (2.FatRat, { $_ / 2 + 1 / $_ } ... (* - *).abs < 1e-100).tail > > 1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534