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
3 answers

How to recursively reverse a list using only basic operations?

I was wondering how to reverse a list using only basic operations such as cons, first, rest, empty?, etc. No helper functions or accumulators allowed, and the function only takes one input - a list. I was told it was possible, though I can't wrap…
b33k3rz
  • 173
  • 1
  • 8
5
votes
1 answer

newline after every third word in a list with cl:format

How can I to add a carriage return (using ~%) after every third argument in a list? E.g., I have now: (format nil "~{~a ~}" (list '"one" '"two" '"three" '"four" '"five" '"six" '"seven" '"eight" '"nine" '"ten")) ;=> "one two three four five six…
Martin Mohan
  • 1,366
  • 12
  • 8
5
votes
3 answers

How are function parameters stored in lisp?

I assumed that values passed into a lisp function are assigned to a quote matching the name of the parameter. However, I was surprised that this: (defun test (x) (print (eval 'x))) (test 5) doesn't work (the variable x is unbound). So if parameters…
rcorre
  • 6,477
  • 3
  • 28
  • 33
5
votes
2 answers

Determining a supertype path

Given a variable with content 1, I know that it's a member of at least five types: 1 (let* ((fred 1)) 2 (princ (typep fred 'bit)) (terpri) 3 (princ (typep fred 'integer)) (terpri) 4 (princ (typep fred 'fixnum)) (terpri) 5 (princ (typep…
Bill Evans at Mariposa
  • 3,590
  • 1
  • 18
  • 22
5
votes
1 answer

Lisp : How do I install gcl in mac

I have Mac OSX 10.8.4. I have cloned the git repo of gcl and as per the readme I ran the ./configure. But, I am getting the following error : configure: error: Cannot build with randomized sbrk. Your options: - upgrade to a kernel/libc that knows…
quickbrownfox
  • 161
  • 1
  • 14
5
votes
3 answers

What distinguishes a continuation from a function?

Continuation describes what happens next with some value, right? Isn't that just a function that takes a value and does some computation? (+ (* 2 3) 5) the continuation of (* 2 3) is (+ _ 5) (define k (lambda (v) (+ v 5))) What is the point of…
ayhid
  • 475
  • 2
  • 10
5
votes
4 answers

How to set local function definition using function (or closure) objects?

The problem with flet is that the functions bound therein must be defined inline. In other words, there's no way to do this: (new-flet ((a (lambda (f x) (funcall f (* x 2)))) (b (function-generator))) (a #'b 10)) I…
nbtrap
  • 581
  • 2
  • 12
5
votes
2 answers

python equivalent of quote in lisp

In python what is the equivalent of the quote operator? I am finding the need to delay evaluation. For example, suppose in the following lisp psuedocode I have: a = '(func, 'g) g = something (eval a) What I am doing is deferring evaluation of g…
CodeKingPlusPlus
  • 15,383
  • 51
  • 135
  • 216
5
votes
4 answers

Filter a list into two parts by a predicate

I want to do (filter-list-into-two-parts #'evenp '(1 2 3 4 5)) ; => ((2 4) (1 3 5)) where a list is split into two sub-lists depending on whether a predicate evaluates to true. It is easy to define such a function: (defun filter-list-into-two-parts…
wrongusername
  • 18,564
  • 40
  • 130
  • 214
5
votes
2 answers

Statically-typed dialect of Lisp with type inference, for Windows?

Is there any statically-typed dialect of Lisp that performs type inference and is compatible with Windows? I have found CMUCL but it doesn't seem to have a Windows-compatible version.
user541686
  • 205,094
  • 128
  • 528
  • 886
5
votes
1 answer

Class finalization: how to avoid creating dummy instances?

I've run into a problem that a third-party library needs to act on a class as if it was finalized. After some reading I understand the motivation behind this mechanism, but I don't really know how it functions. Example: (make-instance 'expression…
user797257
5
votes
2 answers

Weird code example from "Realm of Racket"

I am currently reading the book "Realm Of Racket", which I really like so far. However, in chapter 4 1/2, on page 74, there is one code example that I just don't get. Maybe my mind refuses to figure it out because I am on vacation, however, I simply…
typeduke
  • 6,494
  • 6
  • 25
  • 34
5
votes
2 answers

"Unable to resolve symbol" error in Clojure program

When I paste this code into a REPL, it works fine: (use 'clojure.contrib.seq-utils) (defn- random-letter [] (char (+ (rand-int 26) 97))) (defn- random-digit [] (rand-int 10)) (defn- random-password "Returns an 8-character password consisting of…
foxdonut
  • 7,779
  • 7
  • 34
  • 33
5
votes
3 answers

Not return anything from LISP/Scheme

Basically, I would like to use map to do selection in a list like (define tbl '(a b c d)) (map (lambda (item 'c) (if (eq? item 'c) item (...what in else?) ))) The result I want is '(c) I tried leave the else part empty, it complains that the else…
Alfred Zhong
  • 6,773
  • 11
  • 47
  • 59
5
votes
1 answer

sbcl encoding error only when executed from prompt?

I have a code that if executed from the slime prompt inside emacs run with no error. If I started sbcl from the prompt, I got the error: * (ei:proc-file "BRAvESP000.log" "lixo") debugger invoked on a SB-INT:STREAM-ENCODING-ERROR: :UTF-8 stream…
Alexandre Rademaker
  • 2,683
  • 2
  • 19
  • 21