sbcl

(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

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

Common LISP (SBCL): Returning values from within loops

只愿长相守 提交于 2020-01-05 05:24:17
问题 Preface: I'm currently taking a condensed course that is apparently taught in LISP and I've never worked with LISP in my life so I had to learn the language over a weekend. I apologize in advance for the abysmal code. I'm just familiar enough with LISP's syntax to get the code working and not much more. I'm currently working on a program that solves the map coloring problem. This code takes a sequence where the first element of each sub sequence is a state and the second element represents a

Questions about Execution Order

眉间皱痕 提交于 2020-01-04 13:38:38
问题 I'm trying to learn Common Lisp, and found something unexpected (to me) when trying something out in the repl. Based on order of execution in most programming languages, and the great first class function support I'd always heard about from lisp, I'd think the following should work: ((if t 'format) t "test") In Ruby I can do: if true Object.method(:puts) end.call("test") My thinking in how the above lisp code should work is that it should evaluate the inner lisp form, return format, then

Args for sb-ext:run-program

限于喜欢 提交于 2020-01-04 03:51:29
问题 Can someone tell me exactly what the args argument should look like for sb-ext:run-program? If I do this: (sb-ext:run-program "C:/Program Files/iTunes/iTunes.exe" "C:/lispbox-0.7/opus.mid") I get this error: debugger invoked on a TYPE-ERROR: The value "C:/lispbox-0.7/opus.mid" is not of type LIST. However, if I do this: (sb-ext:run-program "C:/Program Files/iTunes/iTunes.exe" (list "C:\lispbox-0.7\opus.mid")) iTunes opens, but the MIDI file doesn't play, even though this invocation from the

Args for sb-ext:run-program

廉价感情. 提交于 2020-01-04 03:51:17
问题 Can someone tell me exactly what the args argument should look like for sb-ext:run-program? If I do this: (sb-ext:run-program "C:/Program Files/iTunes/iTunes.exe" "C:/lispbox-0.7/opus.mid") I get this error: debugger invoked on a TYPE-ERROR: The value "C:/lispbox-0.7/opus.mid" is not of type LIST. However, if I do this: (sb-ext:run-program "C:/Program Files/iTunes/iTunes.exe" (list "C:\lispbox-0.7\opus.mid")) iTunes opens, but the MIDI file doesn't play, even though this invocation from the

exp in SBCL is wrong?

倖福魔咒の 提交于 2020-01-03 18:35:12
问题 CL-USER> (exp 1) 2.7182817 Why? It should be 2.7182818 (rounded from 2.7182818284590452353602874713526624977572470936999595749669...) SBCL 1.0.29.11.debian 回答1: It is a rounding error inherent in the IEEE single-float format. CL-USER> (exp 1.0d0) 2.718281828459045d0 回答2: Learn more about floating point arithmetic and its 'problems' in this classic paper (PDF): What Every Computer Scientist Should Know About Floating-Point Arithmetic 来源: https://stackoverflow.com/questions/4771346/exp-in-sbcl

Inferior Shell or UIOP: Interacting with background process

这一生的挚爱 提交于 2020-01-03 13:36:59
问题 So, I got past actually getting a program to run from SBCL Lisp using inferior-shell (presumably UIOP would be just fine). Anyway, now that I can do that, I still have no clue how to interact with the program if it is running in the background. All of this functionality like pipes and streams connected to the stdin and stdout of the running program are advertised, just not documented. It would seem like this is the most basic thing to do. Does anybody have an example of doing such a thing?

Running utf-8 encoded scripts with Steel Bank Common Lisp

别来无恙 提交于 2020-01-01 09:44:03
问题 I am trying to run a common lisp script from the command line, on Ubuntu 12.04, using SBCL 1.1.7. I start the script with $ sbcl --script <my-script.lisp> Since the script is UTF_8 encoded, I get some error messages: ; compiling (DEFUN PRINT-USAGE ...)unhandled SB-INT:STREAM-DECODING-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING {1002A39983}>: :ASCII stream decoding error on #<SB-SYS:FD-STREAM for "file ... .lisp" {10045745E3}>: the octet sequence #(194) cannot be decoded. I guess

How to use buildapp in combination with quicklisp

只愿长相守 提交于 2019-12-30 00:40:14
问题 I want to use buildapp to make the curl-lisp executable given as an example: buildapp --output lisp-curl --asdf-path ~/src/clbuild/systems/ \ --load-system drakma \ --eval '(defun main (args) (write-string (drakma:http-request (second args))))' \ --entry main This will most definitly not work, as I got no path "~/src/clbuild/systems/", as I use quicklisp my systems should be at "~/quicklisp/dists/quicklisp/software", but when I execute: buildapp --output lisp-curl \ --asdf-path ~/quicklisp