Skip Menu |
 

This queue is for tickets about the Scalar-List-Utils CPAN distribution.

Report information
The Basics
Id: 128237
Status: open
Priority: 0/
Queue: Scalar-List-Utils

People
Owner: Nobody in particular
Requestors: rvtol [...] isolution.nl
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: feature request: slide
Date: Sun, 13 Jan 2019 16:50:13 +0100
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: "Ruud H.G. van Tol" <rvtol [...] isolution.nl>
Download (untitled) / with headers
text/plain 461b
sub slide (&@) { # like reduce, but returns intermediate values my $f = shift; my $v0= shift; @_ or return $v0; my $pkg= caller; my $a= $v0; no strict 'refs'; local *{"$pkg\::a"} = \$a; my $glob_b= \*{"$pkg\::b"}; $v0, map { my $b= $_; local *$glob_b= \$b; local $_; $a= $f->(); } @_; } Example: my $e= 1+ sum slide { $a / $b } 1..19; # 2.71828182845905 -- Ruud
Download (untitled) / with headers
text/plain 454b
On Sun Jan 13 10:50:26 2019, rvtol@isolution.nl wrote: Show quoted text
> > sub slide (&@) { > # like reduce, but returns intermediate values
Yes; I've on occasion wanted a function to do exactly this. But I wonder about the name - where does "slide" come from? A more transparent name might be sub reduce_with_intermediates though that is ugly and long. I agree with the behaviour, just not so sure about the name - can we find a better one? -- Paul Evans
Subject: Re: [rt.cpan.org #128237] feature request: slide
Date: Mon, 14 Jan 2019 10:22:19 +0100
To: bug-Scalar-List-Utils [...] rt.cpan.org
From: "Ruud H.G. van Tol" <rvtol [...] isolution.nl>
Download (untitled) / with headers
text/plain 796b
On 2019-01-14 00:03, Paul Evans via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=128237 > > On Sun Jan 13 10:50:26 2019, rvtol@isolution.nl wrote:
Show quoted text
>> sub slide (&@) { >> # like reduce, but returns intermediate values
> > Yes; I've on occasion wanted a function to do exactly this. But I wonder about the name - where does "slide" come from?
It was inspired on a dance move. (Hip Hop, the Slide Step). Show quoted text
> A more transparent name might be > > sub reduce_with_intermediates > > though that is ugly and long. I agree with the behaviour, just not so sure about the name - can we find a better one?
We should be able to find a better one. :) In Clojure it is called 'reductions'. http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/reductions -- Ruud


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.