lisp

How to process input and output streams in Steel Bank Common Lisp?

I'm trying to figure out how to use the output stream of one program I start with RUN-PROGRAM so it can be used as the input of another program started with RUN-PROGRAM (i.e., the moral and perhaps literal equivalent of piping). I've tried using a number of combinations of the :INPUT, :OUTPUT and :WAIT keyword arguments, but nothing I've...

The subsets-sum problem and the solvability of NP-complete problems

I was reading about the subset-sums problem when I came up with what appears to be a general-purpose algorithm for solving it: (defun subset-contains-sum (set sum) (let ((subsets) (new-subset) (new-sum)) (dolist (element set) (dolist (subset-sum subsets) (setf new-subset (cons element (car subset-...

LISP community and web frameworks

In the reddit interview with Peter Norvig, he says “For various reasons the set of web libraries and protocols were slower to develop in LISP than in other languages” and consequently lisp adoption among the web community went down, and people went after languages with richer library sets. Is there a reason for this sl...

List without nil in Lisp

Hi! Allknowing that in lisp list must contain nil, but expression like (print (cons 1 (cons 3 2))) dont throw any errors and prints (1 3 . 2) Is it correct? I use GNU Clisp. Help me please ...

Inheritance classes in Scheme

Now I research OOP-part of Scheme. I can define class in Scheme like this: (define (create-queue) (let ((mpty #t) (the-list '())) (define (enque value) (set! the-list (append the-list (list value))) (set! mpty #f) the-list) (define (deque) (set! the-list (cdr the-list)) (if (= (length t...

List of evented / asynchronous languages

I'm working on a system than has to be pretty scalable from the beginning. I've started looking at / playing around with asynchronous/evented approaches to writing serverside code. I've played around with both ruby's EventMachine and node.js. EventMachine is cool, but doesn't have asynchronous file I/O, which I need. The interface is ki...

Best practices in building and deploying Clojure applications: good tutorials?

I am new to Clojure, and am beginning to experiment with building an application. So far, everything I've seen about tutorials on compiling Clojure programs involves interactivity. For example, "load up the REPL and type (load-file "this-or-that") to run. This is fine, but it's not enough. I am so used to the edit-compile-run idiom...

Traversing Scheme function as a list

Isn't it possible to treat functions in Scheme as any other list? Basically, what I want do to is something like this: (define (foo) "hello") (cdr foo) ; or similar, should return the list ((foo) "hello") I've found a similar discussion about this, and I feel a bit disappointed if this is not possible with Scheme. If so, why is th...

What are circular lists good for (in Lisp or Scheme)?

I note that Scheme and Lisp (I guess) support circular lists, and I have used circular lists in C/C++ to 'simplify' the insertion and deletion of elements, but what are they good for? Scheme ensures that they can be built and processed, but for what? Is there a 'killer' data structure that needs to be circular or tail-circular? ...

Cocoa equivalent of the Carbon method getPtrSize

I need to translate the a carbon method into cocoa into and I am having trouble finding any documentation about what the carbon method getPtrSize really does. From the code I am translating it seems that it returns the byte representation of an image but that doesn't really match up with the name. Could someone give me a good explanati...

Lisp Style question label local functions or not?

I was wondering if there is a standard practice regarding the use of labels in Lisp. I've been messing around with a Lisp implementation of the algorithm described in the first answer here http://stackoverflow.com/questions/352203/generating-permutations-lazily My current version uses labels to break out portions of functionality. (de...

Getting reference to the JavaScript Function object behind an operator

Here is a lisp procedure that simply adds 'a' to the absolute value of 'b': (define (a-plus-abs-b a b) ((if (> b 0) + -) a b)) I think this is beautiful, and I am trying to find the best way of writing this in JavaScript. But my JavaScript code is not beautiful: var plus = function(a,b) { return a + b; }; var minus = function(...

Printing Colored Characters in Lisp / Emacs

I'm writing a simple connect-4 program in Lisp and ideally each player (red, black) would have their own color when the game state is displayed. Does anyone know how to print colored ASCII characters? How is this done in general? I'm using emacs 23, so the solution might be specific to emacs itself. Anyways, I've checked the hyperspec t...

Which programming language presents a program as a tree?

I heard that a program can be presented as a tree. I also heard that there is a programming language whose syntax make this idea very clear. I mean that programs written in this language can be easily represented as a tree. Does anybody know what is the name of this language? ...

UVa #112 Tree Summing

I'm working on UVa #112 Tree Summing. I have what I think should be a working solution but it is not accepted by the online judge due to a basic misunderstanding of the problem on my part. Consider the following inputs: -1 (-1()()) 77 (77(1()())()) or diagrammatically, the trees look like: -1 77 / \ / \ (...

Problems with ltk (common lisp)

I installed ltk to Steel Bank Common Lisp with asdf-install, but I can't even start using it V_V. The code below is the simplest example in the documentation, and is copied almost verbatim. (asdf:operate 'asdf:load-op :ltk) (defun hello-1() (with-ltk () (let ((b (make-instance 'button :master nil ...

Vector addition of lists

If I had a N lists each of length M, how could I write a nice clean function to return a single list of length M, where each element is the sum of the corresponding elements in the N lists? (starting to learn lisp - go easy!) ...

nohup SBCL ubuntu couldn't read from standard input

On Ubuntu I compiled sbcl 1.0.35 with threading. I can happily use sbcl from the command line and my hunchentoot website works with threading but when I logout it's gone. When I attempt to nohup sbcl nohup ./src/runtime/sbcl --core output/sbcl.core I get (SB-IMPL::SIMPLE-STREAM-PERROR "couldn't read from ~S" # 9) I've attempted va...

Newbie: Keybindings error in Elisp

Hi, I am trying to make a simple keybinding to the "na" function. When I execute (na) it inserts "å" in the current buffer, which it is supposed to, but the when I try the keybinding as described in the first line I get the error: "Wrong argument: commandp, na". I am not sure if it matters, but I have also put the (local-set-key) comman...

How to write a LISP interpreter for actionscript 3?

I know there is one, but it's not easy to implement the way I want. I would like to know the steps to interpret the lisp language and what functions are essential to be implemented. ...