lisp

Interact with a locally long-running Common Lisp image, possibly daemonized, from the command line

☆樱花仙子☆ 提交于 2019-12-09 10:13:51
问题 How could one interact with a locally long-running Common Lisp image, possibly daemonized, from the command line? I know it is possible to run a Common Lisp function from a Terminal command prompt, I am also aware of this. I would need to do a similar thing, but with a local, already long-running Common Lisp image, being able to poll available functions from the CLI or shell scripts. Is there a way to do that from a CLI, for example calling a function from a bash script, and receiving back

common lisp: how can a macro define other methods/macros with programmatically generated names?

情到浓时终转凉″ 提交于 2019-12-09 09:12:32
问题 I realized that a certain section of my code consists of groups of methods that look similar (like I have multiple trios: a helper function that gets called by two other functions meant for the programmer). I'm trying to write a macro that will define these three functions for me so that all I need to do is call the macro. But my attempt results in defuns and function calls that have quoted strings instead of the generated names as new symbols. What am I doing wrong? Example (incorrect code)

Why use #' with lambda?

前提是你 提交于 2019-12-09 09:05:02
问题 Why should I use #' together with lambda? It is usually written that way, so I guess it is good form. But these lines seem equal to me: > (mapcar #'(lambda (x) (+ x 1)) '(1 2 3)) (2 3 4) > (mapcar (lambda (x) (+ x 1)) '(1 2 3)) (2 3 4) Anyone care to enlighten a beginner about the difference? 回答1: #' is shorthand for function , which returns a pointer to a function (instead of applying it). lambda returns a function, and it's usual to want a pointer to that function. Since this is so common,

What is the best SQL library for use in Common Lisp? [closed]

风流意气都作罢 提交于 2019-12-09 08:44:21
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Ideally something that will work with Oracle, MS SQL Server, MySQL and Posgress. 回答1: if you mean common lisp by lisp, then there's cl-rdbms . it is heavily tested on postgres (uses postmodern as the backend lib), it has a toy sqlite backend and it also has an OCI based oracle backend. it supports abstracting

How to delete variable/forms in Lisp?

被刻印的时光 ゝ 提交于 2019-12-09 08:43:59
问题 In Python we have the del statement for deleting variables. E.g: a = 1 del a What the equivalent of this in Lisp? (setq foo 1) ;; (del foo) ? 回答1: In Common Lisp. For symbols as variables: CL-USER 7 > (setf foo 42) 42 CL-USER 8 > foo 42 CL-USER 9 > (makunbound 'foo) FOO CL-USER 10 > foo Error: The variable FOO is unbound. See: MAKUNBOUND (defined) SLOT-MAKUNBOUND (defined) FMAKUNBOUND (defined) 回答2: Python names reside in namespaces, del removes a name from a namespace. Common Lisp has a

LISP local/global variable assignment

隐身守侯 提交于 2019-12-09 05:56:34
问题 If we define a function something like (defun foo(x) (setf x somevalue)) Is x defined as a local variable or global? using setf/q is setting the value to be global. if it is global can anyone tell me how to define a local variable in lisp other than let ? Thanks! Consider the following example (let ((x 0)) (defun foo (y) (when (equal x 0) (setq x y)) (when (< x y) (setq x y)) x)) when I am giving some input to foo like (foo 2) , it is returning 2 and if we execute the function again with (foo

Is there an equivalent to Lisp's “runtime” primitive in Scheme?

大憨熊 提交于 2019-12-09 05:04:30
问题 According to SICP section 1.2.6, exercise 1.22: Most Lisp implementations include a primitive called runtime that returns an integer that specifies the amount of time the system has been running (measured, for example, in microseconds). I'm using DrScheme, where runtime doesn't seem to be available, so I'm looking for a good substitute. I found in the PLT-Scheme Reference that there is a current-milliseconds primitive. Does anyone know if there's a timer in Scheme with better resolution? 回答1:

Modify a parameter of a function

北慕城南 提交于 2019-12-09 03:39:04
问题 (setf list (loop for i from 1 to 12 collect i)) (defun removef (item seq) (setf seq (remove item seq))) CL-USER> (removef 2 list) (1 3 4 5 6 7 8 9 10 11 12) CL-USER> (removef 3 list) (1 2 4 5 6 7 8 9 10 11 12) Why doesn't removef really modify the variable? 回答1: In Common Lisp, parameters are passed "by identity" (this term goes back to D. Rettig, one of the developers of the Allegro Common Lisp implementation). Think of pointers (to heap objects) being passed by values, which is true for

In LISP how to inspect free variables in a closure?

这一生的挚爱 提交于 2019-12-08 21:24:18
问题 In lisp I can bind free variables bound in a closure like this... (let ((x 1) (y 2) (z 3)) (defun free-variables () (+ x y z))) (free-variables) results in ... 6 What I want to know is if it is possible to inspect bound closure variables dynamically? E.g. (inspect-closure free-variables) resulting in something like... ((x 1) (y 2) (z 3)) Thanks SO 回答1: Common Lisp Access to the closure's internal variables is only possible from functions in the same scope (See Jeff's answer). Even those can't

Anyone using Lisp for a MySQL-backended web app?

只谈情不闲聊 提交于 2019-12-08 21:22:07
问题 I keep hearing that Lisp is a really productive language, and I'm enjoying SICP. Still, I'm missing something useful that would let me replace PHP for server-side database interaction in web applications. Is there something like PHP's PDO library for Lisp or Arc or Scheme or one of the dialects? 回答1: newLisp has support for mysql5 and if you look at the mysql5 function calls, you'll see that it's close to PDO. 回答2: Since nobody has mentioned it, you can try Postmodern, which is an interface