Clojure reduce: one case for text processing

As a practice, I managed to illustrate Clojure files using illustrate.clj, but my original idea was to annotate org-mode files of blogs. It's not uncommon that a blog post has some code snippets. But it missed the feature until last night, as I wasn't sure how to implement it appropriately before and didn't have enough time. For example, I may have an org-mode like this: sum of two numbers: #+begin_src clojure(+ 1 2) #+end_src I want to have a result comment ((;; => 3)) after each top-level form after using illustrate. [Read More]

illustrate.clj to Illustrate Clojure Snippet

To get my hands dirty with Clojure, I am trying to find or implement Clojure's string functions in the sense of Python. Python has powerful string APIs, and I also want to see how powerful Clojure could be in this field. That would be interesting. As shown in the cheatsheet, Clojure has implemented most of them, and there are some that I have to implement myself, like title-case. [Read More]

String Title Case in Clojure

These days I like to write scripts for some tasks in Python instead of shell. One important reason I think that's because Python is powerful at string manipulation. Recently I'm learning Clojure, and I'm trying to find similar ways in Clojure, one of them is s.title() for getting a title-cased version of a string. For example, >>> ' Hello world'.title() ' Hello World' How to do that in Clojure? [Read More]

String Manipulation in Clojure

Python string APIs are powerful and concise, that is an important reason I use it to do a lot of scripting these days, join, split, strip, to name a few. Since I am learning Clojure recently, I am wondering, how is string manipulation like in Clojure and how to implement equivalent ones? I think it's an excellent opportunity to get familiar with Clojure. Before diving into the implementation, how to declare a multi-line string? [Read More]

A Random Password Generator in Babashka

I'm used to learning by practicing, so when I learned Clojure, I always kept an eye on chances to write code in it. Scripting is an excellent field to practice, but the experience is not so good. On the one hand, it's too hacky to wrap Clojure code in a shell script with the shell bang. On the other hand, the startup time of JVM is too long to hurt the user experience. [Read More]