in reply to perl6 rational number problem
So the initial assignment is failing because "1" is not a Rat. That piece can be fixed, and re-tried:> my Rat @example = 1 , * ** 0.9999 ... Inf; [...] > @example[^4] Type check failed in assignment to @example; expected Rat but got Int in block <unit> at <unknown file>:1
A little further that time .. We successfully assigned "1" to @example[0], but that is all. The next element is a "Num", not a Rat, so the assignment failed.> my Rat @example = 1.0, * ** 0.9999 ... Inf; [...] > @example[^4] Type check failed in assignment to @example; expected Rat but got Num in block <unit> at <unknown file>:1 > @example[0] 1
If you use an increasing Rat sequence, it works:
> my Rat @example = 1.0, * += 0.9999 ... Inf; [...] > @example[^4] (1 1.9999 2.9998 3.9997)
All power corrupts, but we need electricity.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl6 rational number problem
by freakcoco (Sexton) on Nov 21, 2017 at 15:49 UTC | |
by Anonymous Monk on Nov 21, 2017 at 18:07 UTC |