→ Why Racket? Why Lisp?
A slightly older (from Aug 2014), but nonetheless great post by Matthew Butterick where he enumerates the benefits of learning to program in Lisp (or one of its dialects).
Read more…Book - Hackers & Painters
A couple of days ago, I finished reading Paul Graham’s book of essays Hackers and Painters: Big Ideas from the Computer Age, and thoroughly enjoyed the book. I had already read a few of these essays on his website, yet I still enjoyed re-reading them. The essays are very insightful, and I plan to re-read several essays & passages periodically.
Read more…A Quine in Objective-C
A quine is a program that takes no input and outputs its own source code. It has been a while since I last wrote a quine, so I figured I’ll write one in Objective-C. In general, quines follow a fairly simple formula. The program contains a string that includes all the code before the string and all the code after the string. Depending on the programming language, the string might also contain format string (for languages that use format-strings to print to stdout
)
Finding the Start of a Loop in a Circular Linked List
A lot of people are familiar with the problem of detecting a loop in a linked list. The problem goes as follows: “Given a linked list, what is the algorithm to determine if it has any cycles (loops)?”
Read more…Stern-Brocot Tree
Stern-Brocot tree is a tree data structure whose vertices correspond to the set of non-negative rational numbers. Thus, this tree provides a very elegant way for constructing the set of fractions m/n
, where m
and n
are relatively prime. To construct the tree, the basic idea is to start with two fractions (0/1
, 1/0
) and then repeat the following operation:
Read more…Insert (m+m’)/(n+n’) between two adjacent fractions m/n and m’/n'
Manual Memory Management in Objective-C
Objective-C on iOS has no garbage collector, so it is up to the programmer to make sure that memory is properly freed once an object is no longer needed. On the other hand, Objective-C on the Mac does have a garbage collector (in Objective C 2.0). This blog post focuses on how to manage memory in the absence of a garbage collector.
Read more…