7,048 questions
-1
votes
0
answers
34
views
Euler problem 1 Common Lisp recursive solution not working [closed]
I just started playing around with Common Lisp and tried the first euler problem which states to sum all the divisors of 3 OR 5 under some given parameter x. I would like to use a recursive solution ...
Advice
1
vote
16
replies
191
views
In Common Lisp, replacing "get-setf-method" with "get-setf-expansion" is not always working
The sortf function from Chapter 12 of the book "On Lisp" originally used get-setf-method, which is currently unavailable in a recent SBCL by default.
Therefore, get-setf-expansion was used ...
0
votes
1
answer
56
views
How does Lisp’s macro system differ from regular functions, and when should I use macros instead? [duplicate]
I’ve been reading about Lisp programming languages and trying to understand the core difference between macros and regular functions. From what I gather, Lisp’s macro system allows developers to ...
0
votes
1
answer
57
views
How to include a file with shadow-cljs/inline, but preprocess it first?
Shadow-cljs has a resource loader that can include literal files into the Clojurescript code
(ns app.my
(:require
[shadow.resource :as rc]))
(rc/inline "file.txt")
I need a macro that ...
-1
votes
1
answer
101
views
I can't see why Steel-Bank Common Lisp thinks a string is a function in my code [closed]
I am using a Windows 11 computer, running Steel Bank Common Lisp (version 2.0.0) in PowerShell by inputting functions directly into the SBCL.exe REPL to see if they work. In the process, I have hit ...
1
vote
1
answer
88
views
LISP macro indentation for sub-expressions?
I'm using Emacs, and I have a macro that's like a switch for regexes, and runs an expression with variables bound to match results.
The indentation isn't what I'd like but I can't find if there's a ...
3
votes
2
answers
70
views
Lisp: Iterating over slots with a macro
With this:
(defclass test-class ()
((data :initarg :data)
(other :initarg :other)))
(defmethod test ((tc test-class) &key)
(macrolet ((print-slot (slot)
`(with-slots (,slot) ...
1
vote
1
answer
127
views
How to create Clojure-style loop/recur macro using syntax-case in Guile Scheme?
I'm learning syntax-case macro system. This is what I have so far:
(define-syntax loop
(lambda (x)
(syntax-case x ()
[(_ (var val x ...) body)
(with-syntax ([recur (datum->syntax ...
1
vote
1
answer
64
views
How to use a function in setq with quote?
Suppose I'm setting a var like this:
(setq var '((:item1 "stringA") (:item2 "stringB")))
(this works)
Now I would like "stringA" be a conditional, like this:
(setq var '(...
-1
votes
2
answers
112
views
AutocadLisp - let variable argument definition mistaken as e function
I've never used LISP before and I'm using AI to try to create simple automations for autocad so I can speedup the proccess. Everything works fine to the point where I have a let expression which takes ...
0
votes
3
answers
91
views
Common Lisp: Why does using read-from-string create two REPL outputs?
I have been learning Common Lisp for a short while, using the SBCL 2.0.0 REPL on a Windows 10 machine. At one point in time I inputted the 2 following lines into a REPL:
(defvar var-string (print (* 5 ...
1
vote
1
answer
135
views
What is the difference between CLISP and SBCL in handling closures and lexical variables?
(Edit 2025-02-27: I should note that there isn’t a difference between how CLISP and SBCL handle this situation the way I initially thought there was; see the comments to this question, and the answer ...
0
votes
1
answer
200
views
AutoCAD LISP where I can select the Polyline which bounds the selected Text
I work with lots of rectangles(POLYLINE) with an ID name(TEXT) inside them.
I need to separate each Recatngles by Layer depending on their ID name.
So to make things a bit easier, I want to be able to ...
0
votes
1
answer
56
views
Cons and dot product related?
Does a Lisp or Scheme cons bear any similarities or theoretical kinship to a dot product? In the Lisp family (cons 1 2) produces (1 . 2) which looks a lot like a dot product. Just coincidence?
7
votes
1
answer
408
views
Inconsistent results in SBCL
Consider the following Common Lisp code.
(print (let* ((x nil) (y x)) (setq x t) (and y x))) ; T
(print (let* ((x nil) (y x)) (setq x t) (and x y))) ; NIL
(print (let* ((x nil) (y t)) (setq y x) (...
1
vote
1
answer
132
views
Does recursive call have to be strictly the last call in a function for a function to be tail-recursive?
Inspired by a post on Reddit (someone wanted to count frequencies in commonlisp forum), I wanted to write a list-based one for the fun and practice, hash-based one is of course more efficient. I got ...
1
vote
1
answer
87
views
find-symbol requires explicit package name
Solving a challenge in www.codewars.com.
It uses sbcl and rove for testing the answers.
I want to translate a string to a symbol. Codewars requires code inside a package to see it. This is a sample
(...
2
votes
1
answer
96
views
Adding items to a list with if condition in Common Lisp
I'm new on lisp and I'm trying to solve some basic exercises. I'm trying to make a list of elements in an input list that are out of max and min limits. I've been trying to do this by creating two ...
0
votes
0
answers
72
views
What is wrong with this macro expansion?
I am trying to use Dog Hoyte's Let over Lambda, Chapter 3, named let with some touch from EmacsLisp (named-let from subr-x.el).
Neither his original, nor mine slightly modified version macroexpand in ...
3
votes
2
answers
99
views
Is there a standard/portable way to query if a symbol stands for a symbol macro?
As the title says, how do I (programmatically) check in a portable way (if possible) if a symbol stands for a symbol-macro?
CL-USER> (define-symbol-macro some-macro some)
SOME-MACRO
CL-USER> (...
4
votes
2
answers
116
views
What should be the domain of a 'minimum' function in functional programming?
So I'm studying systems engineering and we're currently going over different programming paradigms.
We started playing with functional programming last class and we were asked to code a recursive '...
0
votes
0
answers
122
views
How do I help SBCL find libcrypto (and some other libraries)?
I have just upgraded to SBCL 1.4.3, and I'm having trouble loading foreign libraries while loading my package with Quicklisp. Everything worked before the upgrade.
I get this error:
(CFFI::FL-ERROR &...
0
votes
1
answer
130
views
Can you auto-continue on continuable error with clisp (or sbcl)?
This seems like an obvious question but my Googling suggests the answer is no, which I find hard to believe. I'm just starting out using examples from textbooks, and get the following. I have to type &...
2
votes
1
answer
66
views
Unbound Variable in Lisp Macro using loop-for-collect
I am a beginner lisp programmer, and I'm following the Practical Common Lisp book, specifically chapter 9.
After finishing the chapter, I've tried to expand the unit-testing environment. Specifically, ...
0
votes
2
answers
104
views
make-pathname and pathname-directory - drive information loss in windows
I have a question, whether this is intended by the language or whether this is kind of an unexpected/unwanted behavior/ BUG in Common Lisp.
However, I observed it in both: CLISP and SBCL:
I thought,
(...