lisp

How do I delete from a binary search tree in Lisp

南笙酒味 提交于 2020-01-15 18:32:28
问题 How can I delete a node from a BST? I need an algorithm to do that in Dr. Scheme. 回答1: You basically toss the BST you have now, and create a new one sans the element. You can do this by recursively descending the tree. If your item is less than the root datum, create a BST whose root and greater-than branch is copied from what you have now, but whose less-than branch is the result from a recursive call. It's very similar to how you add a node, but when you get to the one you were searching

Need advice on how to print a matrix in lisp

余生颓废 提交于 2020-01-15 10:45:33
问题 I have a matrix defined so if I do this (format t "~a" (get-real-2d 0 0)) it prints out the element in the first row first column and if I do this (format t "~a" (get-real-2d a 0 1)) it prints out the element in first row second column and if I do this (format t "~a" (get-real-2d a 1 0)) it prints out the element in second row first column. The matrix a looks like this a = ((0 1 2) (3 4 5) (6 7 8)) and I was hoping you can show me exactly how to write a dotimes loop or other loop that would

Statically-typed dialect of Lisp with type inference, for Windows?

北战南征 提交于 2020-01-14 09:53:26
问题 Is there any statically-typed dialect of Lisp that performs type inference and is compatible with Windows? I have found CMUCL but it doesn't seem to have a Windows-compatible version. 回答1: Have a look at SBCL which descends from CMUCL. It has good support for static typing through type declarations, performs plenty of type inference, and runs on Windows. It's very much dynamic by default, though. You might be interested in Typed Racket. 回答2: Stalin is a free Scheme implementation doing type

How can I have optional arguments AND keyword arguments to the same function?

浪子不回头ぞ 提交于 2020-01-14 09:10:56
问题 I am trying to write a Lisp function that can take optional and keyword arguments. The function begins (defun max-min (v &optional max min &keyword (start 0) (end nil)) When I try to call the function using the keyword arguments but not the optional ones, I get an error. What I'm trying to do is (max-min #(1 2 3 4) :start 1 :end 2) I'm getting the error Error: :START' is not of the expected type REAL' I assume that this is because it is trying to bind :start to max . How can I get this to

hunchentoot fatal error encountered in SBCL SIGABRT received

丶灬走出姿态 提交于 2020-01-14 04:19:25
问题 while installing hunchentoot (and subsequently loading it), I have the error: * (ql:quickload :hunchentoot) To load "hunchentoot": Load 1 ASDF system: hunchentoot ; Loading "hunchentoot" ....fatal error encountered in SBCL pid 43052(tid 0xb57dc0): SIGABRT received. Welcome to LDB, a low-level debugger for the Lisp runtime environment. ldb> I have locally built SBCL, using ./make.sh --fancy flag to have threads on my macOS % sbcl --version SBCL 1.5.9 mac os: % uname -a Darwin <m/c name> 19.0.0

How to know whether a symbol represents function or macro?

血红的双手。 提交于 2020-01-14 02:28:10
问题 I'm writing a macro for function / macro composition (mixed combinations are possible). Inside of the macro I have to treat symbols which represent functions and those that name macros differently. It is because result function must work with any number of arguments (if 'lowest' function in composition can), and I cannot apply apply to macros. My question: how to determine what a given symbol represents: function or macro? 回答1: Macro: CL-USER 8 > (macro-function 'bar) NIL CL-USER 9 > (macro

Man or javadoc-style documentation for common lisp

牧云@^-^@ 提交于 2020-01-13 19:12:11
问题 Is there any kind of common lisp docs like javadoc, man or even intellisense-like popups? I've just started learning common lisp and do not have enough hand memory. I am using emacs and slime — it has tab completion, but it seem not very informative. Thanks! 回答1: Just in case this question was meant to ask where the reference is - there are several Hyperspecs available online. If you search Google for something like "hyperspec function-name" there's a good chance you will land on one of them.

(Random) in Common Lisp Not So Random?

谁说我不能喝 提交于 2020-01-13 07:49:08
问题 Okay, final question and I'll have finished my number guessing game in Common Lisp! :D Whenever the game starts (or a new game begins after the first game), the following function is called. ;;; Play the game (defun play () ;; If it's their first time playing this session, ;; make sure to greet the user. (unless (> *number-of-guesses* 0) (welcome-user)) ;; Reset their remaining guesses (setq *number-of-guesses* 0) ;; Set the target value (setq *target* ;; Random can return float values, ;; so

What are the good “rich” IDEs for Lisp? [closed]

烈酒焚心 提交于 2020-01-12 04:36:08
问题 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 6 years ago . What are the good "rich" IDEs for Lisp? To clarify by "rich" I mean it should have a good look-up reference, auto complete, auto

How to use packages installed by quicklisp?

邮差的信 提交于 2020-01-12 03:20:31
问题 I've installed the CL-PNG package using quicklisp. (ql:quicklisp 'png) Now I want to define my own package which depends on the CL-PNG package. Like so: (defpackage :FOO (:use :CL :PNG) (:export :BAR)) When compiling it I get this error: The name "PNG" does not designate any package. [Condition of type SB-KERNEL:SIMPLE-PACKAGE-ERROR] It seems that I have to call (require :PNG) on the REPL before compiling my package. What do I have to do to make the CL-PNG package available for the compiler