Scheme: for-each Redundancy

I use Fish as my command-line shell. But when I feel the need to write a shell script these days I use Scheme, via scsh. It has been a while since I’ve written Scheme (or any Lisp) on a regular basis, and so I find myself typing down some dumb, novice mistakes. And tonight I want to share one.

Spot the Problem

Here is a piece of a script I use to update certain software, namely fetching updates from repositories and compiling them. See if you notice the problem:

(for-each
 (lambda (dir)
   (update-git-sub-directories dir))
 directories-with-git-repositories)

See the issue? Keep in mind that for-each calls a given function (here an anonymous function) for each element of a list. Think about that until you see the facepalm-quality redundancy.

Advertisements

Add Your Thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s