Tagged Common Lisp
One of the most distinctive features of Common Lisp and Lisp in general, are its code-generation and code-manipulation capabilities.
Probably the best example is the
LOOP macro - a Swiss Army knife of iteration that can do pretty much anything. The following snippet iterates a list of random numbers collecting some statistics of its contents and does that while being very concise and readable:
(let ((random (loop with max = 500 for i from 0 to max collect (random max)))) (loop for i in random counting (evenp i) into evens counting (oddp i) into odds summing i into total maximizing i into max minimizing i into min finally (format t "Stats: ~A" (list min max total evens odds))))
Stats: (0 499 120808 261 240)
Here's a cool hack I use to optimize my docs searching.
...takes me exactly where I want.
Let's use it to our advantage, shall we?
StumpWM is a tailing window manager that allows you to define system-wide key bindings that work and feel pretty much like Emacs ones. Combining that with DuckDuckGo'es !bang syntax makes you just a few clicks away from anything out there:
(defcommand duckduckgo (phrase) ((:string "Search: ")) "Searches for something on DuckDuckGo." (run-shell-command (concatenate 'string *your-fav-webbrowser* " http://duckduckgo.com/?q=" (substitute #\+ #\Space phrase)))) (define-key *root-map* (kbd "d") "duckduckgo")
Now, if you want to find out if I used
substitute correctly all you have to do is:
C-t d !lisp substitute
...what will take you directly there. Turns out I did.
But wait, there's more!Continue reading
I had very little time for this blog lately, but this is about to end soon enough. Here's a quick post showing ASM' keyboard distribution.
I finally got around to writing a proper review of this book...