Self Wright

Tag: clozure

Summing up

I came across this post talking about numerical speed in Clojure, so I thought I would try out the equivalent in Common Lisp (Clozure CL) on my Macbook:

[code lang=text]
CL-USER> (let* ((arr-size 3000000)
(double-arr (make-array arr-size :element-type 'single-float)))
(dotimes (i arr-size)
(setf (aref double-arr i) (random 1.0)))
(time (loop for i from 0 below arr-size
summing (aref double-arr i))))
took 45,649 microseconds (0.045649 seconds) to run.
During that period, and with 4 available CPU cores,
45,558 microseconds (0.045558 seconds) were spent in user mode
57 microseconds (0.000057 seconds) were spent in system mode

So — 45 milliseconds, not bad.

Minor changes to the setup

As a followup to my initial getting started post:

* I later replaced the Clozure App with the command-line version, obtained by

`svn co`

  • The basic slime (running in comint mode) is a bit too bare-bones, and it’s much better to add

`(setq slime-contribs ‘(slime-fancy))`

Getting Started on OSX

Here’s what I did, though perhaps a better order of steps exists:

  • Downloaded Emacs for OSX

  • Downloaded ClozureCL from the Mac App Store.

  • Downloaded Quicklisp

  • Ran ClozureCL, then “File -> Load File …”, and selected quicklisp.lisp downloaded earlier.

  • Ran (quicklisp-quickstart:install)

  • Ran (ql:add-to-init-file) to make sure I don’t have to repeat this step again

  • Ran (ql:quickload :quicklisp-slime-helper). This downloaded SLIME and told me what to add to my .emacs:

`(load (expand-file-name “~/quicklisp/slime-helper.el”))`

  • Made a useful symlink:

  `ln -s /Applications/Clozure ~/bin/ccl`

  • Added a reference to this in my .emacs:

`(setq inferior-lisp-program “~/bin/ccl”)`

  • Ran emacs, M-x slime works !

(or as the prompt says, “Happy hacking!”)


Powered by WordPress & Theme by Anders Norén