std.algorithm sort() and reverse() confusion
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jan 30 10:46:54 PST 2015
On 01/30/2015 09:55 AM, Jonathan M Davis via Digitalmars-d-learn wrote:
> sort returns a different type rather than the original type, and that
type
> indicates that its sorted, and some algoritms are able to take
advantage of
> that.
I covered that a little bit during DConf 2014, at around 4:30 minute
mark here:
http://www.youtube.com/watch?x-yt-cl=85114404&v=oF8K4-bieaw&feature=player_detailpage&x-yt-ts=1422579428#t=267
> there is no such benefit with reverse, so there's no need to
> return anything.
Still, returning the original range would help with chaining calls:
arr.reverse.map!sqrt
Side note: There is the confusion between the .reverse property of
arrays and std.algorithm.reverse. :-/
Ali
More information about the Digitalmars-d-learn
mailing list