develooper Front page | perl.perl6.users | Postings from October 2021

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

Thread Previous | Thread Next
From:
ToddAndMargo via perl6-users
Date:
October 31, 2021 11:10
Subject:
Re: how do I turn a real into and array of Integers?
Message ID:
d03ac421-1aa4-bb45-e1eb-1b91597831bc@zoho.com
On 10/31/21 01:43, Shlomi Fish wrote:

> 
>> ("" ~ sqrt(2)).comb().grep(* ne ".").map(+*)
> (1 4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1)

Cool!

my Int @x = ("" ~ sqrt(2)).comb().grep(* ne ".").map(+*)
[1 4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1]

Is there a way to set how many digits I get?

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About