clisp

Clisp “Program stack overflow. RESET” on a (cadr). How? [duplicate]

喜欢而已 提交于 2019-12-12 01:47:47
问题 This question already has an answer here : Unusual stack overflow when inserting nodes in binary tree (1 answer) Closed 2 years ago . I'm (still) porting code from Franz Lisp to Common LISP. Now I seem to have pushed the interpreter into a strange corner where it blows up. [11]> (setq fff (cadr contextstack)) *** - Program stack overflow. RESET Now how can that cause a stack overflow? Where's the recursion? I can take the length OK: [12]> (length contextstack) 79 describe works. This is just

CLISP Terminal error: Invalid byte sequence

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 07:01:38
问题 i have a problem while loading my source file inside terminal using clisp. if i execute the following command to load the file: (load #p "filename.lisp") it gives me the following error: SYSTEM::LINE-COMMENT-READER: Invalid byte sequence #xE0 #xA0 #x20 in CHARSET:UTF-8 conversion can someone please tell me what i need to do in order to load the file? thank you. 回答1: Your file is encoded with ISO-8859-1: $ file filename.lisp filename.lisp: ISO-8859 text, with no line terminators Based on CLISP

Listing directories in CLISP

馋奶兔 提交于 2019-12-11 05:08:02
问题 I've been trying to see get a list of all files within a directory in CLISP, but I've only been able to get all non-directory files within a directory. I'm currently trying this in Windows 7 with cygwin, so that may influence my results. I'm pretty new to CLISP (and LISP over all), and what I'm currently trying to do is as follows: (directory (make-pathname :directory '(:absolute "cygdrive" "c" "Download") :name :wild)) This successfully returns all non-directory files within "C:\Download.

Giving a symbol a negative value in lisp

为君一笑 提交于 2019-12-11 03:43:09
问题 I'm very new to lisp and I am working on basic syntax. I am trying to convert: r1 = (-b + sqrt(b^2 - 4*a*c))/(2*a) into a lisp format. The only problem I think I am having is that I cannot get lisp to recognize -b as the negative value of my symbol b. This is what I have so far from the lisp prompt: [17]> (setq a 1L0) 1.0L0 [18]> (setq b -1L0) -1.0L0 [19]> (setq c -1L0) -1.0L0 [20]> (setq r1 (+ (/ (sqrt (- (power b 2) (* (* 4 a) c))) (* 2 a)) -b)) *** - EVAL: variable -B has no value The

LISP - How to get the average length for nested lists?

白昼怎懂夜的黑 提交于 2019-12-11 03:29:32
问题 I have a problem. I need to get average length from this list: (1 (2 3 4) 5 (6 7) 8 (9)) . It should be 2. And I have no idea where to start... I tried to get (1 2 3 4 5 6 7 8 9) from (1 (2 3 4) 5 (6 7) 8 (9)) but I failed, because (reduce #'append list-name) isn't working. I have idea how to calculate this but I need to get all lists inside (1 (2 3 4) 5 (6 7) 8 (9)) like this: list1 = (1 5 8) list2 = (2 3 4) list3 = (6 7) list4 = (9) But I don't know how. Can u give me some help? 回答1: (defun

CLISP - Reversing a simple list

孤街浪徒 提交于 2019-12-10 23:49:28
问题 I have to reverse the elements of a simple (single-dimension) list. I know there's a built-in reverse function but I can't use it for this. Here's my attempt: (defun LISTREVERSE (LISTR) (cond ((< (length LISTR) 2) LISTR) ; listr is 1 atom or smaller (t (cons (LISTREVERSE (cdr LISTR)) (car LISTR))) ; move first to the end ) ) Output pretty close, but is wrong. [88]> (LISTREVERSE '(0 1 2 3)) ((((3) . 2) . 1) . 0) So I tried to use append instead of cons : (t (append (LISTREVERSE (cdr LISTR))

LISP or Haskell [closed]

烈酒焚心 提交于 2019-12-10 16:01:52
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . LISP or Haskell, I need to learn functional programming, but I heard that lisp is very old, any advice between those two languages ?

In LISP is it possible to access a function's form?

℡╲_俬逩灬. 提交于 2019-12-10 13:57:03
问题 Suppose I define a function globally: (defun x (y) (1+ y)) ;; Edit: my first example was too complicated Is it possible to "coerce" the function x into a list like: (x (y) (1+ y)) Thanks in advance! PS - @Danlei's example works in Clozure CL with a special flag, however does anyone know how to get FUNCTION-LAMBDA-EXPRESSION to work in SBCL? 回答1: You could try FUNCTION-LAMBDA-EXPRESSION: (function-lambda-expression #'foo) But it's not guaranteed to work ("… implementations are free to return `

Does a setfable nthcdr implementation exist?

谁说我不能喝 提交于 2019-12-10 03:38:49
问题 I am using clisp and I wonder if there is any library with a setfable version of nthcdr that I can use. 回答1: You can hack around it with: (let ((lst (list 1 2 3 4)) (n 2)) (setf (cdr (nthcdr (1- n) lst)) '(5 6 7)) l) > (1 2 5 6 7) Or define your own setf for it: ;; !!warning!! only an example, lots of nasty edge cases (defsetf nthcdr (n lst) (new-val) `(setf (cdr (nthcdr (1- ,n) ,lst)) ,new-val)) I do not know why nthcdr does not have a setf defined. Even Alexandria seems to define setf for

Updating to ASDF 3.x in CLISP

限于喜欢 提交于 2019-12-07 10:16:58
问题 I am trying to update ASDF in CLISP 2.49 (on Mac OS Sierra) to version 3.x. I have now version 2.26 of ASDF. I have tried everything I found online: I downloaded the latest version of ASDF as indicated in https://common-lisp.net/project/asdf/ but then when I eval (require "asdf") , as indicated in the manual (https://common-lisp.net/project/asdf/asdf.html#Upgrading-ASDF) nothing happens, I still have version 2.26. The manual also tells to load the file asdf.lisp , but the file is missing from