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

Tool to generate step by step box diagrams for Lisp

Is there a tool that takes a short Lisp code snippet and then generate a series of box diagrams to represent state for each step of the code? I am thinking of something like this: Online Python Tutor. Something like this can be good for answering…
Jisang Yoo
  • 3,670
  • 20
  • 31
5
votes
1 answer

Why does print-circle default to nil?

CLHS says An attempt to print a circular structure with *print-circle* set to nil may lead to looping behavior and failure to terminate. And then there's this: Why does this Lisp macro as a whole work, even though each piece doesn't…
Le Curious
  • 1,451
  • 1
  • 13
  • 13
5
votes
2 answers

Scheme (Lazy Racket) an infinite list of natural numbers

I think that Lazy Racket should be useful for handling infinite lists. According to the Wikipedia Lazy Racket article, fibs (the infinite list of Fibonacci numbers) can be defined as: ;; An infinite list: (define fibs (list* 1 1 (map + fibs (cdr…
user1028880
5
votes
2 answers

Why (apply and '(1 2 3)) doesn't work while (and 1 2 3) works in R5RS?

I tried it in Racket like this > (apply and '(1 2 3)) . and: bad syntax in: and > (and 1 2 3) 3 Does anyone have ideas about this?
Hanfei Sun
  • 45,281
  • 39
  • 129
  • 237
5
votes
1 answer

"Fake" global lexical variables in Common Lisp

It is stated in section "Global variables and constants" of the Google Common Lisp Style Guide that: "Common Lisp does not have global lexical variables, so a naming convention is used to ensure that globals, which are dynamically bound, never have…
Paulo Tomé
  • 1,910
  • 3
  • 18
  • 27
5
votes
2 answers

From Google Common Lisp Style Guide: "Avoid modifying local variables, try rebinding instead" meaning?

Google Common Lisp Style Guide say Avoid modifying local variables, try rebinding instead What does it mean? What does rebinding mean in that sentence?
Le Curious
  • 1,451
  • 1
  • 13
  • 13
5
votes
3 answers

About "cond" in scheme

I want to be able to do this. For example, this is my code: (cond [true AA] [else BB]) In AA, I want it to do 2 things. 1 is to set the value of a global variable, and then return a string. How would I go about doing that?
nonion
  • 826
  • 2
  • 9
  • 18
5
votes
2 answers

SICP 1.31: Approximating Pi

I'm working through SICP on my own, so I don't have an instructor to ask about this. This code is supposed to approximate pi but always returns zero instead. (define (approx-pi acc) (define (factors a) (define basic-num (if (= (mod a…
gregsabo
  • 430
  • 2
  • 9
5
votes
4 answers

Common lisp push from function

I have the following common lisp functions: (aggregate line1 line2) and (queuer data result). queuer should push into result either the values line1 and line2 if they have the 1st field different, or the aggregate of those 2 lines if they have the…
emanuel.manea
  • 71
  • 1
  • 8
5
votes
1 answer

Why (list + 1 2) evaluates to ('(+ 1 2) 1 2) in Common Lisp

Why does evaluating (list + 1 2) in Common Lisp (CCL REPL) returns ('(+ 1 2) 1 2)? More: OK, I see that + actually evaluates to the last REPL result, but I still have a question: Is this a standard CL REPL thing, to have + equal to the last result,…
NeuronQ
  • 7,527
  • 9
  • 42
  • 60
5
votes
3 answers

Higher Order Function Syntax in Common Lisp

I'm teaching myself Common Lisp using Norvig's Paradigms of AI Programming and came across something I didn't understand and he didn't explain. (defun mappend (fn the-list) (apply #'append (mapcar fn the-list))) What is the difference between…
vrume21
  • 561
  • 5
  • 15
5
votes
12 answers

asm / C / Python / Perl / Lisp / Scheme Programmer looking for something new to learn

I need to have an at-home project now that I'm working on Python/Django at work. I'd like to learn something new, so I was thinking of checking out Java. What's the most well respected web framework for deploying Java web apps? The only reason I'm…
callen
  • 11
  • 7
5
votes
7 answers

LISP: How can I test if two lists have the same elements?

I want to write a function that takes as parameters two lists and checks if every element in the first one is included in the second ( the order of the elements doesn't matter). The function will also be checking if the two list have the same length…
seby598
  • 141
  • 4
  • 11
5
votes
3 answers

Scheme: Cond "not equal"

I'd like to do this in scheme: if ((car l) != (car (cdr (order l))) do something in particular I wrote this: ((eq? (car l) (car (cdr (order l))) ) (cons (count (car (order l)) (order l)) (count_inorder_occurrences (cdr (order l))))) but…
Frank
  • 2,083
  • 8
  • 34
  • 52
5
votes
2 answers

clojure - resolve a symbol inside let

How do I write a function to resolve a symbol in a lexical environment? (let [foo some-var] (let [sym 'foo] (resolve-sym sym))) I want to get the var that 'foo is bound to.
navgeet
  • 987
  • 1
  • 10
  • 23