Questions tagged [lisp]

Lisp is a family of general purpose programming languages, influenced by the lambda calculus, and with the ability to manipulate source code as a data structure.

Introduction

The name Lisp derives from "LISt Processor". It was originally created as a practical mathematical notation for computer programs. See Wikipedia for more information.

Hello World Program in Lisp

;;; Hello World in Common Lisp

(defun helloworld ()
  (print "Hello World!"))

Popular dialects

Free Lisp Programming Books

There is also a Stack Overflow chat room on Lisp.

6922 questions
5
votes
1 answer

Lexical closures over macrolet?

Is there a way to do something like lexical closures using macrolet? What I want to do is make the following macro a local recursive helper that calls a function on each combination instead of generating a list as it does now calling the macro in…
asm
  • 8,758
  • 3
  • 27
  • 48
5
votes
3 answers

Side effects in Lisp/Clojure

My question is about structuring lisp code with side effects. The particular example I have in mind comes from Clojure, but I think it can apply to any lisp. In this case, I am interacting with an existing library that requires some functions to be…
munk
  • 12,340
  • 8
  • 51
  • 71
5
votes
1 answer

additional properties to slot definition

http://mop.lisp.se/concepts.html says: An implementation is free to add additional properties to the canonicalized slot specification provided these are not symbols accessible in the common-lisp-user package, or exported by any package …
user1312837
  • 1,268
  • 1
  • 11
  • 29
5
votes
1 answer

cross-package defgeneric/defmethod in Common Lisp?

What is the right way to define a generic in package A and to provide a method for this generic in package B in CLOS? Thank you in advance! Example: (defpackage :common (:use :cl)) (in-package :common) (defgeneric compare (a b)) (defmethod…
Damg
  • 406
  • 3
  • 9
5
votes
5 answers

HOWTO definition and usage of Common Lisp packages (libraries)?

I have developed some Common Lisp functions in a couple of Lisp source files that I'd like easily available to other functions I write, or make available on github if I think they'd be useful for someone else. For now, I've just been putting them in…
lurker
  • 56,987
  • 9
  • 69
  • 103
5
votes
1 answer

make-keyword-map in Clojure - Idiomatic?

I have been writing some Clojure recently, and I found myself using the following pattern frequently enough: (let [x (bam) y (boom)] {:x x :y y}) So I went ahead and wrote the following macro: (defmacro make-keyword-map [& syms] …
missingfaktor
  • 90,905
  • 62
  • 285
  • 365
5
votes
3 answers

let inside cond

I'm working with clojure and while I've dabbled with lisps before, I'm having trouble finding a clean way to nest let statements in cond statements. For example, consider the following function: (defn operate-on-list [xs] (let [[unpack vector]…
So8res
  • 9,856
  • 9
  • 56
  • 86
5
votes
2 answers

Connect SBCL on Windows to SQL Server using Integrated Authentication

What is the path of least resistance in getting an SBCL application running on Windows to connect to a SQL Server instance, using integrated authentication? I have found posts on connecting from CL-SQL to SQL Server using ODBC connections but as far…
futuranon
  • 190
  • 8
5
votes
4 answers

Conditionals in Elisp's cl-loop facility

I'm trying to wrap my head around Elisp's cl-loop facility but can't seem to find a way to skip elements. Here's an artificial example to illustrate the problem: I'd like to loop over a list of integers and get a new list in which all odd integers…
tmalsburg
  • 354
  • 2
  • 11
5
votes
1 answer

SICP Infinite Streams (Chapter 3.5.2)

This is a question related to the SICP Book Chapter 3.5.2. I'm implementing a stream data structure in other programming languages. And I'm not sure if I understand the following snippet correctly. (define (integers-starting-from n) …
Yeo
  • 11,416
  • 6
  • 63
  • 90
5
votes
2 answers

With case, which is the best of these methods for expressing the cases?

These all work: (defun testcaseexpr (thecase) (case thecase ('foo (format t "matched foo")) (bar (format t "matched bar")) ((funk) (format t "matched funky")))) Which of these three expressions is considered the idiomatic way? And…
johnbakers
  • 24,158
  • 24
  • 130
  • 258
5
votes
2 answers

Why is elt not as common as car, cdr, first, rest?

I see this a lot in examples I read in books and articles: (caddr *something*) Or the many variants of c***r commands. It seems a bit ridiculous to me, when you can more clearly just pull things out with elt: (elt *something* 2) But I don't see this…
johnbakers
  • 24,158
  • 24
  • 130
  • 258
5
votes
1 answer

defparameter vs defun for passing functions around

So I can do this: (defparameter *some-function* ... ; returns lambda later or this: (defun some-function ... With either, I can use funcall: (funcall 'some-function ... or (funcall *some-function* ... With the defun version I can also do…
johnbakers
  • 24,158
  • 24
  • 130
  • 258
5
votes
2 answers

What gives Lisp its excellent math performance?

I am reading this in a Lisp textbook: Lisp can perform some amazing feats with numbers, especially when compared with most other languages. For instance, here we’re using the function expt to calculate the fifty-third power of 53: CL> (expt 53 53)…
johnbakers
  • 24,158
  • 24
  • 130
  • 258
5
votes
1 answer

Getting emacs to turn things on at startup

Whenever I start emacs, there are a few things I do right away: M-x slime M-x ido-mode I also open a few files that I always use so they are available as buffers: C-x C-f .... When I get into a buffer, I then do this for that buffer (nearly all…
johnbakers
  • 24,158
  • 24
  • 130
  • 258