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

Boolean functors in lisp

I find myself in a situation when I need to combine several predicate into one. Is there a standard way of doing this, something similar to compliment? Suppose there are several simple predicates (e.g. is-fruit-p, is-red-p, grows-on-trees-p etc.)…
zzandy
  • 2,263
  • 1
  • 23
  • 43
5
votes
1 answer

Define my own read macro

There are some read macros in Common Lisp such as ' #' #P, but how can I write a read macro? Like this: #T"hello world" ====================> (gettext "hello world")
Mike Manilone
  • 582
  • 4
  • 17
5
votes
2 answers

How can I send a file in a POST request?

I'm building a clojure API to my website that is basically a wrapper around the original web API. One of the features that I'm not being able to implement is file sending via POST requests, basically what I would do in shell with curl -F foo=bar…
konr
  • 1,173
  • 12
  • 26
5
votes
5 answers

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…
Shamster
  • 2,092
  • 5
  • 24
  • 27
5
votes
2 answers

How do I calculate non-natural logarithms in Racket?

I am aware of racket's log function, which computers the natural logarithm of a number. I am trying to find the logarithms of numbers raised to arbitrary bases. In other words, instead of this: > (log 9) 2.1972245773362196 I would like to do…
Alex V
  • 3,416
  • 2
  • 33
  • 52
5
votes
2 answers

Apply font lock to quoted symbols in elisp

In Emacs I would like quoted symbols in emacs lisp such as: 'blah and display them in a different color. How can I use font-lock mode to do this?
Zameer Manji
  • 3,017
  • 5
  • 31
  • 42
5
votes
1 answer

major-mode hook configuration affects other buffers

Let me start by saying I'm very new to emacs. I'm attempting to create customizations for major-modes. While my settings are functioning correctly, I'm observing that when I open a new buffer, that buffers major-mode customization is being applied…
5
votes
1 answer

Visualize s-expressions in real-time

I want to write Lisp/Scheme/Clojure code like this (map inc (range 0 5)) And have it visualized somewhat like this map -- inc \\ range -- 0 \ -- 5 I want to see the tree change in real-time as I manipulate my…
MRocklin
  • 55,641
  • 23
  • 163
  • 235
5
votes
3 answers

How do I send an attachment with an email in Racket?

I looked at the net/smtp module which provides several functions for sending emails. However, it does not say anything about including attachments. I also used the search feature on the Racket documentation website to look for the word "attach" and…
Alex V
  • 3,416
  • 2
  • 33
  • 52
5
votes
1 answer

Body of defmacro not being executed

I've noticed a trend in my code of repeating the same (with-current-buffer .... over and over again so I decided to define a macro based off that macro definition of with-current-buffer - this is what I have so far: (defmacro…
Dan LaManna
  • 3,431
  • 4
  • 23
  • 35
5
votes
1 answer

fixed point combinator in lisp

;; compute the max of a list of integers (define Y (lambda (w) ((lambda (f) (f f)) (lambda (f) (w (lambda (x) ((f f) x))))))) ((Y (lambda (max) (lambda (l) (cond ((null? l) -1) ((> (car…
alinsoar
  • 15,386
  • 4
  • 57
  • 74
5
votes
4 answers

Racket: Identifying tail recursion?

I wrote two different functions in racket to determine whether a list of numbers is ascending: (define (ascending list) (if (<= (length list) 1) #t (and (< (car list) (car (cdr list))) (ascending (cdr list))))) (define (ascending-tail…
L.Neil
  • 53
  • 1
  • 3
5
votes
5 answers

How might I format an alist in common lisp?

I'm beginning to write me some Common Lisp and am just getting the hang of consing things together and formatting them. Let's suppose I have an alist, like this: (defvar *map* '((0 . "zero") (1 . "one") (2 . "two"))) How do I format it like…
Michael
  • 794
  • 5
  • 15
5
votes
2 answers

CLOS: How to make a slot have an enforced type of vector of symbols?

I'm trying to create a class that can store a vector of symbols in a slot in SBCL. I cannot figure out how to set it up. My best guess thus far has been (defclass Individual () ((discrete-decisions :type (vector symbol)))) This returns the…
sadakatsu
  • 1,255
  • 18
  • 36
5
votes
2 answers

Rewrite this script by designing an interpreter in racket

The original script is like this: #lang racket (for ([i (in-range 3)]) (for ([j (in-range 9)]) (display "X")) (display "\n")) (for ([i (in-range 6)]) (for ([j (in-range 3)]) (display " ")) (for ([j (in-range 3)]) (display…
Hanfei Sun
  • 45,281
  • 39
  • 129
  • 237