7,048 questions
-1
votes
0
answers
63
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 ...
2
votes
0
answers
44
views
issues with set-car! when implementing SICP evaluator in Racket
I am implementing circular evaluator in Chapter 4 SICP with racket, it seems that the code running fine only it cannot add new frames to the environment due to set-car! issue.
I tried the followings:
...
Advice
1
vote
16
replies
197
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 ...
1
vote
1
answer
74
views
OpenBLAS gemm 2x slower in Lisp CFFI compared to direct C calls with same BLAS library
I'm experiencing a significant performance difference where OpenBLAS matrix multiplication runs 2x slower when called through Lisp CFFI compared to direct C calls, despite using the exact same ...
0
votes
1
answer
57
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
2
answers
56
views
Can I conditionally select a special-form at the beginning of an expression?
If I want to make a special-form conditional (making its value depend on a condition) in an expression like (FUNC ARGS) by making FUNC a conditional expression (if).
I ended up trying with something ...
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 ...
2
votes
1
answer
170
views
How do I measure performance of Lisp code?
I'm trying to discern how much performance gains I would achieve by converting Lisp (SBCL) code to assembly language. The time function on SBCL keeps giving counterintuitive results even for trivial ...
-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
3
answers
135
views
Scheme evaluation of list
I wrote a simple intersection function on two lists:
(define (intersection l1 l2)
(if (null? l1) '()
(if (member (car l1) l2)
(cons (car l1) (intersection (cdr l1) l2))
(...
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 ...
2
votes
1
answer
74
views
Let-binding *read-default-float-format* not having effect in another thread?
I don't know if I am clear in the title, but here me out. I have a package in which I bind *read-default-float-format* to 'double-float.
So far so good. When I load the library into fresh SBCL process ...
3
votes
2
answers
73
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
2
answers
126
views
In Common Lisp, what is the correct way to define a type or nil in a class slot?
I have a class, in which I want some slots to be nil when object is created, but they should be only setable with objects of some certain type. Something like:
(defclass Something ()
((foo :initarg :...
1
vote
1
answer
128
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 ...
0
votes
1
answer
67
views
ASDF "compile-bundle-op" seems to skip "package-inferred-system" projects?
I noticed that both compile-bundle-op and monolithic-compile-bundle-op work as expected on traditional projects. That is, generating the FASL files:
# compile-bundle-op FASL
<asdf-fasl-project-...
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
vote
1
answer
105
views
Common Lisp: Why does `WITH-SLOTS` allow shorthand names, but `WITH-ACCESSORS` doesn't?
I've noticed an interesting difference between WITH-SLOTS and WITH-ACCESSORS in Common Lisp:
WITH-SLOTS allows a shorthand syntax:
(with-slots (slot1 (var-name slot2)) instance
...)
But WITH-...
-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 ...
2
votes
2
answers
113
views
How do I correctly capitalize words that contain non-alphanumeric characters in Common Lisp?
Thanks in advance for the help!
Here's the situation:
I want to capitalize the first word in a sentence. I have the individual words in a sentence, stored as strings. In the case of the first word, I ...
0
votes
3
answers
92
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
3
answers
85
views
AutoLISP -- Extracting a string from a List of Lists?
Working in AutoLISP. I am looking for a more elegant way to extract the second string in this list of lists...
(("FullName") ("Larry Paige"))
Currently using the following to ...
1
vote
1
answer
140
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
122
views
Stack Overflow with BFS LISP
I have created a search function following the BFS algorithm but found a problem, it works fine on other problem domains but on this problem domain I am only getting stack overflows.
This specific ...
0
votes
1
answer
213
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 ...
1
vote
1
answer
82
views
what is the proper way to evaluate Lisp/Scheme in emacs
I try this LISP snippet from the Structure and Interpretation book
(define (a-plus-abs-b a b)
((if (> b 0) + -) a b))
in emacs by C-x C-e, or by evaluating the whole buffer. either way
and get ...
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?
0
votes
1
answer
113
views
How is defconstants and symbol macros handled in Common Lisp in regard to space?
When interfacing with C libraries, in this case win32 in particular, there may be a large number of defined constants. In a C/C++ program these are just literal numbers when compiler sees them, the ...
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) (...
0
votes
0
answers
49
views
executing in slime lisp does not execute
This code works when launched like this: clisp test.lisp
;;contents of test.lisp file
(defun wtof (filename text)
"Append TEXT to the file specified by FILENAME."
(with-open-file (stream ...
1
vote
1
answer
133
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 ...
0
votes
0
answers
76
views
ACT-R Lisp dynamically create chunk
(defun creer-bagage (=poids =categorie)
(let* ((timestamp (get-universal-time))
(=id (format nil "~8d" (mod timestamp 100000000)))
(=dimensions
(case =...
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
(...
1
vote
3
answers
180
views
If - loop issues in Common Lisp
I'm having some troubles with Common Lisp. I want to do a code to find how many times the values of a list are over or under two limits. I want to do a sweep on a list and evaluate if the current ...
2
votes
1
answer
97
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 ...
2
votes
1
answer
76
views
How can I delete a "." from a list in Common Lisp?
I'm new on lisp and I'm finding a difficulty while working with "append". I have to reorder a list and put the first element of the input list as the last of the output list. I've trying ...
0
votes
0
answers
76
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 ...
0
votes
2
answers
135
views
What is the Lisp's symbol equivalent of JavaScript?
So in Lisp/Scheme, there are these 'symbols', which are basically, if I understand correctly, and correct me if I'm wrong, references to variables (not their values). I was wondering if there's a ...
3
votes
2
answers
101
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> (...
1
vote
2
answers
85
views
Why can we use first-class expression in place of first-class function?
This is from this CS 61A notes about SICP p80~82 about ucblogo (a dialect of Logo, which derived from Lisp):
Second, Logo has first-class expressions; you can run a list that you get as an argument.
...
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
1
answer
76
views
SQL Injection safety in mito/sxql
I started playing with some hobby webdev project in Common Lisp.
For DB access I'm planning on using mito and sxql. I'm trying to find out if I need to do any additional stuff to protect myself from ...
0
votes
0
answers
125
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 &...
2
votes
1
answer
200
views
How does recursive tail optimization work?
How does recursive tail call optimization work in regards to what is placed/removed from the call stack? Specifically for LISP like languages? Any insight at assembly level will be helpful.
I show ...
0
votes
1
answer
131
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 &...
4
votes
2
answers
114
views
Is TRUNCASE a symbol that ever existed in a Lisp implementation?
It appears that the Kate editor has a lot of xml files describing various languages, for highlighting purposes. For example, commonlisp.xml contains all 978 standard Common Lisp symbols. Other ...
2
votes
1
answer
77
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, ...
1
vote
2
answers
193
views
How do I ask a CommonLisp system to lookup symbols dynamically at runtime in compiled functions?
As a preamble, I am implementing two simple commands I can use via a little package in SBCL, which emulates Allegro repl. The package is sb-aclrepl, found in the contrib folder in SBCL sources. The ...
0
votes
2
answers
107
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,
(...
2
votes
3
answers
415
views
How to deploy a web application so that I can modify its code, while it is running?
Let's say there is a web application running on a VPS with Linux as a systemd service, or whatever is best for it. Is it possible to access the running Lisp image with a new REPL instance or somehow ...