Raku / problem-solving

🦋 Problem Solving, a repo for handling problems that require review, deliberation and possibly debate
Artistic License 2.0
70 stars 16 forks source link

Do we need an API method "SLICE", as extension to AT-POS? #441

Open lizmat opened 1 month ago

lizmat commented 1 month ago

Sometimes I feel the absence of a SLICE method, essentially doing:

method SLICE(@pos) { my @values; @values.push(self.AT-POS($_)) for @pos; @values } Making this part of the internal API, would allow for several optimizations, e.g. when working on fully reified lists / arrays and given a Range.

Moved from https://github.com/rakudo/rakudo/issues/1639

librasteve commented 1 month ago

while low level for many uses, i am a big fan of slice as an all encompassing low level api for lists, arrays and so on … definitely support this idea

0racle commented 1 month ago

Yes please. I've thought about supporting Array access on Noun objects in Inline::J, and a SLICE method that receives all the positions requested would be very useful.