common-lisp

idiomatic way to replace (null x) function from common lisp in clojure

In Common Lisp you use the (null x) function to check for empty lists and nil values. Most logically this maps to (or (nil? x) (= '() x)) In clojure. Can someone suggest a more idiomatic way to do it in Clojure? ...

Clisp + Emacs compile-and-load-file

Hello, Starting to learn Common lisp. Instal in my debian 5.03 clisp, emacs-23.1 and slime. Write in .emacs: (setq inferior-lisp-program "/usr/bin/clisp") ; your Lisp system (add-to-list 'load-path "/home/slime/") ; your SLIME directory (require 'slime) (slime-setup '(slime-scratch slime-editing-commands slime-repl)) ...

SQLITE user-defined functions in Lisp

In SQLITE there is a possibility to relatively easily create User-Defined Functions and Aggregates in (extension) languages such as C, Perl, Python and others. Is there also such possibility using common-lisp as SQLITE language extension? I know there are libraries like cl-sqlite and plain-odbc but they don't seem to offer this possibil...

Package RCL and Inf

Hi, this will be a difficult question to answer, I contacted the author but still no replies I'll give it a shot here: In the package RCL (http://common-lisp.net/project/rcl/) examples: (in-package :rcl) (r-init) (r "/" 1 5) RCL> 0.2d0 (r "print" (r% "/" 1 5)) RCL> ;R# 1 0.2 0.2d0 The above is ok, but (r "/" 1 0) RCL>> # broken (r ...

Why #' is used before lambda in Common Lisp?

Hello! I would like to know why most Common Lisp code I see has things like (mapcar #'(lambda (x) (* x x)) '(1 2 3)) instead of just (mapcar (lambda (x) (* x x)) '(1 2 3)), which seems to work as well. I am beginning to learn Common Lisp, and having some background in Scheme, this intrigues me. Edit: I know that you need #' with fu...

Why multiple namespaces?

What is the rationale behind the design decision to have separate namespaces for values and functions in Common Lisp? What are the arguments for and against it? ...

Common Lisp: What is the downside to using this filter function on very large lists?

I want to filter out all elements of list 'a from list 'b and return the filtered 'b. This is my function: (defun filter (a b) "Filters out all items in a from b" (if (= 0 (length a)) b (filter (remove (first a) a) (remove (first a) b)))) I'm new to lisp and don't know how 'remove does its thing, what kind of time will thi...

lisp interpreter

Possible Duplicate: Whats a good Common Lisp implementation for Windows? where can I get common lisp interpreter for windows? ...

Easy way to merge plists?

Is there an easy way in Common Lisp to merge two plists? Or from another point of view: is there a way to remove duplicates from a plist? I know I can just append plists (and GETF will take the first one it finds), but I'd like to not keep accumulating unused keys as my app runs. I'm thinking about something like (loop for p on my-pli...

Concise Lisp code to apply a list of functions all to the same argument(s) and get a list of the return values?

Suppose I have a single element, and I have a list of predicates (functions). I want to apply each of these predicates to the single element and get a corresponding list of return values. I know that map and friends can apply a single function to each a list of arguments, but is there any concise syntax to apply many functions to a singl...

When does format actually print in Common Lisp?

I have the following Common Lisp code: (defun micro-read-eval-print () (format t "Micro > ") (let ((form (read-line))))) When I run it, I get the following: CL-USER> (micro-read-eval-print) (m-quote a) Micro > NIL Note that I typed in "(m-quote a)", while the Lisp interpreter output "Micro > NIL". Now, I would have expecte...

with-open-file explanation in layman terms.

I'm learning CL, and I have minimal experience in other languages. Could someone explain to me in layman terms what this means, especially what "out" here represents, and how it all fits together: (defun save-db (filename) (with-open-file (out filename :direction :output :if-exists :supersede) ...

Online tutorial on lisp

Any online tutorial on lisp which can teach the basics (loop, condition and etc) of this language in a short time? ...

Unexpected output with cons()

I am from an imperative background but these days trying my hands on LISP (Common LISP) I read here about cons that (cons x L): Given a LISP object x and a list L, evaluating (cons x L) creates a list containing x followed by the elements in L. When I intentionally did not use a list as the second argument i.e when I used (co...

How many primitives does it take to build a LISP machine? Ten, seven or five?

On this site they say there are 10 LISP primitives. The primitives are: atom, quote, eq, car, cdr, cons, cond, lambda, label, apply. http://hyperpolyglot.wikidot.com/lisp#ten-primitives Stevey reckons there are seven (or five): Its part of the purity of the idea of LISP: you only need the seven (or is it five?) primitives to build ...

What are the advantages of scheme macros?

Why would anyone prefer Scheme macros over Common Lisp macros (and I genuinely want to know too, I'm not trying to be a troll)? My experience as a Lisp newb is that Common Lisp style macros are much easier to learn than Scheme's macros. I have yet to see any advantages to Scheme's macros, but of course that doesn't mean they don't exis...

Swapping rows and columns in common lisp

I am trying to swap 'rows' and 'columns' in common lisp. Comments delineate my logic. (setq thingie '((1 2 3) (4 5 6) (7 8 9))) ;;test case (defun rotate (mat) (if (car mat) (let ((top (mapcar 'car mat)) ;;slice the first row off as a list (bottom (mapcar 'cdr mat))) ;;take the rest of the rows (cons top (ro...

Difference between let* and set? in Common Lisp

I am working on a genetic programming hobby project. I have a function/macro setup that, when evaluated in a setq/setf form, will generate a list that will look something like this. (setq trees (make-trees 2)) ==> (+ x (abs x)) Then it will get bound out to a lambda function #<FUNCTION :LAMBDA (X) ... > via strategic use of function...

Scheme or Common Lisp?

Hello! I am an intermediate programmer, and have decided to learn either common lisp or scheme. My question is simple, which one would you choose? I don't care much for the difficulty of the syntax, just the power, flexibility, and other aspects of the language itself. Also, which implementation of either common lisp or scheme should I c...

Serial port communication in common lisp

Is there a library for serial port communication in Common Lisp on Windows? ...