Functional Programming

## Metadata
- Author: [[Jamie Todd Rubin]]
- Full Title: Functional Programming
- Category: #articles
- Document Note: ---
tags:
- #functionalprogramming
- #wolframlanguage
- #automation
- #productivity
- #obsidian
- #mathematica
Author: Jamie Todd Rubin
Source: Personal blog
Reference: https://jamierubin.net/2023/06/26/functional-programming/
date created: 2025-08-22 00:00
---
# Title: Functional Programming — From Procedural Habits to a Lambda Breakthrough
## Table of Contents:
- 🧭 Overview (#-🧭-Overview)
- 🎯 2023 Goals: Consolidation, Simplification, Automation (#-🎯-2023-Goals-Consolidation-Simplification-Automation)
- 🛠️ Tooling & Workflow (Obsidian + Wolfram) (#-🛠️-Tooling-Workflow-Obsidian-+-Wolfram)
- 🤖 Automations Built (So Far) (#-🤖-Automations-Built-So-Far)
- 🧵 Procedural to Functional: The Shift (#-🧵-Procedural-to-Functional-The-Shift)
- 📝 Stylesheet Use Case & Options (#-📝-Stylesheet-Use-Case-Options)
- ⚙️ Sync Script: Procedural vs Functional (#-⚙️-Sync-Script-Procedural-vs-Functional)
- 🧠 The Click Moment & Prior Parallels (#-🧠-The-Click-Moment-Prior-Parallels)
- 📚 References (#-📚-References)
### References:
- Wolfram Language and Mathematica documentation
- Obsidian and Obsidian Publish documentation
- Perl regular expressions resources (contextual background)
## 📝 Summary:
Jamie Todd Rubin reflects on mid‑year progress toward three 2023 themes—consolidation, simplification, and automation—anchored in two work product formats: plain text in Obsidian and Wolfram Language notebooks in Mathematica. He describes several practical automations he built with Wolfram Language (daily work-product logging to Obsidian, randomized article selection via email, and automated export/publish of a reading list), then narrates a pivotal mindset shift from procedural programming to functional programming. Using a concrete use case—syncing custom Mathematica stylesheets from a personal Settings directory to the application library—he rewrites a procedural loop into a concise functional map with an anonymous function, experiencing a “click” similar to when regular expressions became intuitive during his Perl learning in the 1990s.
## 📖 Main Content:
- The author is optimizing his digital life by limiting formats and tools: plain text (Obsidian) for journaling/daily life notes and Wolfram notebooks for code, writing, and automation. This consolidation reduces friction and increases consistency across devices.
- Wolfram Language’s breadth enables both heavy-lift computation and simple system tasks, making it suitable as a unifying automation layer.
- Three concrete automations showcase progressive simplification:
- Automatic daily work-product summaries appended to Obsidian notes.
- Evening emails with a randomly selected feature article to curb decision fatigue.
- Automated reading list export to an Obsidian-published vault, eliminating a long-standing manual process.
- The learning highlight is the evolution from procedural code (explicit loops and conditionals) to functional code (mapping an anonymous function across a list). The case study: propagating updated custom stylesheets to Mathematica’s library only when the master is newer.
- The functional rewrite reduces verbosity and emphasizes transformation over mutation, which enhances clarity once the mental model is internalized. The result sparks confidence and motivation to further adopt functional patterns.
### 🗒️ Notes
- Goals and framing
- Consolidation, simplification, automation as yearly themes.
- Two output formats: Obsidian notes and Wolfram notebooks.
- Tooling alignment
- Obsidian: daily notes, life/event tracking.
- Wolfram: working notes, code, writing, automation tasks.
- Automations implemented
- Daily work-product collector:
- Scans for files created/edited that day.
- Appends summary to Obsidian daily note.
- Runs nightly to provide a morning review.
- Random feature-article emailer:
- Draws from subscribed magazines.
- Reduces decision fatigue, adds serendipity.
- Reading list export/publish:
- Pulls from a maintained spreadsheet.
- Builds charts/stats; publishes via Obsidian Publish.
- Functional programming pivot
- Background in procedural programming since early 1980s (BASIC onward).
- Wolfram supports both but shines with functional style.
- Stylesheet sync use case
- Three approaches considered: manual save; copy-on-change; automate.
- Chose automation following “do it right once” principle.
- Settings folder serves as a master source for portability across machines.
- Task: ensure Mathematica’s library has up-to-date copies.
- Procedural implementation
- Loop through files; for each:
- If exists in library, compare modification dates; copy if newer.
- If not exists, copy.
- Functional implementation
- Anonymous function checks existence and modification times; copies accordingly.
- Map over list of stylesheets.
- Shorter and expressive once functional mindset “clicks.”
- Learning resonance
- Parallel to Perl regular expressions: initially opaque, later intuitive.
- The breakthrough increases confidence and appetite for more functional work.
## 📖 References:
- Functional programming concepts in Wolfram Language: Map, pure functions (anonymous/lambda), FileExistsQ, FileDate, CopyFile, FileNameJoin, FileBaseName, FileExtension.
- Obsidian Publish documentation for vault publishing.
- Perl regular expressions (historical analogy, no explicit source cited).
## 🗣️ Paraphrase:
1) Original idea: After years of procedural coding, Wolfram’s strength is functional programming, and I’ve begun teaching myself to think functionally. Over the weekend, I faced a stylesheet-placement problem with several options, and I chose to automate the sync fully.
- Paraphrase: Although I’ve long favored step-by-step, procedural code, Wolfram’s real advantages emerge in a functional style, which I’m now learning. When I needed to manage a custom writing stylesheet, I evaluated manual and semi-automated choices but ultimately decided to build a complete synchronization workflow.
2) Original idea: I rewrote a procedural loop as a concise anonymous function mapped over files; it worked immediately, marking a personal milestone akin to when regular expressions in Perl suddenly made sense.
- Paraphrase: I transformed the loop-driven approach into a compact lambda applied across the stylesheet list, and it executed flawlessly on the first try. That success felt like a landmark—similar to the moment regex in Perl shifted from indecipherable to intuitive.
## 📰 Newsletter:
Learning web development never sits still—and neither should your toolbox. This week, we’re focusing on reducing decision fatigue and embracing automation. Highlights:
- Recent updates: Streamline your workflow by standardizing formats—think “Markdown + code notebooks.” If you’re an Obsidian fan, nightly scripts can summarize your day’s work products automatically, giving you a next‑morning snapshot of progress.
- Community spotlight: Makers are leaning into functional patterns. Whether you’re in JavaScript (Array.map/filter/reduce) or Python (list comprehensions, pathlib + shutil), the functional mindset helps turn repetitive chores into tidy, testable transforms.
- New plugins: Check out Obsidian community plugins that pair well with automation (Templater for dynamic notes, Dataview for live dashboards). For WordPress devs, keep an eye on tools that export content metrics into your docs for better editorial planning.
- What to try: Build a script that emails you one longread at day’s end—less doomscrolling, more deliberate reading.
Useful links:
- Functional programming in practice: “Map and anonymous functions” concepts explained in the Wolfram Language docs
- Obsidian Publish overview for sharing curated knowledge bases
As always, keep it friendly, hacky, and fun—ship the boring bits to your scripts, save your energy for the creative ones.
## ✅ Action Items:
Prompt for alignment with open-source advocacy, contributor engagement, education, and OSPO trajectory:
- Purpose: Analyze how each article reinforces sustainable, inclusive open-source practices in the WordPress ecosystem and beyond.
- Use this prompt with any article:
“Analyze how this article’s them
- Summary: Functional programming is a programming paradigm characterized by the use of immutable data and the absence of side effects. The author of the document shares their experience with functional programming, specifically in relation to Wolfram Language and Mathematica. They discuss their goals for consolidation, simplification, and automation, and how they have successfully incorporated functional programming into their workflow using these tools. The author highlights their achievements, such as creating scripts for generating daily notes and automating tasks like exporting reading lists. They also reflect on the benefits and challenges of functional programming, drawing parallels to their past experiences with learning new programming concepts. Ultimately, the author expresses excitement and confidence in their newfound functional programming skills.
- URL: https://jamierubin.net/2023/06/26/functional-programming/
Photo by Christina Morillo on Pexels.com
**Late last year** [I set myself some goals](https://jamierubin.net/2022/12/29/goals-for-2023/) to tackle in 2023. These goals fell into three areas in which I am seeking improvement: (1) consolidation, (2) simplification, and (3) automation. In setting those goals, I wrote the following:
> I believe I can get away with two primary work product formats: plain text files used in conjunction with Obsidian; and Wolfram Language notebooks (.nb files) used in conjunction with Wolfram Language and Mathematica.
>
>
Halfway through 2023, I think I have been largely successful. My daily notes and all things related to events in my life (and that of my family) are recorded in Obsidian. Meanwhile, working notes, coding, writing, and automation has happened primarily in Wolfram notebooks, and using the Wolfram Language as my primary framework.
I’ve been a hobbyist user of [Mathematica](https://www.wolfram.com/mathematica/) and [Wolfram Language](https://www.wolfram.com/language/) since 2009. I like its all-encompassing scope, its ability notional that nearly everything is computable, and its coding framework . A great thing about the Wolfram Language is that it can be used for complex mathematical experiments, or simply to copy files from folder A to folder B. It is a language that can be used for any task and that is how I have been using it. In the six months since setting my goals, for instance, I’ve done the following using Wolfram Language notebooks and scripts:
* Created a script that adds work products for a given day to my Daily Notes file in Obsidian. Work products are defined as any file that I created or edited that day: notes, scripts, spreadsheets, etc. The script runs automatically each night and in the morning, I can see the files that I worked on the previous day.
An example of my Daily Notes file with the “Today’s work products” section generated automatically by my script
* Created a script that selects a random article from the magazines I read and emails me the article the evening. I read a feature article each day and this script [eliminated some decision fatigue](https://jamierubin.net/2022/08/28/battling-decision-fatigue-an-article-a-day/) while simultaneously adding a little spontaneity and surprise to the day — I never know what will get selected.
* Create a script that exports my current reading list to an Obsidian vault, complete with charts and stats. This vault is published to the web using Obsidian Publish. For decades this was a manual task for me and now it is fully automated. All I have to do is keep my spreadsheet up-to-date.
I [learned to write code](https://jamierubin.net/2021/02/23/how-to-learn-to-write-code-in-37-short-years-part-1-hello-world/) in the early 1980s by trial and error. And from that first foray with BASIC through this year, I’ve been a procedural programming — a method by which a set of procedures are called in step-by-step fashion. Those procedures might be functions, events or anything that can be called at any point during the program’s execution. Wolfram Language can do procedural programming, but its real power comes from its ability to do functional programming. After a lifetime of procedural programming, I have begun to teach myself functional programming.
Over the weekend, I began exploring the use of stylesheets in Wolfram Notebooks. I created a simple stylesheet for writing, with styles and elements that I use frequently. There is a folder location with the Mathematica framework for these custom stylesheets to be stored. I had several choices:
1. I could simply save my custom stylesheet to the folder in question.
2. I could store the stylesheet in one place and copy it to the folder in question whenever I made a change.
3. I could automate the process.
One of the things I’ve learned as a professional software developer is that it is worth spending the time to do things the right way the first time. I opted, therefore, for option 3.
In my Documents folder, I have a folder called Settings, where I keep my preferences for all of the software I use. This includes things like settings files, templates, stylesheets, preferred fonts, etc. This is the source for my personal preferences and when I get a new machine, it makes it easy to apply all my settings to that machine.
My settings folder
I placed my newly created Writing.nb notebook in the Mathematica folder in my Settings folder. Whenever I updated my stylesheet, this is the file I’d update. But for the file to appear in Mathematica, it needs to live in a special folder in my library. For that, I write a Wolfram Language script. The script does the following:
* makes a list of all files in my StyleSheets folder (a sub-folder of my Mathematica folder)
* for each of the files in the list:
+ checks to see if the file exists in the Mathematical library
+ if it exists, it checks to see if my master copy has been update more recently than the version in the library folder; if it has, it copies the updated version to the library folder
I wrote the code as I have written most of my Wolfram Language code, procedurally. It looks as follows:
```
Do[
If[FileExistsQ[
FileNameJoin[{customStyleSheetDestPath, customStyleSheets[[i]]}]],
If[FileDate[customStyleSheets[[i]], "Modification"] >
FileDate[
FileNameJoin[{customStyleSheetDestPath, customStyleSheets[[i]]},
"Modification"]],
CopyFile[customStyleSheets[[i]],
FileNameJoin[{customStyleSheetDestPath,
FileBaseName[customStyleSheets[[i]]] <> "." <>
FileExtension[customStyleSheets[[i]]]}], OverwriteTarget -> True
]
],
CopyFile[customStyleSheets[[i]],
FileNameJoin[{customStyleSheetDestPath,
FileBaseName[customStyleSheets[[i]]] <> "." <>
FileExtension[customStyleSheets[[i]]]}],
OverwriteTarget -> True
]
],
{i, Length[customStyleSheets]}
]
```
Having written and tested the code, I decided that this was a simple enough task for me to try to rewrite the code as a functional program instead of a procedural one. To my surprise, I’d was able to do it fairly quickly. I was further surprised that it worked on the first try. Here is the same program, written as a functional program:
```
If[FileExistsQ[FileNameJoin[{customStyleSheetDestPath, #}]],
If[FileDate[#, "Modification"] >
FileDate[FileNameJoin[{customStyleSheetDestPath, #}],
"Modification"],
CopyFile[#,
FileNameJoin[{customStyleSheetDestPath,
FileBaseName[#] <> "." <> FileExtension[#]}],
OverwriteTarget -> True]],
CopyFile[#,
FileNameJoin[{customStyleSheetDestPath,
FileBaseName[#] <> "." <> FileExtension[#]}],
OverwriteTarget -> True]
] & /@ customStyleSheets;
```
It looks much shorter, and is probably a bit more difficult to read if you are not used to working with functional programs. Essentially, this version of the program defines the entire procedure as an anonymous (i.e. Lambda) function and then maps that function over the list of style sheet files.
While this likely seems obscure and insignificant to most people, it was an important milestone for me. I did this early Saturday morning, and I was excited about the results all weekend. Indeed, I was excited enough by the results to want to tell people about it in a post. This was a milestone for me. Something about functional programmed had clicked in my head and, it seemed, I suddenly got it.
This isn’t the first time something like this has happened to me. I remember in late 1994 or early 1995 when I was teaching myself Perl, I looked at regular expressions as utter gibberish, something I would never understand. A year later, I recall, to my amazement, that I could in almost-realtime craft regular expressions for a pattern in my head. Like functional programming, it just clicked one day.
There is a lesson here. I set about my Saturday morning with a practical task in mind: creating a stylesheet for writing in Wolfram Notebooks. I came away with that stylesheet, but much more important, I had new confidence in my ability, and now I am eager to try flex my functional programming muscles even further.
Some content could not be imported from the original document. [View content ↗](https://widgets.wp.com/follow/index.html#href=jamierubin.net&lang=en&blog=https%3A%2F%2Fjamierubin.net&show_follower_count=true)
[](https://jamierubin.net/2012/03/12/personal-analytics/)
[](https://jamierubin.net/2014/03/03/a-network-graph-of-my-blog-links/)
[](https://jamierubin.net/2022/12/29/goals-for-2023/), Functional Programming, Jamie Todd Rubin, 01h4dtzbb4nsbdr08pz82vrtz5.