(Trival and beginner Question) Tutorial (setf (select x 4) 11) not working

11 views
Skip to first unread message

KWC Coin

unread,
Mar 27, 2022, 9:38:32 AM3/27/22
to Common Lisp Statistics
Spending 1 whole hour on one minor issue with the tutorial and gave up on that part.

(def x (list 3 7 5 9 12 3 14 2)) ; same as (defparameter x (list 3 7 5 9 12 3 14 2)) I assume

(select x 1)                                 ; do return 7

(setf (select x 1) 11) ; Got error as below:

```
LS-USER> (setf (select x 1) 11) 

There is no applicable method for the generic function

  #<STANDARD-GENERIC-FUNCTION (COMMON-LISP:SETF SELECT:SELECT) (2)>

when called with arguments

  (11 (3 7 5 9 12 3 14 2) 1).

   [Condition of type SB-PCL::NO-APPLICABLE-METHOD-ERROR]

; Evaluation aborted on NIL

LS-USER> ; Quit to level 1

LS-USER> ; Evaluation aborted on #<SB-PCL::NO-APPLICABLE-METHOD-ERROR {10046A6203}>

```

I tried not use my slimv and do it on command line but same error message

--- compare with

(def y #(3 7 5 9 12 3 14 2))

(setf (aref y 1) 11)

y ; #(3 11 5 9 12 3 14 2)

or

(setf (nth 2 x) 11)

---


Both work.  Very rusty my lisp.  Familar more with aref in vector or car/nth in lisp for one element etc.  Select for a range or here one element I am not sure.  Somehow it cannot update in place.

As Bruce Lee would say, walk on

Steve Nunez

unread,
Mar 27, 2022, 8:48:14 PM3/27/22
to lisp...@googlegroups.com

Select returns a vector, array or data-frame. It is not a setf-able place. See generalized variables and setf. This is a not-uncommon Lisp error when beginning.

 

One thing to keep in mind is that Lisp-Stat is not the same as XLISP-Stat. You won’t be able to work through that book using Lisp-Stat. Common Lisp and XLisp differ. The best tutorials are on the website https://lisp-stat.dev/. If you encounter any problems working through those tutorials, we’d like to hear about them because they all work (we think). You could work possibly work through the XLISP-Stat book using the XLS-Compat system; no one has done that though.

 

In 2022, I think your best option is to learn Common Lisp. It’s close enough to XLISP that much will be familiar, and there are many tutorials and learn resources available.  For example see:

 

 

 

 

--
You received this message because you are subscribed to the Google Groups "Common Lisp Statistics" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lisp-stat+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lisp-stat/c8888e17-def4-4522-9725-780cfc0b7033n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages