March 30, 2015
On 3/30/2015 5:04 AM, Laeeth Isharc wrote:
> when this happens, it would be great if the person could post to the group a few
> lines about it so someone (possibly someone else) can collate into a future
> series on gems in phobos.  maybe give subject some consistent name so it is easy
> to find them later.


Even Andrei, who wrote most of std.algorithm, posted here recently how he was surprised at how powerful it was.
March 30, 2015
On Mon, 2015-03-30 at 11:19 -0700, Walter Bright via Digitalmars-d-announce wrote:
> […]
> 
> My brain still thinks in terms of loops.

The excellent influence of functional programming on imperative programming is implicit iteration and higher-order functions.

Any explicit for/while loop in a modern imperative language code should *necessarily* involve a side-effect or it is coded wrongly. Even then it can almost certainly be recast to preserve the side- effect and remove the loop – unless you are implementing the implicit iteration function.

This has nothing to do with tail recursion optimization and all that Lambda Calculus stuff, this is to do with correct levels of abstraction that allow the tool chain to maximize support for the programmer.

Java programmers are having to come to terms with this. Python programmers sort of have, except that BDFL has failed to accept the correct end point and still likes loops. Scala has done it all wrong. (Further opinions available on request :-)

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


March 30, 2015
On Mon, 2015-03-30 at 11:20 -0700, Walter Bright via Digitalmars-d-announce wrote:
> 
[…]
> Even Andrei, who wrote most of std.algorithm, posted here recently how he was surprised at how powerful it was.

An indicator of plagiarism? ;-)

-- 
Russel. ============================================================================= Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net 41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


March 30, 2015
On Monday, 30 March 2015 at 12:04:22 UTC, Laeeth Isharc wrote:
> On Monday, 30 March 2015 at 07:29:56 UTC, Jonathan M Davis wrote:
>> On Saturday, March 28, 2015 14:19:46 Walter Bright via Digitalmars-d-announce wrote:
>>> Thank you. I need to learn std.algorithm better.
>>
>> Don't we all. Part of the problem with std.algorithm is its power. It's
>> frequently the case that you think that something isn't there when it's
>> either there under a different name, or you just have to look at one of its
>> functions from a different angle to use it for what you're trying to do. It
>> wouldn't surprise me at all if folks who know it quite well get surprised by
>> what it can do at least from time to time.
>>
>> - Jonathan M Davis
>
> when this happens, it would be great if the person could post to the group a few lines about it so someone (possibly someone else) can collate into a future series on gems in phobos.  maybe give subject some consistent name so it is easy to find them later.


I regularly review std.algorithm just because I'm not used to functional programming, it has so many useful things.
March 30, 2015
On Monday, 30 March 2015 at 18:41:17 UTC, Russel Winder wrote:
> On Mon, 2015-03-30 at 11:19 -0700, Walter Bright via Digitalmars-d-announce wrote:
>> […]
>> 
>> My brain still thinks in terms of loops.
>
> The excellent influence of functional programming on imperative
> programming is implicit iteration and higher-order functions.
>
> Any explicit for/while loop in a modern imperative language code
> should *necessarily* involve a side-effect or it is coded wrongly.
> Even then it can almost certainly be recast to preserve the side-
> effect and remove the loop – unless you are implementing the implicit
> iteration function.
>
> This has nothing to do with tail recursion optimization and all that
> Lambda Calculus stuff, this is to do with correct levels of
> abstraction that allow the tool chain to maximize support for the
> programmer.
>
> Java programmers are having to come to terms with this. Python
> programmers sort of have, except that BDFL has failed to accept the
> correct end point and still likes loops. Scala has done it all wrong.
> (Further opinions available on request :-)

speaking of optimization, are there any guarantees(documented?) on the kind of optimizations you should expect from range programming in D(i.e, function chaining) similar to Haskell's stream fusion?
March 30, 2015
On 3/30/2015 11:41 AM, Russel Winder via Digitalmars-d-announce wrote:
> Java programmers are having to come to terms with this. Python
> programmers sort of have, except that BDFL has failed to accept the
> correct end point and still likes loops. Scala has done it all wrong.
> (Further opinions available on request :-)

I always enjoy your posts, Russel! ... opinionated posts backed by experience.

March 30, 2015
On 3/30/2015 11:53 AM, weaselcat wrote:
> speaking of optimization, are there any guarantees(documented?) on the kind of
> optimizations you should expect from range programming in D(i.e, function
> chaining) similar to Haskell's stream fusion?

No. It's a QoI issue.
March 31, 2015
On 3/30/15 12:29 AM, Jonathan M Davis via Digitalmars-d-announce wrote:
> On Saturday, March 28, 2015 14:19:46 Walter Bright via Digitalmars-d-announce wrote:
>> Thank you. I need to learn std.algorithm better.
>
> Don't we all. Part of the problem with std.algorithm is its power. It's
> frequently the case that you think that something isn't there when it's
> either there under a different name, or you just have to look at one of its
> functions from a different angle to use it for what you're trying to do. It
> wouldn't surprise me at all if folks who know it quite well get surprised by
> what it can do at least from time to time.

Then we need more examples and tutorials. -- Andrei

March 31, 2015
On Monday, 30 March 2015 at 18:20:39 UTC, Walter Bright wrote:
> Well put.
>
> My brain still thinks in terms of loops.

Sadly, mine also... ;-P
March 31, 2015
On Tuesday, 31 March 2015 at 02:05:05 UTC, Andrei Alexandrescu wrote:
> On 3/30/15 12:29 AM, Jonathan M Davis via Digitalmars-d-announce wrote:
>> On Saturday, March 28, 2015 14:19:46 Walter Bright via Digitalmars-d-announce wrote:
>>> Thank you. I need to learn std.algorithm better.
>>
>> Don't we all. Part of the problem with std.algorithm is its power. It's
>> frequently the case that you think that something isn't there when it's
>> either there under a different name, or you just have to look at one of its
>> functions from a different angle to use it for what you're trying to do. It
>> wouldn't surprise me at all if folks who know it quite well get surprised by
>> what it can do at least from time to time.
>
> Then we need more examples and tutorials. -- Andrei

how are these to appear?