common-lisp

Do you have a mnemonic for remembering the meaning of car and cdr?

Most of my Lisp experience comes from Elisp. As such, I find myself writing Lisp only on occasion. By the time I come back to it, I often forget the difference between car and cdr and need to reference the docs to jog my memory. What kinds of clever mnemonics do you use to remember the difference between Lisp functions that have nam...

Getting field names and types in CLSQL from a result set

So I'm looking to modify the CLSQL abstractions to suit my own needs. I've been using the clsql-sys package and that's suited most of my needs. However, I can't seem to find how to get a list of field names and field types from the result set. In fact, I just seem can't to find anything ANYWHERE to get types (names I can just hack into t...

CLSQL symbol exports

Does anyone know about how the clsql-sys methods get exported to the clsql-sys/cl-user package? The methods are defined individually for each database type. For example, suppose I define a method in db-mysql/mysql-sql.lisp in package clsql-mysql: (defpackage #:clsql-mysql (:use #:common-lisp #:clsql-sys #:mysql #:clsql-uffi) (:export #...

What is the Definition of a Lisp Cons Cell?

What exactly is the definition of a Common Lisp Cons Cell? How is a Cons Cell different than a standard linked list item? After all, both the cons cell and the linked list item have a value and a pointer to the next cell or item... or is this understanding wrong? ...

What Lisp is better at parsing?

I'd like to implement a Lisp interpreter in a Lisp dialect mainly as a learning exercise. The one thing I'm thrown off by is just how many choices there are in this area. Primarily, I'm a bit more interested in learning about some of the Lisps that have been around a while (like Scheme or Common Lisp). I don't want to use Clojure to d...

How to call particular function depending on variable that's passed in?

I'm fairly new to lisp but I've been playing around with it. I have several problems which I need clarifying. Below is my little macro that I defined. (defmacro transform (query) '(lambda (row) (eq (nth 1 query) (nth 0 (nth 0 row))) ) ) I'm just wondering, how can I specify the function to use in the body dynamically? Like say i...

How to use Lispworks comm package for SSL access in Postmodern instead of cl+ssl

On XP, I'd like to use Postmodern in Lispworks to use the database on a server via SSL. It looks like CL+SSL has a problem with setting up a unilateral SSL connection. Lispworks works fine. Is there a way to get Postmodern to use the socket set up by Lispworks instead of one by CL+SSL? Or is there a version of CL+SSL which can make a un...

Calling C++ (not C) from Common Lisp?

Hello, I am wondering if there is some way to call C++ code from Common Lisp (preferably portably, and if not, preferably in SBCL, and if not, well, then Clozure, CLisp or ECL). The C++ would be called inside loops for numeric computation, so it would be nice if calls were fast. CFFI seems to not support this: "The concept can be ...

Unilateral SSL with CL+SSL package

In Lispworks on XP when I do: CL-USER 489 > (cl+ssl:make-ssl-client-stream (cl+ssl:stream-fd standard-output)) I get: Error: A failure in the SSL library occurred on handle #. (Return code: 1)SSL error queue: error:140C5042:SSL routines:SSL_UNDEFINED_FUNCTION:called a function you should not call Is this something I'm doing wrong? ...

Common Lisp function or idiom for creating a temporary file name?

Is there a Common Lisp function or typical way for creating a temporary file name or file? ...

Simple issue with subseq (LISP)

I just started using LISP, coming from a background in C. So far its been fun, although with an incredible learning curve (I'm an emacs newbie too). Anyway, I'm having a silly issue with the following code to parse include statements from c source - if anyone can comment on this and suggest a solution, it would help a lot. (defun inclu...

How do I iterate through a directory in Common Lisp?

I'm using OpenMCL on Darwin, and I'd like to do something like: (loop for f in (directory "somedir") collect (some-per-file-processing f)) But I can't get directory to return anything other than NIL, and I can't seem to find any good explanation online (other than "its different for each system"). Any pointers? ...

Looking for a particular Common Lisp implementation

I'm looking for a Common Lisp implementation I ran across once, sometime in the past year or two. I only remember a few things, and I don't know how to search for it based on these facts, so maybe somebody here can help. it was open-source, but wasn't one of the big ones (SBCL, CMUCL, MCL, etc.) it was likely incomplete; it looked alm...

Using string object as a hash key in Common Lisp

Hi folks, I'm trying to create a "dictionary" type - ie hash table with a string as a key. Is this possible or wise in Lisp? I noticed that this works as expected: > (setq table (make-hash-table)) #<HASH-TABLE :TEST EQL size 0/60 #x91AFA46> > (setf (gethash 1 table) "one") "one" > (gethash 1 table) "one" However, the following does ...

What is the difference between '(a b c) and (list 'a 'b 'c)?

I am reading "On lisp" and encounter this code (I simplified a bit). CL-USER> (defun foo () '(a b c)) FOO CL-USER> (foo) (A B C) ...

Updating font-lock keywords in emacs without major mode reload

I am doing small modification to SLIME, so that I can get all currently loaded symbols from Lisp, analyze them and make font-lock fontify them. I managed to do all these steps, but I have a small problem - when keyword list changes in font-lock the buffer is not updated unless you restart the major lisp-mode. I don't want to restart lis...

In CL Postmodern what :col-type to use for Many to Many field?

When defining a database access object for use in cl-postmodern, what should the :col-type be for a Many to Many field? ...

How do I tell if the value of a variable is a symbol bound to a procedure in Scheme?

I am familiar with Common Lisp and trying to learn some Scheme, so I have been trying to understand how I'd use Scheme for things I usually code in Common Lisp. In Common Lisp there's fboundp, which tells me if a symbol (the value of a variable) is bound to a function. So, I would do this: (let ((s (read))) (if (fboundp s) (app...

In common-lisp, how do I modify part of a list parameter from within a function without changing the original list?

I'm trying to pass a list to a function in Lisp, and change the contents of that list within the function without affecting the original list. I've read that Lisp is pass-by-value, and it's true, but there is something else going on that I don't quite understand. For example, this code works as expected: (defun test () (setf origina...

Parsing numbers from strings in lisp

Here's the brief problem: Input: a list of strings, each containing numbers (" 3.4 5.4 1.2 6.4" "7.8 5.6 4.3" "1.2 3.2 5.4") Output: a list of numbers (3.4 5.4 1.2 6.4 7.8 5.6 4.3 1.2 3.2 5.4) Here's my attempt at coding this: (defun parse-string-to-float (line &optional (start 0)) "Parses a list of floats out of a given string" ...