Help language development. Donate to The Perl Foundation
Array::Rounded - arrays that round indices while accessing elements
use Array::Rounded; my @a is Rounded = ^10; say @a[1.5]; # 2
Array::Rounded provides a subclass of Array
called Rounded
that will round non-integer indices on the array, rather than truncating them. Other than that, any arrays created with the Rounded
class will act as a normal Array
.
Because postcircumfix:<[ ]>
already intifies any non-integer value in current and possibly future versions of the Raku Programming Language, this module also exports some postcircumfix:<[ ]>
candidates to circumvent the premature intifications.
Also, due to some issues with native arrays, it has as yet been impossible to provide similar functionality for native arrays.
Elizabeth Mattijsen [email protected]
Source can be located at: https://github.com/lizmat/Array-Rounded . Comments and Pull Requests are welcome.
If you like this module, or what I’m doing more generally, committing to a small sponsorship would mean a great deal to me!
Copyright 2022 Elizabeth Mattijsen
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.