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:
Andinus via perl6-users
Date:
October 31, 2021 16:08
Subject:
Re: how do I turn a real into and array of Integers?
Message ID:
87ee81jhyf.fsf@cadmium.cadmium

ToddAndMargo via perl6-users @ 2021-10-30 23:57 -07:

> Without going into why (it is a secret), how do I turn
>
>> my $x = sqrt 2
> 1.4142135623730951
>
> into an array of integers?
> @y[0] = 1
> @y[1] = 4
> @y[2] = 1
> @y[3] = 4
> @y[4] = 2
> @y[5] = 1

    put 2.sqrt.comb.grep(*.Int)>>.Int[^10].raku # 10 digits

(1, 4, 1, 4, 2, 1, 3, 5, 6, 2)

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