Funcalls and Fun w/Code

Written on 2008-09-29 17:49:22
Life: I have a part-time job interview tomorrow and I've gotten by so far through contract work. I'm also really 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...

Techie stuff: I've pretty much completely switched to Xmonad. 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 here). 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 Practical Common Lisp is a really fun and great book to pick up lisp. More on all that later. Here are some fun code snippets:


(dotimes (x 30)
(dotimes (y 30)
(format t "~3d" (* (1+ x) (1+ y))))
(format t "~%"))



(do ((n 0 (1+ n))
(cur 0 next)
(next 1 (+ cur next)))
((= 10 n) cur))


Pop quiz: What do these two Common Lisp snippets do?
Answers:
(reverse '(The first prints out a multiplication table up to 30x30. The second computes the 11th fibonacci number.))


And the first macro:

(defmacro do-primes ((binder lbound ubound) &rest expr)
`(do ((,binder (next-prime ,lbound) (next-prime (1+ ,binder))))
((> ,binder ,ubound))
,@expr))


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.
Previous
Next
comments powered by Disqus

Unless otherwise credited all material Creative Commons License by Brit Butler