Using map instead of iteration
Russel Winder
russel at russel.org.uk
Sun Mar 6 08:07:12 PST 2011
On Sun, 2011-03-06 at 14:57 +0100, Simen kjaeraas wrote:
[ . . . ]
> You should use std.range.iota(0,numberOfThreads) instead of
> 0..numberOfThreads. Having a..b return a general interval range
> has been proposed numerous times, but nothing has been implemented as
> of yet.
Thanks for this pointer.
> If you like syntactic sugar, this is likely the closest you'll get at
> this point:
>
> import std.range;
>
> struct _ {
> auto opSlice(B,E)(B begin, E end) {
> return iota(begin, end);
> }
> }
>
> // Example:
> map!foo( _[0..numberOfThreads] );
Interesting. I am not sure I would do this, instead just going with the
explicit iota.
It would be better though if x..y (and x..<y) were standard parts of the
syntax.
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at russel.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110306/203deaaf/attachment.pgp>
More information about the Digitalmars-d
mailing list