Section 3.5 of Structure and Interpretation of Computer Programs describes streams. Does Common Lisp have such streams built in or is there a good Common Lisp library implementing such streams?
[I mean streams in all the generality presented in section 3.5 of SICP; not just your usual i/o streams.]
...
In terms of scope? Actual implementation in memory? The syntax? For eg, if (let a 1) Is 'a' a variable or a symbol?
...
Problem 19-2 in "Lisp" by Winston and Horn states,
In depth-first search, all of the
partial paths in the queue at a given
point in the search are related to
one another in a simple way: each is
the extension by one node of the
partial path after it in the queue.
The queue might, for example, look
like this:
...
I define a function in LISP, and it defines correctly. But whenever I try to call it, I get an error saying "The variable FACTORIAL is unbound."
I have tried this on both OS X and Windows 7, on LispWorks and Allegro. The function is -
(defun factorial (x)
(if (= 1 x) 1
(* x factorial (- 1 x))))
Any help is appreciated.
...
I'm currently learning how to write CL style macros (define-macro) in Scheme. As a simple example, I wrote a struct macro that defines functions like make-thing, thing?, thing-field accessors and so on.
Now I'd like to combine multiple defines in a single macro, but only the last one is actually used. Currently I'm using eval to define ...
In my class definition, I want to initialize one slot based on the value of another slot. Here is the sort of thing I would like to do:
(defclass my-class ()
((slot-1 :accessor my-class-slot-1 :initarg slot-1)
(slot-2 :accessor my-class-slot-2 :initform (list slot-1))))
However this doesn't compile:
1 compiler notes:
Unknown l...
I'm trying to learn Lisp now, as a supplement to my CS1 course because the class was moving too slow for me. I picked up "Practical Common Lisp," which so far has turned out to be a great book, but I'm having some trouble getting some examples to work. For instance, if I load the following file into the REPL:
;;;; Created on 2010-09-01 ...
I'd like to setf different fields of a struct depending on a certain variable. I decided to use the following approach:
Generate a string with the field's accessor name:
(setq my-string (format nil "STRUCT-ESTADISTICAS-NUM-~S" x))
and then use intern with funcall:
(funcall (intern my-string) *estadisticas*)
This call returns t...
I'm working on OS X 10.6.4. I've been using clbuild to install supporting libraries for SBCL (including clsql), and I do all my work through Aquamacs. I installed MySQL using the excellent instructions over at Hive Logic. But when I call (require 'clsql) -- which seems to work fine -- and then try to execute (clsql:connect '(nil "lisp" "...
The following page talks about how atoms work in Clojure. It doesn't say a whole lot about the differences between atoms in Clojure and other lisp dialects.
What is the primary difference between an atom in Common Lisp and an atom in Clojure? (What is missing from the definition of atom in Clojure that exists in CL?)
...
Given a function:
(defun foo (bar)
(let ((baz bar))
(setf baz (+ baz 1)))
I have been given to understand (perhaps incorrectly?) that baz becomes some sort of reference to bar, instead of being a true copy of bar.
What I would like to do is create a true temporary variable so that I can ensure that I can muck about with the pass...
My professor has given us a refresher assignment in clisp. One exercise is to achieve the same thing in three ways: Return a flattened list of all positive integers in a given list.
Now, there's only one way I really like doing this, using cons and recursion, but he wants me to do this using mapcan and a loop (I suspect lisp is not his...
I was messing around in SLIME (connected a Clozure REPL) when I discovered this:
It looks like the variables +, *, and / are all bound to some variation on recent input, + is the input itself, * is the result of evaluating that input, and / is the result contained in a list.
Is this right? Who is responsible for this, SLIME or Clozure?...
Given the following definition of the LISP eval function - what is required to add the defmacro function? (Or even just evaluate a macro)
(defun null. (x)
(eq x '()))
(defun and. (x y)
(cond (x (cond (y 't) ('t '())))
('t '())))
(defun not. (x)
(cond (x '())
('t 't)))
(defun append. (x y)
(cond ((null. x) ...
Say I have a function that takes a list and does something:
(defun foo(aList)
(loop for element in aList ...))
But if the list is nested I want to flatten it first before the loop does stuff, so I want to use another function (defun flatten(aList)) that flattens any list:
(defun foo(flatten(aList))
(loop for element in aList .....
How do I figure out how many bytes a defclass object has in Common Lisp?
...
Why is it that the Common Lisp array syntax is not evaluating its arguments:
(let ((a 1)) #2A((a 2) (3 4)))
=> #2A((A 2) (3 4))
I would have guessed it was #2A((1 2) (3 4)). Is this because A is not available at reader time?
...
I wonder if some functional languages are used for web development and which are most useful and supported with that goal?
...
Is there a way to dereference a list in lisp?
I am trying to compare 2 strings but one is in a list.
...
Newbie Common Lisp question here.
Is there a way to reset the state of the environment? What I mean, is there some command that brings the REPL back to the same state it was right after it started up, that is, uninterning all variables, functions, etc. Or if that's not in the Common Lisp standard, is there some extension in SBCL (the im...