Functional Programming in D

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Oct 9 18:12:22 UTC 2019


On Wed, Oct 09, 2019 at 05:41:02PM +0000, Jonathan Gerlach via Digitalmars-d-learn wrote:
> On Wednesday, 9 October 2019 at 14:26:53 UTC, NonNull wrote:
> > Hello,
> > I want to become fluent in the use of functional programming
> > techniques in D (as well as the use of ranges) using std.functional
> > (and std.algorithm and whatever else is relevant). Is there anything
> > out there that isn't just module documentation that covers the full
> > scope of this?
> 
> I had this same feeling about wanting to learn `std.functional` a bit
> more, so I decided to do https://adventofcode.com/ with additional
> constraints that the code would be functional D with as many unit
> tests as I could manage.  I learned a bunch and had a lot of fun with
> it.

Actually, std.functional is somewhat of a misnomer. It mostly deals with
higher-order functions, i.e., functions that return functions, currying,
that sort of thing.  These are part of functional programming, but
there's more to functional programming than that.  I'd say std.range and
std.algorithm are another major part of functional-style programming
support in D, along with the purity system.

Here are some resources that might help get you started:

	https://klickverbot.at/blog/2012/05/purity-in-d/
	https://tour.dlang.org/tour/en/basics/ranges
	http://ddili.org/ders/d.en/ranges.html
	http://dconf.org/2015/talks/davis.html
	http://www.informit.com/articles/printerfriendly.aspx?p=1407357&rll=1
	http://wiki.dlang.org/Component_programming_with_ranges


T

-- 
What did the alien say to Schubert? "Take me to your lieder."


More information about the Digitalmars-d-learn mailing list