"f of x for all x in set s where predicate p holds"

[ f(x) for x in s if p(x) ]

is easier for me to read in python (and english) than

"the composition of map with f and filter with p, applied to set s"

map(f, filter(p, s))

Guido makes similar arguments: artima.com/weblogs/viewpost.js

is comprehension syntax always easier than composition, or is it just our familiarity?

will the same code in idiomatic haskell eventually become as effortless to think about as the list comp is for me in python?

i also want to know the answer for scheme, but i expect it will be "just manipulate the language to provide the syntax you prefer"

Brit
Follow

@pho4cexa Won't do scheme off the top of my head but in common lisp the LOOP macro allows things like:

(loop for x in xs
when (predicate x)
collect (function x))

Some folks use a 3rd party lib called Iterate because LOOP "doesn't feel lispy" syntactically.

But hey, it's in the standard! Along with so many other wild things. You can really tell that CL is a committee/political artifact but I find that endearing. The "archaeologist" side of me I suppose. :)

@kingcons you're making me want to read A Deepness In the Sky again with this programmer archaeology talk

@cwebber @kingcons my favorite part is how the CL standard documents require features that are only relevant on VAX/VMS filesystems.

@technomancy @cwebber The first time I encountered CL pathnames, "wtf" did not quite cover my reaction. I was unprepared.

@kingcons @technomancy @cwebber
I stopped reading "Practical Common Lisp" because of that 🙄

Sign in to participate in the conversation
Tiny Tilde Website

ttw is the unofficial Mastodon instance of tilde.town. We're only smol, but we're friendly. Please don't be a dick.