[Issue 9550] New: Repeat!fun(size_t n)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 19 23:45:52 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9550
Summary: Repeat!fun(size_t n)
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: daniel350 at bigpond.com
--- Comment #0 from Daniel Cousens <daniel350 at bigpond.com> 2013-02-19 23:45:50 PST ---
Unless I'm missing something, after several separate discussions on the D IRC,
I could not find a way to run a function 'n' times lazily for a range without
doing hackery's like this:
iota(100).map!(x => uniform(0, 76));
The use case is where you want to repeat an (impure) function n times lazily.
A possible example:
auto five_random_ints = take(recurrence!(uniform!int), 5)
or
auto five_random_ints = repeat!(uniform!int)(5);
If there is an idiomatic way to do this already that I am missing, sorry for
taking up your time.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list