7,047 questions
1
vote
4
answers
139
views
Evaluation of expression in operator position of a list
I am trying to learn Lisp, but it seems like I can not quite get behind how the quotes and the evaluation works. Why does the following expression
((car '(car)) '(a b))
not evaluate to a in the REPL? ...
2
votes
0
answers
58
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
2
votes
16
replies
217
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
90
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
71
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
59
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
69
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
202
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
114
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
143
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
97
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
79
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
80
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
142
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
132
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 ...