/
Funcalls-and-Fun-wCode.post
7 lines (7 loc) · 2.13 KB
/
Funcalls-and-Fun-wCode.post
1
2
3
4
5
6
7
;;;;;
title: Funcalls and Fun w/Code
tags: Linux, LISP, Personal, \"Real World\"
date: 2008-09-29 17:49:22
format: html
;;;;;
Life: I have a part-time job interview tomorrow and I've gotten by so far through contract work. I'm also <i>really</i> enjoying not having a car. I've picked up some new tunes and am in guitar fingerpicking mode. I should learn how to myself, really. For now though I'm just listening to Kaki King and Andy McKee. Oh, and Calexico too. They're awesome. Moving on...<br><br>Techie stuff: I've pretty much completely switched to <a href="http://xmonad.org/">Xmonad</a>. It's great and I've polished up my key layout and config for it. There will be some changes in that sense in my next RedLinux release (Fast Amazon download mirror and install guide <a href="http://blog.kingcons.io/posts/Let-That-Which-Does-Not-Matter-Truly-Slide.html">here</a>). For example, there won't be a Caps Lock key in my Linux. It will just be another Control key. It's not like you use it anyway, right? I'm also starting to finally get comfortable with emacs and slime. And <a href="http://gigamonkeys.com/book/">Practical Common Lisp</a> is a really fun and great book to pick up lisp. More on all that later. Here are some fun code snippets:<br><br><pre lang="lisp"><br>(dotimes (x 30)<br> (dotimes (y 30)<br> (format t "~3d" (* (1+ x) (1+ y))))<br> (format t "~%"))<br></pre><br><br><pre lang="lisp"><br>(do ((n 0 (1+ n))<br> (cur 0 next)<br> (next 1 (+ cur next)))<br> ((= 10 n) cur))<br></pre><br><br>Pop quiz: What do these two Common Lisp snippets do?<br>Answers: <pre lang="lisp">(reverse '(The first prints out a multiplication table up to 30x30. The second computes the 11th fibonacci number.))</pre><br><br>And the first macro:<br><pre lang="lisp"><br>(defmacro do-primes ((binder lbound ubound) &rest expr)<br> `(do ((,binder (next-prime ,lbound) (next-prime (1+ ,binder))))<br> ((> ,binder ,ubound))<br> ,@expr))</pre><br><br>Sure it's useless but it makes sense and points the way to some great possiblities. Additionally, destructured lists like so are grand. That's enough lisp to bug you folks with for one day. Deuces.