programming

Heh, Emacs LISP function! Lemme give you a piece of advice!

Did you know that in some programming languages, you can give a function a piece of advice? The basic idea is this: if you are using an application or a library written by somebody else, what can you do if you need to modify the behavior of a particular function? You could modify its source code, if your version improves it for everybody. However, if you only want to customize it for your personal needs, a more lightweight solution might be desirable.
Read more

Beautiful ideas in programming: generators and continuations

In this post, I’ll summarize what I’ve learned from an attempt to gain a deeper understanding of two important concepts in programming: Python’s generators and Scheme’s continuation. The aim is not to teach Python or Scheme programming. Rather, what I want to do is to demonstrate that generators are special cases of a much more powerful construct - continuations. Continuations allow programmers to invent new control structures, and it is the foundation upon which iterators, generators, coroutines, and many other useful constructs can be built.
Read more

Simple exercises with grep, sed and awk in org-mode

For text processing, I had never bothered to learn classic Unix tools such as sed and awk, because I can always use Python's regular expression library. The syntax of sed and awk just appeared to be too arcane to me. However, recently I realize that for many simple ad-hoc tasks, even writing a Python script is too much overhead. This motivated me to learn to use regular expressions directly in the command line.
Read more

In the 70’s, it was fashionable for intellectuals to abuse the term “grammar” to refer to any underlying principles. In one of his essays, Italo Calvino used the term “the grammar of tree” to refer to…. essentially developmental plant biology. I thought that was pretentious. But heh, in R programming, people are talking about the grammar of graphics and grammar of data manipulation again. It’s fashionable to call functions “verbs” again.
Read more

Idea: a Python dialect called Pynchon (after Thomas Pynchon). A pynchonic code is probably not very pythonic. Brevity is highly discouraged. Variable names should be all puns. In fact, Pynchon should be a concatenative language like Forth. This way, statements can be chained together into a longer and longer statement… until the entire program is one single statement.