sbcl

Running a Common Lisp function from a Terminal command prompt

百般思念 提交于 2019-12-28 05:52:12
问题 I'm having some difficulty finding an answer to this, so maybe it isn't possible. I'd like the flexibility of being able to load/compile a lisp file from a command line, i.e. not inside emacs, and then also run one of the lisp functions in that file also from the command line. This is no doubt implementation specific feature, so any pointers on an implementation that offers this (or perhaps it is fairly standard, I don't know). I'm using SBCL and like it, so it would be great if that could do

How to call native c function with windows HANDLE in common lisp / cffi

杀马特。学长 韩版系。学妹 提交于 2019-12-24 14:07:24
问题 native c header: typedef HANDLE HCAMERA; int Begin(HCAMERA* h); int End(HCAMERA h); HANDLE is defined: typedef void *HANDLE; native c source I want: HCAMERA h; int r = 0; r = Begin(&h); VERIFY(r); r = End(h); VERIFY(r); I tried following code in sbcl 1.3.1 but not working. (cffi:use-foreign-library "camera.dll") (cffi:defcfun "Begin" :int (handle :pointer)) (cffi:defcfun "End" :int (handle :pointer)) (defparameter *camera* (cffi:foreign-alloc :pointer)) ; alloc handle (cffi:with-foreign

duplicating and modifying the head of a list of list, in Lisp

风流意气都作罢 提交于 2019-12-24 01:43:48
问题 I'm learning Lisp. I wish to add a new list to a list of list, say ((1 1 1) (0 0 0)), where the new head of this list collection is computed based on the previous head. Here's what I tried, in the REPL environment in Slimv with sbcl: > (defvar *ll* (list (list 1 1 1) (list 0 0 0))) *LL* > *ll* ((1 1 1) (0 0 0)) > (push (car *ll*) *ll*) ((1 1 1) (1 1 1) (0 0 0)) > (setf (nth 2 (car *ll*)) 2) 2 > *ll* ((1 1 2) (1 1 2) (0 0 0)) As shown above, I only wanted to modify the last element of the

Can I use lambda with an on-the-fly lambda list (without macros)?

早过忘川 提交于 2019-12-24 01:16:20
问题 I'm trying to create a function to return functions, with arbitrary lambda lists, generated on the fly. I can do it with macros, but I'm trying to de-macro-ify what I've already got: (defmacro make-canned-format-macro (template field-names) `(function (lambda ,field-names (apply #'format `(nil ,,template ,,@field-names))))) I can use it as follows: * (make-canned-format-macro "~A-powered ~A" (fuel device)) #<FUNCTION (LAMBDA (FUEL DEVICE)) {10067D975B}> * (setf (fdefinition 'zoom-zoom) (make

Why does SBCL eval function lose the macrolet it's running in?

纵然是瞬间 提交于 2019-12-23 17:58:21
问题 (print x) prints exactly what I want to eval, but (eval x) fails, but if I run x it works! What am I missing? Please tell me why this doesn't work, or if I'm doing something stupid. I'm trying to print a table of dynamic size and setting lambda variables to eventually evaluate an expression for each cell in the table. BTW I figured out why eval fails. (eval x) is losing the macrolet, but WHY?! This works: (defvar varlist '(a b c d)) (defvar vvars '(c d)) (defvar hvars '(a b)) (macrolet (

Why would Common Lisp (SBCL) use so much memory for a simple program?

你离开我真会死。 提交于 2019-12-23 13:11:02
问题 since I'm a newbie to Common Lisp I tried to solve problems on SPOJ by using Common Lisp (SBCL). The first problem is a simple task of reading numbers until number 42 is found. Here's my solution: (defun study-num () (let ((num (parse-integer (read-line t)))) (when (not (= num 42)) (format t "~A~%" num) (study-num)))) (study-num) The solution is accepted. But when I looked into the details of the result I found it used 57M of MEM! It's bloody unreasonable but I can't figure out why. What can

CFFI Not Loading Dependent Libraries?

寵の児 提交于 2019-12-22 10:14:47
问题 I am trying to use the BLAS/LAPACK libraries from SBCL (specifically trying to get the LLA package running). I was having a lot of troubles getting the BLAS shared library to load; eventually I discovered that it wasn't able to load its dependent libraries. Eventually I was able to load BLAS by loaded all of its dependencies manually: (setq cffi::*foreign-library-directories* '("C:/cygwin64/bin/" "C:/cygwin64/lib/lapack/")) (CFFI:LOAD-FOREIGN-LIBRARY "CYGWIN1.DLL") (CFFI:LOAD-FOREIGN-LIBRARY

How can I view the definition of a function in lisp (sbcl)?

ε祈祈猫儿з 提交于 2019-12-22 08:48:20
问题 I use sbcl+emacs+slime . I writing a function in lisp, I use C-c C-c compile, but i've already deleted it. I can't find it. I want to know how I define it. I tried use function-lambda-expression , but I get this: (function-lambda-expression #'b) T B I hope someone can give me some help.Thanks very much in advance! Thanks Vsevolod. If function define in repl , i can use (descri #'function-name) get how i define the function, but if i through C-c C-c define it, i just get source file My attempt

SBCL initialization file

折月煮酒 提交于 2019-12-22 04:03:24
问题 I would like to know where I should save my .sbclrc file. I tried saving it in my .sbcl folder, but it doesn't seem to be working. I'm using Windows XP with Emacs version 23. I'm trying to set up asdf-install, that is why I'm mucking around with the initialization file. Thanks for your time. 回答1: What is the result of evaluating this in the repl: (SB-IMPL::USERINIT-PATHNAME) 来源: https://stackoverflow.com/questions/2245854/sbcl-initialization-file

Common Lisp: compilation vs evaluation

。_饼干妹妹 提交于 2019-12-21 17:26:36
问题 On Emacs + Slime with sbcl, once I define a function (or more) in a file I have two choices: Evaluation : e.g. with C-M-x eval-defun Compilation : e.g. with C-c M-k compile-file The second one produces a .fasl file, too. What are the differences between the two? What's going on under the hood when I compile a definition / a file? What are the Pros and Cons of each one? 回答1: First of all, there's a function eval [1], that allows to evaluate (i.e. execute) arbitrary CL form in the language