I'm trying to use cl-pdf for some fairly basic PDF generation, but I'm getting tripped up at the examples (which is embarassing to say the least).
When I run the first example included in the package
(defun example1 (&optional (file #P"/tmp/ex1.pdf"))
(pdf:with-document ()
(pdf:with-page ()
(pdf:with-outline-level ("Example" (pdf:register-page-reference))
(let ((helvetica (pdf:get-font "Helvetica")))
(pdf:in-text-mode
(pdf:set-font helvetica 36.0)
(pdf:move-text 100 800)
(pdf:draw-text "cl-pdf: Example 1"))
(pdf:translate 230 500)
(loop repeat 150
for i = 0.67 then (* i 1.045)
do (pdf:in-text-mode
(pdf:set-font helvetica i)
(pdf:set-rgb-fill (/ (random 255) 255.0)
(/ (random 255) 255.0)
(/ (random 255) 255.0))
(pdf:move-text (* i 3) 0)
(pdf:show-text "cl-typesetting"))
(pdf:rotate 13)))))
(pdf:write-document file)))
by running (example1 #P"/home/inaimathi/Desktop/ex1.pdf") it gives me this error
#<SB-SYS:FD-STREAM for "file /home/inaimathi/Desktop/test.pdf"
{CF9D931}> is not a binary output stream.
[Condition of type SIMPLE-TYPE-ERROR]
Restarts:
0: [ABORT] Exit debugger, returning to top level.
The same thing happens when I call (example1), or when I do
(with-open-file
(test-file #P"/home/inaimathi/Desktop/ex1.pdf"
:direction :output :if-does-not-exist :create)
(example1 test-file))
Finally, if I try
(with-open-file
(test-file #P"/home/inaimathi/Desktop/ex1.pdf"
:direction :output :if-does-not-exist :create
:element-type '(unsigned-byte 8))
(example1 test-file))
I get the error
#<SB-SYS:FD-STREAM for "file /home/inaimathi/Desktop/test.pdf"
{D197C99}> is not a character output stream.
[Condition of type SIMPLE-TYPE-ERROR]
Restarts:
0: [ABORT] Exit debugger, returning to top level.
Is there a way to declare a binary character stream? How do I get simple output out of cl-pdf? I'm using SBCL straight out of the debian repos (which is 1.0.29, I think), in case it matters.
(setf pdf:*compress-streams* nil) should help. It's trying to write binary data to a character stream, and while that works on LispWorks and some other systems, it doesn't work everywhere and particularly not on SBCL.
EDIT 2: asdf-install is unmaintained and deprecated. It is best to use Quicklisp. To install Quicklisp, you'll need to download it:
$ curl -O https://beta.quicklisp.org/quicklisp.lisp
Then add cl-pdf to your lisp installation:
$ sbcl --load quicklisp.lisp
* (quicklisp-quickstart:install)
* (ql:quickload "vecto")
* (ql:add-to-init-file)
* (exit)
Now all you need to do is add
(load "~/quicklisp/setup.lisp") ; if it installed in the default location
to your .lisp file, and you can then add
(ql:quickload "cl-pdf")
EDIT: This is what I ended up doing. The solution by xach above would also work.
In the end I had to wget http://www.fractalconcept.com/download/cl-pdf-current.tgz and install that.
For the newbs (since I remember how frustrating it is for someone new to Common Lisp to hear "just do a checkout and install it"):
1.Do the checkout as above (I assume you've done this in your home directory from now on)
2.Type in tar xvzf cl-pdf-current.tgz (the point is to get a tarball of the folder. You can do this through the GUI too, it makes no difference)
3.Hop into your SBCL prompt and enter
(require 'asdf)
(require 'asdf-install)
4.If you already installed cl-pdf using (asdf-install:install 'cl-pdf), then you'll need to enter (asdf-install:uninstall 'cl-pdf)
5.Type (asdf-install:install "/home/[your home folder name]/cl-pdf-current.tgz")
I got one compilation error throughout this process, which I just selected [Accept] for. It still seems to work fine.
Hopefully the upcoming release of quicklisp will reduce the need for this sort of package hunting.
Related
Assuming that a local system has create-react-app installed (npm i -g create-react-app), I want to run it with parameters from within a Common Lisp file. What's the best way to do this?
as far as i know, the potrable solution is uiop:run-program, since your cl distribution probably has the asdf included.
CL-USER> (uiop:run-program "create-react-app" :output t :error-output t)
;;Please specify the project directory:
;; create-react-app <project-directory>
;;For example:
;; create-react-app my-react-app
;;Run create-react-app --help to see all options.
;;; Debugger entered on #<UIOP/RUN-PROGRAM:SUBPROCESS-ERROR {10018B83A3}>
this one reports error, as the create-react-app itself does for no args.
(uiop:run-program "create-react-app my-new-shiny-app" :output t :error-output t)
succeeds, and creates app in your cwd.
you can wrap it into a function like this, for example:
(defun create-react-app (app-path &key verbose info scripts-version template use-npm use-pnp typescript)
(let ((cmd (format nil "create-react-app ~a ~
~#[--verbose~*~] ~
~#[--info~*~] ~
~#[--scripts-version ~a~] ~
~#[--template ~a~] ~
~#[--use-npm~*~] ~
~#[--use-pnp~*~] ~
~#[--typescript~*~]"
app-path verbose info scripts-version template use-npm use-pnp typescript)))
(format t "executing shell command: ~a~%" cmd)
(uiop:run-program cmd :output t :error-output t)))
(create-react-app "my-new-shiny-app" :template "cra-template-quickstart-redux" :use-npm t)
havent thoroughly tested it, but it should work.
I updated quicklisp to the latest February version and went to re-run a few of my unit tests for the xlmanip workbook/worksheet reader I'm developing. SBCL borks on the unit test because it recompiles the closure-common package and closure-common modifies the standard readtable (in a nice way, actually.)
My one option is to fork the closure-common code base, hope that the maintainer actually responds to the patch, and pray that the patch is accepted, follow clozure-common dependencies in quicklisp where SET-DISPATCH-MACRO-CHARACTER is also called for the same reason.
Does anyone know of a workaround for this problem? closure-common isn't the only package that has this issue, I'm fairly certain.
EDIT: If I have to clone and hack clozure-common, what is the recommended/preferred way for localizing readtable modifications or switching to a custom readtable?
EDIT #2: Here's the output transcript using a freshly installed quicklisp (specifically, look at the last line of closure-common-20101107-git/syntax.lisp where the call to SET-DISPATCH-MACRO-CHARACTER occurs):
To load "xlmanip/tests":
Load 1 ASDF system:
xlmanip/tests
; Loading "xlmanip/tests"
.
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
yes, using code points.
..
;;; Checking for wide character support... WARNING: Lisp implementation doesn't use UTF-16, but accepts surrogate code points.
yes, using code points.
;;; Building Closure with CHARACTER RUNES
........While evaluating the form starting at line 4, column 0
of #P"/tmp/xlmanip17497a.lisp":
Fatal condition:
SET-DISPATCH-MACRO-CHARACTER would modify the standard readtable.
See also:
The ANSI Standard, Section 2.1.1.2
The ANSI Standard, Glossary entry for "standard readtable"
Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1002A7D263}>
0: ((LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX))
1: (SB-IMPL::CALL-WITH-SANE-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX) {1006B1F8BB}>)
2: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-DEBUG::FUNCALL-WITH-DEBUG-IO-SYNTAX) {1006B1F88B}>)
3: (SB-DEBUG:PRINT-BACKTRACE :STREAM #<SB-SYS:FD-STREAM for "standard error" {1003135713}> :START 0 :FROM :DEBUGGER-FRAME :COUNT 4611686018427387903 :PRINT-THREAD T :PRINT-FRAME-SOURCE NIL :METHOD-FRAME-STYLE NIL :EMERGENCY-BEST-EFFORT NIL)
4: ((LAMBDA NIL :IN UIOP/IMAGE:PRINT-BACKTRACE))
5: ((LAMBDA NIL :IN UIOP/STREAM:CALL-WITH-SAFE-IO-SYNTAX))
6: (SB-IMPL::%WITH-STANDARD-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN UIOP/STREAM:CALL-WITH-SAFE-IO-SYNTAX) {1006B1F86B}>)
7: (UIOP/IMAGE:PRINT-CONDITION-BACKTRACE #<SB-INT:STANDARD-READTABLE-MODIFIED-ERROR {1006B1D643}> :STREAM #<SB-SYS:FD-STREAM for "standard error" {1003135713}> :COUNT NIL)
8: (UIOP/IMAGE:HANDLE-FATAL-CONDITION #<SB-INT:STANDARD-READTABLE-MODIFIED-ERROR {1006B1D643}>)
9: (SIGNAL #<SB-INT:STANDARD-READTABLE-MODIFIED-ERROR {1006B1D643}>)
10: (CERROR "Frob it anyway!" SB-INT:STANDARD-READTABLE-MODIFIED-ERROR :OPERATION SET-DISPATCH-MACRO-CHARACTER)
11: (SET-DISPATCH-MACRO-CHARACTER #\# #\/ RUNES::RUNE-READER #<READTABLE {100041EA83}>)
12: (SB-FASL::LOAD-FASL-GROUP #S(SB-FASL::FASL-INPUT :STREAM #<SB-SYS:FD-STREAM for "file <homedir>/.cache/common-lisp/sbcl-1.3.1.243-55a6786-macosx-x64/<homedir>/quicklisp/dists/quicklisp/software/closure-common-20101107-git/syntax.fasl" {1006B0F693}> :TABLE #(282 SET *PACKAGE* "RUNES" #<PACKAGE "SB-IMPL"> SB-IMPL::%DEFUN #<PACKAGE "RUNES"> RUNES::RT-WHITE-SPACE-P STRING MAKE-STRING-INPUT-STREAM :EOF PEEK-CHAR ...) :STACK #(0 SET-DISPATCH-MACRO-CHARACTER #\# #\/ RUNES::RUNE-READER 0 50 "<homedir>/quicklisp/dists/quicklisp/software/closure-common-20101107-git/syntax.lisp" #<SB-KERNEL:LAYOUT for SB-C:DEFINITION-SOURCE-LOCATION {10000415B3}> NIL NIL NIL ...) :DEPRECATED-STUFF NIL :SKIP-UNTIL NIL) NIL)
<...truncated... error occurs in syntax.lisp>
The script that generates this output:
#!/bin/sh
tmpf=/tmp/xlmanip$$a.lisp
cat >${tmpf} <<__EOF__
(proclaim '(optimize speed space))
;;; SBCL:Muffle compiler-notes
#+sbcl (declaim (sb-ext:muffle-conditions sb-ext:compiler-note))
(ql:quickload :xlmanip/tests)
(time (asdf:oos 'asdf:test-op :xlmanip))
(quit)
__EOF__
trap "rm -f ${tmpf}" 0 1 2 3 15
if test "x${CL_LISPS}" = x; then
CL_LISPS="sbcl ccl clisp ecl"
fi
for l in $CL_LISPS; do
echo "\n======== $l ========\n"
cl-launch --lisp $l --execute --quicklisp --init '(load "'"${tmpf}"'")'
done
Diagnosing the problem: Somewhere in the code stream that loads closure-common, there seems to be a call similar to:
(with-standard-io-syntax
(load "closure-common"))
That's the only way that I've found to trip the standard *readtable* modification. In all other cases, e.g., from the sbcl prompt, set-dispatch-macro-character doesn't modify the standard *readtable*. I haven't traced the problem into ASDF, UIOP or Quicklisp itself, although those are likely candidates as well.
I've bitten the bullet, cloned the closure-common repo and decided to go with named-readtables. Very likely that if I publish these changes to quicklisp, implicitly taking maintainership, there will be ripple changes into other dependent packages that use #" and #/ reader macros provided by closure-common.
I'm a Lisp beginner trying to understand how to properly use Lisp package system while learning LTK for GUI programming, using SBCL 1.0.55.0.debian and Limp 0.3.4 (and Debian Wheezy if that matters). I have installed ASDF using aptitude package manager (packages cl-asdf & cl-common-lisp-controller), then I installed Quicklisp using the instructions on Quicklisp website (http://www.quicklisp.org/beta/index.html) (not from Debian repository) and then I have installed LTK with (ql:quickload 'ltk) in SBCL console.
hello-1.lisp (directly from LTK tutorial):
(defun hello-1()
(with-ltk ()
(let ((b (make-instance ’button
:master nil
:text "Press Me"
:command (lambda ()
(format t "Hello World!~&")))))
(pack b))))
If I compile this straight on in a new SBCL Lisp image, I get the message that WITH-LTK and PACK are undefined functions and 'BUTTON is undefined variable.
So, I found out that I need to load 'ltk first and then use in-package.I to be able to run it, I first have to use (ql:quickload 'ltk) and (in-package :ltk) in SBCL console. However, I still an error message that 'BUTTON is undefined variable.
* (ql:quickload 'ltk)
To load "ltk":
Load 1 ASDF system:
ltk
; Loading "ltk"
(LTK)
* (in-package :ltk)
#<PACKAGE "LTK">
* (compile-file "/home/user/code/lisp/hello-1.lisp")
; caught WARNING:
; undefined variable: ’BUTTON
;
; compilation unit finished
; Undefined variable:
; ’BUTTON
; caught 1 WARNING condition
; /home/user/code/lisp/hello-1.fasl written
; compilation finished in 0:00:00.009
#P"/home/user/code/lisp/hello-1.fasl"
T
T
*
Then, as this didn't work out as I wanted, I also attempted to define my own package definitions according to the answers of another question (Problems with ltk (common lisp)), Xach's blog entry "Making a small Lisp project with quickproject and Quicklisp" http://xach.livejournal.com/278047.html?thread=674335 and ASDF Manual (http://common-lisp.net/project/asdf/asdf/The-defsystem-form.html) using quickproject:make-project, but without success. Currently I have the following files:
package.lisp (compiles cleanly if I first (ql:quickload 'ltk) SBCL REPL):
(defpackage :hello-world-ltk-system
(:use :cl :asdf :ltk))
hello-world-ltk.asd (compiles cleanly after I have first compiled package.lisp):
(in-package :hello-world-ltk-system)
(asdf:defsystem :hello-world-ltk
:serial t
:description "Describe hello-world-ltk here"
:author "Your Name <your.name#example.com>"
:license "Specify license here"
:depends-on (:cl :asdf :ltk)
:components ((:file "package")
(:file "hello-world-ltk")))
hello-world-ltk.lisp (I get compile error The name "HELLO-WORLD-LTK" does not designate any package).
(require 'hello-world-ltk)
(in-package :hello-world-ltk)
(defun hello-world-1 ()
(with-ltk ()
(let ((b (make-instance 'button
:master nil
:text "Press me!"
:command (lambda ()
(format t "Hello world!~&")))))
(pack b))))
When I attempt to compile this hello-world-ltk.lisp after successfully compiling package.lisp and hello-world-ltk.asd (which all reside in the same directory) I get the following error:
; compiling (IN-PACKAGE :HELLO-WORLD-LTK)
debugger invoked on a SB-KERNEL:SIMPLE-PACKAGE-ERROR in thread
#<THREAD "initial thread" RUNNING {10029A0FA3}>:
The name "HELLO-WORLD-LTK" does not designate any package.
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
(SB-INT:%FIND-PACKAGE-OR-LOSE "HELLO-WORLD-LTK")
0]
(load "/home/user/code/lisp/hello-world-ltk/hello-world-ltk")
debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "initial thread" RUNNING {10029A0FA3}>:
attempt to load an empty FASL file:
"/home/user/code/lisp/hello-world-ltk/hello-world-ltk.fasl"
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Reduce debugger level (to debug level 1).
1: Exit debugger, returning to top level.
(SB-FASL::LOAD-AS-FASL
#<SB-SYS:FD-STREAM
for "file /home/user/code/lisp/hello-world-ltk/hello-world-ltk.fasl"
{1005291233}>
NIL
#<unavailable argument>)
0[2]
So, I'm quite lost here with all different ways to define packages, ASDF, Quicklisp, package.lisp, quickproject, asdf:defsystem, require and ql:quickload... quickproject:make-project looks promising, but I really don't know what's still wrong with my source files. I'm looking for a solution that should handle all the compilations and package loadings preferibly in one single command for the whole project and that should be extendable for bigger projects too.
Thank you for any help :)
The first problem in your code is that you use apostrophe (’) instead of tick ('). That's why you get undefined variable error, as ’button is read as variable name (it's not quoted).
Now regarding packages and systems. A package is defined with defpackage and it is a collection of symbols, which are used after the in-package form inside a file (or in interactive session). A package has internal and external (exported) symbols, that can be accessed as package::internal-symbol and package:external-symbol respectively. Packages can also import symbols from other packages. If you use-package, you import all its external symbols. While in-package switches the current package to the specified one and you start to define symbols in it (and it is not desirable to do such things in 3rd-party packages, like LTK). So if you want to use LTK symbols, like with-ltk or button, you just need to either use-package LTK or import these symbols from LTK in your defpackage form:
(defpackage :hello-world-ltk-system
(:use :cl)
(:import-from :ltk :with-ltk :button))
or simply import all LTK symbols (with use clause):
(defpackage :hello-world-ltk-system
(:use :cl :ltk))
Finally, systems and packages are totally unrelated things. A system is an instance of a class ASDF:SYSTEM, which holds information about physical files and their relations, so that they can be compiled and loaded appropriately. For your hello-world application I would suggest, that you don't bother about systems for now, and write all your code in one file. This file should start with a defpackage form, followed by in-package, and then the rest of your code.
When this file will grow large enough, that you'll see clear parts in it, you can factor out those parts into separate files. Then you'll have to create a system definition file, that will look like this:
(asdf:defsystem :hello-world
:depends-on (:ltk)
:serial t
:components ((:file "package")
(:file "first")
(:file "second")
...))
The "package.lisp" file will now hold your package definition.
I'm new to the whole JVM thing, and trying to play with clojure. I'm attempting to load clojure-contrib and failing:
# in bash
$ java -cp /path/to/clojure.jar:/path/to/contrib.jar clojure.main
# in REPL
user=> (require 'clojure.contrib.math)
nil
user=> (sqrt 2)
java.lang.Exception: Unable to resolve symbol: sqrt in this context (NO_SOURCE_FILE:10)
Any pointers will be great - thanks.
I'm no expert, but it seemed like a namespace issue. The solution I employed was this:
;; for REPL
user=> (ns user (:use clojure.contrib.math))
nil
user=> (sqrt 2)
1.4142135623730951
You should put refer after require which will map all the symbols into current namespace
(require 'clojure.contrib.math)
(refer 'clojure.contrib.math)
(sqrt 2)
(expt 2 3)
For detailed intro you may read wikibooks article.
http://en.wikibooks.org/wiki/Clojure_Programming/Concepts#Refer_and_Use
I have been reading a lot about Reinforcement Learning lately, and I have found "Reinforcement Learning: An Introduction" to be an excellent guide. The author's helpfully provice source code for a lot of their worked examples.
Before I begin the question I should point out that my practical knowledge of lisp is minimal. I know the basic concepts and how it works, but I have never really used lisp in a meaningful way, so it is likely I am just doing something incredibly n00b-ish. :)
Also, the author states on his page that he will not answer questions about his code, so I did not contact him, and figured Stack Overflow would be a much better choice.
I have been trying to run the code on a linux machine, using both GNU's CLISP and SBCL but have not been able to run it. I keep getting a whole list of errors using either interpreter. In particular, most of the code appears to use a lot of utilities contained in a file 'utilities.lisp' which contains the lines
(defpackage :rss-utilities
(:use :common-lisp :ccl)
(:nicknames :ut))
(in-package :ut)
The :ccl seems to refer to some kind of Mac-based version of lisp, but I could not confirm this, it could just be some other package of code.
> * (load "utilities.lisp")
>
> debugger invoked on a
> SB-KERNEL:SIMPLE-PACKAGE-ERROR in
> thread #<THREAD "initial thread"
> RUNNING {100266AC51}>: The name
> "CCL" does not designate any package.
>
> Type HELP for debugger help, or
> (SB-EXT:QUIT) to exit from SBCL.
>
> restarts (invokable by number or by
> possibly-abbreviated name): 0:
> [ABORT] Exit debugger, returning to
> top level.
>
> (SB-INT:%FIND-PACKAGE-OR-LOSE "CCL")
I tried removing this particular piece (changing the line to
(:use :common-lisp)
but that just created more errors.
> ; in: LAMBDA NIL ; (+
> RSS-UTILITIES::*MENUBAR-BOTTOM* ;
> (/ (- RSS-UTILITIES::MAX-V
> RSS-UTILITIES::V-SIZE) 2)) ; ; caught
> WARNING: ; undefined variable:
> *MENUBAR-BOTTOM*
>
> ; (-
> RSS-UTILITIES::*SCREEN-HEIGHT*
> RSS-UTILITIES::*MENUBAR-BOTTOM*) ; ;
> caught WARNING: ; undefined
> variable: *SCREEN-HEIGHT*
>
> ; (IF RSS-UTILITIES::CONTAINER ;
> (RSS-UTILITIES::POINT-H ;
> (RSS-UTILITIES::VIEW-SIZE
> RSS-UTILITIES::CONTAINER)) ;
> RSS-UTILITIES::*SCREEN-WIDTH*) ; ;
> caught WARNING: ; undefined
> variable: *SCREEN-WIDTH*
>
> ; (RSS-UTILITIES::POINT-H
> (RSS-UTILITIES::VIEW-SIZE
> RSS-UTILITIES::VIEW)) ; ; caught
> STYLE-WARNING: ; undefined function:
> POINT-H
>
> ; (RSS-UTILITIES::POINT-V
> (RSS-UTILITIES::VIEW-SIZE
> RSS-UTILITIES::VIEW)) ; ; caught
> STYLE-WARNING: ; undefined function:
> POINT-V
Anybody got any idea how I can run this code? Am I just totally ignorant of all things lisp?
UPDATE [March 2009]: I installed Clozure, but was still not able to get the code to run.
At the CCL command prompt, the command
(load "utilities.lisp")
results in the following error output:
;Compiler warnings :
; In CENTER-VIEW: Undeclared free variable *SCREEN-HEIGHT*
; In CENTER-VIEW: Undeclared free variable *SCREEN-WIDTH*
; In CENTER-VIEW: Undeclared free variable *MENUBAR-BOTTOM* (2 references)
> Error: Undefined function RANDOM-STATE called with arguments (64497 9) .
> While executing: CCL::READ-DISPATCH, in process listener(1).
> Type :GO to continue, :POP to abort, :R for a list of available restarts.
> If continued: Retry applying RANDOM-STATE to (64497 9).
> Type :? for other options.
1 >
Unfortuately, I'm still learning about lisp, so while I have a sense that something is not fully defined, I do not really understand how to read these error messages.
My guess is that the code is CCL-dependent, so use CCL instead of CLISP or SBCL. You can download it from here: http://trac.clozure.com/openmcl
That code is for Macintosh Common Lisp (MCL). It will only run there. Using Clozure CL (CCL) will not help. You would have to comment the graphics code. The random state stuff also is slightly special for MCL. You have to port it to portable Common Lisp (make-random-state, etc.). Also the file names are special for the Mac.
Clozure CL is a fork from Macintosh Common Lisp, but has be changed to Unix conventions (pathnames, ...) and does not include the special graphics code of MCL.
Using the latest version of CCL on linux x86, with this file saved as foo.lisp:
#+ccl (defun random-state (x y)
(ccl::initialize-random-state x y))
(load "utilities.lisp")
(use-package 'rss-utilities)
(load "testbed.lisp")
(setup)
(init)
(print (runs 10 10 .1))
Running
~/svn/ccl/lx86cl -l foo.lisp
prints a bunch of warning messages and the desired answer of:
(-0.77201915 0.59691894 0.78171235 0.41514033 0.6744591 0.26383805 0.8981678 1.1274683 0.50265205 0.4081622)
To figure out the required #'random-state defun, I guessed that the “#.(RANDOM-STATE 64497 9)” was a serialized random-state object from MCL. To see how CCL handles that, I checked what MAKE-RANDOM-STATE outputs in CCL:
$ ~/svn/ccl/lx86cl
Welcome to Clozure Common Lisp Version 1.3-r11936 (LinuxX8632)!
? (make-random-state)
#.(CCL::INITIALIZE-RANDOM-STATE 64497 9)
If you have never used lisp in a meaningful way, there is a Matlab code for "Reinforcement Learning: An Introduction".
In addition to Rainer Joswig's answer: Once you install Clozure you'll have to update references to the function RANDOM-STATE in utilities.lisp to random-mrg31k3p-state.
More specifically replace: #.(RANDOM-STATE 64497 9) with #.(ccl::random-mrg31k3p-state)
random-mrg31k3p-state seems to have replaced random-state sometime after the code was written see l1-numbers.lisp?rev=13327