common-lisp

lisp delete list

I am having a bit problem on how to extract inside a list of a list. (defun delete (a l) (cond ((null l) nil) ((eq (car l) a) (delete a (cdr l))) (t (cons (car l) (delete a (cdr l)))))) it deletes whatever is 'a' in a list l but if l consists of another list and a is in that inner list then my program cudnot ...

Common Lisp: deleting unreachable code.

This is an easy one. (let ((x)) (if (typep x 'null) "a" "b")) generate a warning about unreachable code deletion. Presumably the compiler was smart enough to figure that it is only executed once and the type will always be null. I wouldn't normally write that code, but in this case I just don't want the code deletion notice in my outp...

Checking whether every list in a list is null in Common Lisp

I know that I can check whether a list of lists only contains null lists like this CL-USER> (null (find-if (lambda (item) (not (null item))) my-list)) where my-list is a list of lists. For example: CL-USER> (null (find-if (lambda (item) (not (null item))) '(nil (bob) nil))) NIL CL-USER> (null (find-if (lambda (item) (not (null item)...

Swapping elements in a Common Lisp list.

Is there a Common Lisp function that will swap two elements in a list given their indices and return the modified list? ...

Have some way to save the REPL state of Common Lisp or Scheme?

Have some way to save the REPL state of Common Lisp or Scheme? Thanks ...

large output in common lisp linux terminal

I wrote a clisp program that prints out n sets of x*y random integers. I'd like to make n=100, but I can't copy and paste the whole thing because my linux terminal doesn't go back far enough, for lack of a better word. I'd like the simplest way possible to capture 2200 lines of linux terminal readout. ...

XML Data Binding for Common Lisp

I'm interested in finding a code generation tool that, given a set of XSD files, will generate a set of CLOS classes from XSD, generate deserialisation routines from XML to CLOS and generate the corresponding serialisation routines. The closest project that I've been able to find is CL-SOAP but it seems to be at an early stage. I need su...

Common Lisp Wildcard for eql

Is there a wildcard in Common Lisp that is eql to any atom? That is, is there any wildcard such that (eql wildcard any-atom) returns true? ...

cl-pdf output error

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...

How would one interleve elements of 2 lists in LISP?

Given 2 lists, how can you produce an output of a 3rd list which has it's elements as an interleaved set of L1 and L2? if they are uneven length, nil should be inserted for holes. On a second note, how can I reverse a list? I've super new to LISP and simply modifying existing code... I'd really love to have a good explanation, not jus...

Invoking a CLIM UI from an application

In order to run a CLIM UI, the generic function clim:run-frame-top-level must be invoked, however this function blocks until the UI exits. This would seem to require all application control be handled via the CLIM top level. Is it possible to structure an application differently such that a control-flow outside of the CLIM top level is ...

Play MIDI file from Common Lisp

Is it possible to play a MIDI file (existing on the hard drive) from Common Lisp? If so, how? ...

Common Lisp Error Not Understood

I'm trying to write a number guessing game in Lisp as a time-killing project. However, when I try to load up the program using SBCL, I get the following error: debugger invoked on a SB-C::INPUT-ERROR-IN-COMPILE-FILE in thread #<THREAD "initial thread" RUNNING ...

Read Statement Being Skipped Over, Unbound Variable

I'm still working on my number guessing game in Common Lisp, and I've reached a standstill. When the following code is invoked: ;;;; number-game.lisp ;;;; ;;;; Andrew Levenson ;;;; 10/25/2010 ;;;; ;;;; Simple number guessing game. User has ;;;; five guesses to determine a number between ;;;; one and one hundred, inclusive (1-100). ;;; ...

Integer Value is Not a Number in Common Lisp?

When I execute the following Common Lisp program by calling (play), I get the error: Argument X is not a NUMBER: Guess ;;;; number-game.lisp ;;;; ;;;; Andrew Levenson ;;;; 10/25/2010 ;;;; ;;;; Simple number guessing game. User has ;;;; five guesses to determine a number between ;;;; one and one hundred, inclusive (1-100). ;;; Set globa...

(Random) in Common Lisp Not So Random?

Okay, final question and I'll have finished my number guessing game in Common Lisp! :D Whenever the game starts (or a new game begins after the first game), the following function is called. ;;; Play the game (defun play () ;; If it's their first time playing this session, ;; make sure to greet the user. (unless (> *number-o...

Making an instance of midi:midifile

I'm using a Lisp MIDI library for a small project I'm working on. Just to get started, I'm trying to write a simple MIDI file that plays middle C. However I can't seem to get this to work and can not find any documentation on how to do this sort of thing. Here is my code: (defun make-track () (list (make-instance 'midi:note-o...

CLOS for Clojure?

Does there exist anything like CLOS (Common Lisp Object System) for Clojure? If there isn't, how hard would it be to write one? Thanks in advance. -- Eric Grindt ...

Illegal Function Call in Common Lisp

I'm working on making a two player tic-tac-toe game, and am in the phase where I work out all of the errors in my code. The current error i'm stuck on is an illegal function call error in the following code: (cond [...snip...] ((= CHOICE 3) (IF (NUMBERP (AREF *BOARD* 0 2)) (SETF (AREF *BOARD* 0 2) *MARKER*) (INVALID-SELECTI...

Checking for a win in Tic-Tac-Toe

Okay, so I'm about finished with my latest project, a (admittedly not very good) implementation of Tic Tac Toe in Common Lisp (the whole program available here), but I'm stuck on one last part; I can't figure out how to get my function that checks for a winner working. The function (and its subordinate function) look like this: (defun c...