Trivial (but not bikeshed please) question of style…

Russel Winder via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 28 10:57:07 PDT 2014


On Tue, 2014-10-28 at 13:44 -0400, Steven Schveighoffer via
Digitalmars-d wrote:
[…]
> If you are saying we should expect sort(arr) to return a *copy* of the 
> array that is sorted, I don't think that's a fair assessment of D user 
> expectations. D is not a functional language. Even D pure function can 
> mutate data.

Python's take on this works quite well:

	x.sort()

is a mutating sort delivering nothing, whilst:

	sorted(x)

created a new sorted item based on the data of x. In both case you can
give optional arguments to specify the sort key on the data in the
container and the direction of the sort.

-- 
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 winder.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: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141028/36418b1b/attachment.sig>


More information about the Digitalmars-d mailing list