The lambda calculus is a foundational mathematical framework for studying functions. It forms the bedrock of functional programming, offering a powerful and elegant way to define and manipulate functions. Emacs Lisp, a dialect of Lisp heavily used within the Emacs editor, offers a flexible environment for exploring these concepts. In this article, we’ll embark on a journey to understand how the lambda calculus is expressed within Emacs Lisp, using illustrative examples to highlight the core concepts. ...
The Endo Monoid
Overview Endo can be used as a form of composition by concating functions. In this concatination functions results are fed into the concatted function. The value is fed into Endo’s run function providing opportunities for lazy operations. I’m purposely being extremely explicit because I make to make sure that I understand each step of these functional implementations. ## Examples Example 1 // Endo monoid declaration // Endo :: (a -> a) -> Endo a const Endo = run => ({ run, // concat :: Endo a -> Endo a -> Endo a concat: other => Endo(x => run(other.run(x))) }) // Endo.empty :: () -> Endo a Endo.empty = () => Endo(x => x) // List monad for putting functions into a list. // List :: [a] -> List a const List = list => ({ list, // map :: (a -> b) -> List a -> List b map: fn => List(list.map(fn)), // fold :: ((b, a) -> b, b) -> List a -> List b fold: (fn, initialValue) => List(list.reduce(fn, initialValue)), // foldMap :: (a -> b) -> b -> List a -> b foldMap: (monoid, empty) => { return empty != null ? list.reduce((acc, x, i) => acc.concat(monoid(x, i)), empty) : list.map(monoid).reduce((acc, x) => acc.concat(x)) }, // extract :: () -> [a] extract: () => list, }) // Utility functions // compose :: (b -> c) -> (a -> b) -> a -> c const compose = f => g => x => f(g(x)) // curry :: ((a, b) -> c) -> a -> b -> c const curry = f => a => b => f(a, b) // toUpper :: String -> String const toUpper = str => str.toUpperCase() // exclaim :: String -> String const exclaim = str => `${str}!!` // to OrgHeader :: String -> String const toOrgHeader = str => `* ${str}` // toOrgTagList :: [String] -> String const toOrgTagList = xs => List(xs) .map((tag, index) => !index ? `:${tag}:` : `${tag}:` ) .fold((accumalator,tag, index) => accumalator.concat(tag) ,'') .extract() // Tag list for header const tags = ['javascript', 'completed', 'moved'] // addTagsToHeader :: [String] -> String -> String const addTagsToHeader = curry((tagList,str) => `${str} ${tagList}`) console.log(addTagsToHeader(toOrgTagList(tags))("A Header")) const result = List([addTagsToHeader(toOrgTagList(tags)),toOrgHeader, toUpper, exclaim]).foldMap(Endo, Endo.empty('')).run('hello') //> A Header :javascript:completed:moved: console.log(result) //> HELLO!! :javascript:completed:moved:
Functional Programming Concepts
Overview This is essential a map of content for functional programming concepts that I’m learning. List Monad
List Monad in JavaScript
Thoughts I’m writing this more as a way to document and organize my thoughts around the list monad. This is a very important monad. A map of functional concepts I’m currently studying can be found at Functional Programming Concepts. The Code export const List = list => ({ list, map: fn => List(list.map(fn)), fold: (fn, initialValue) => List(list.reduce(fn, initialValue)), foldMap(monoid, empty) { const mappedList = list.reduce(fn, initialValue); const result = mappedList.reduce( (accumalator, monoidValue) => accumalator.concat(monoidValue), empty, ); return List(result); }, extract: () => list, }); Example Here is a sample implementation of this list monad. ...
My Zettelkasten Workflow
Introduction Emacs Capture Templates Org-Roam Browser Browser Options Capture Templates
Why Lisp?
Writing Lisp Code is Easy However good Lisp programming is hard according to Richard P. Gabriel. Lisp is extremely hackable It’s easy to create a Lisp Language It’s Easy to Make a Lisp Language Domain Specific Writing a parser and compiler for Lisp is way claner than other languages Emacs is configured with Lisp Lisp Helps Me with My Programmatic Thinking Once you know Lisp you think of programming in a very different way. Lisp has heavy ties to Functional Programming My interested in mathematics has motivated my interest in functional programming. A lot of functional programming ideas implemented in other programming languages started in Lisp. A lot of academic computer science work uses Lisp. Common Lisp’s Object-Oriented System is Great Development of programs in Lisp advance faster then in other languages Its easy to build a prototype of an idea in Lisp. ...
Tech I'm Intersted In
Focus on the Fundamentals In all of my learning of programming and computer science I would like to keep a focus on having strong fundamentals. This desire to have strong fundamentals is what informs my decisions on what to learn and in what order. Languages JavaScript Many sources online say you should take either JavaScript or Python as your first language. I like that JavaScript has more of a closeness to C-syntax since C is a high priority on my list of languages to learn. With JavaScript I can build and interact with the full stack of web development. I can work from browser to server. This means the skills I learn can be applied to more places. JavaScript is thought of having a closeness to Lisp. So this also feeds in to my desire to learn Lisp. In learning JavaScript I believe it will be easy to crossover into Python. But I don’t think it would be as easy the other way around. In the end, Python being a very important language, I will still get to learning it at some point no matter what. It’s important to really grokk one language. Then it will be easier to pick up the rest because I will actually understand the core principles of programming. Sort of like mastering one key in song writing. Then later it will be easy to pick up the rest of the keys. JavaScript works in the browser which means that I can build little applications that can run in browser. No need to download anything. Lisp/Elisp I learned lisp because of reading that it will help you to be a better programming. However they also say it shouldn’t be your first language. As a result of learning lisp I was lead towards Emacs Emacs I believe also helps me to be a better programmer All of the greatest engineers in the world use emacs ...
Find Closest Number To Zero
This is some text
Improving Education for Common Lisp Developers: Goals and Strategies
Common Lisp has been part of the programming landscape for decades, offering a powerful macro system, dynamic typing, and multi-paradigm flexibility. Despite its strengths, it remains niche compared to more mainstream languages. One of the reasons for this is the challenge of finding comprehensive and accessible educational resources. Better education can attract new developers, retain seasoned ones, and ensure that Common Lisp continues to evolve. Below is an in-depth look at how to improve education for Common Lisp developers, the common obstacles they face, and potential strategies for overcoming those barriers. ...