lisp

Unexpected output with cons()

I am from an imperative background but these days trying my hands on LISP (Common LISP) I read here about cons that (cons x L): Given a LISP object x and a list L, evaluating (cons x L) creates a list containing x followed by the elements in L. When I intentionally did not use a list as the second argument i.e when I used (co...

How many primitives does it take to build a LISP machine? Ten, seven or five?

On this site they say there are 10 LISP primitives. The primitives are: atom, quote, eq, car, cdr, cons, cond, lambda, label, apply. http://hyperpolyglot.wikidot.com/lisp#ten-primitives Stevey reckons there are seven (or five): Its part of the purity of the idea of LISP: you only need the seven (or is it five?) primitives to build ...

Applying the Y-Combinator to a recursive function with two arguments in Clojure?

Doing the Y-Combinator for a single argument function such as factorial or fibonacci in Clojure is well documented: http://rosettacode.org/wiki/Y_combinator#Clojure My question is - how do you do it for a two argument function such as this getter for example? (Assumption here is that I want to solve this problem recursively and this n...

What are the advantages of scheme macros?

Why would anyone prefer Scheme macros over Common Lisp macros (and I genuinely want to know too, I'm not trying to be a troll)? My experience as a Lisp newb is that Common Lisp style macros are much easier to learn than Scheme's macros. I have yet to see any advantages to Scheme's macros, but of course that doesn't mean they don't exis...

Why does format happen after read in this example from Paul Graham Book

Possible Duplicate: Lisp format and force-output I'm reading Paul Grahams book ANSI common lisp and on page 19 (haven't gotten far yet) there is an example that I tried in sbcl. (defun askem (string) (format t "~A" string) (read)) When I run it in REPL, I have to input something before the prompt is printed. If I save ...

What is it about a single namespace that leads to unhygienic macros? (in LISP)

Some claim that a single namespace in LISP leads to unhygienic macros. http://community.schemewiki.org/?hygiene-versus-gensym http://www.nhplace.com/kent/Papers/Technical-Issues.html What precisely is it about having single, dual or multiple namespaces that leads to macro hygiene? ...

What POOP frameworks exist for Lisp and Scheme.

What all nice POOP (Prototype-based Object-oriented Programming) Frameworks exists in Lisp and Scheme I know one * Sheeple But I did not find any other. ...

What is the correct term for the following functional programming pattern?

I've heard it referred to as a stream, as an infinite list, and sometimes even as a lazy sequence. What is the correct term for the following pattern? (Clojure code shown) (def first$ first) (defn second$ [str] (cond (empty? str) () true ((first (rest str))))) (defn stream-builder [next_ n] (cons n (cons (fn [] (stream-bu...

Lisp compiler design

I am looking for a compiler design book. I am learning it at college; but lectures were never meant for me. Moreover, at my college they don't do much practical and I believe even if I sincerely do the course about finite automata and compiler design, I will not know how to implement a compiler. So, I am looking for books about implement...

Swapping rows and columns in common lisp

I am trying to swap 'rows' and 'columns' in common lisp. Comments delineate my logic. (setq thingie '((1 2 3) (4 5 6) (7 8 9))) ;;test case (defun rotate (mat) (if (car mat) (let ((top (mapcar 'car mat)) ;;slice the first row off as a list (bottom (mapcar 'cdr mat))) ;;take the rest of the rows (cons top (ro...

emacs lisp listing files with glob expansion

Are there any library or function that performs a bash-like glob expansion for emacs lisp? For example: (directory-files-glob "~/Desktop/*") > ("/home/user/Desktop/file1" "/home/user/Desktop/file2") If there isn't such a function are there any hint/suggestion on how to implement it? EDIT: I've found in the docs also an useful funct...

Lisp style question: memoization (caution: contains the solution for project euler #14)

Hello, I am just trying to learn some Lisp, so I am going through project euler problems. I found problem no. 14 interesting (so if you are planning to solve this problems stop reading now, because I pasted my solution at the bottom). With my algorithm it was so slow, but after using memoization (I copied the function from Paul Graham's...

Difference between let* and set? in Common Lisp

I am working on a genetic programming hobby project. I have a function/macro setup that, when evaluated in a setq/setf form, will generate a list that will look something like this. (setq trees (make-trees 2)) ==> (+ x (abs x)) Then it will get bound out to a lambda function #<FUNCTION :LAMBDA (X) ... > via strategic use of function...

Language Requirements for AI Development

Possible Duplicate: Why is Lisp used for AI? Hey guys,im kind of curious as to what makes a language suitable for Artificial Intelligence development. Ive heard that LISP and Prolog are widely used in this field, but what features do they have that makes them suitable for AI development?.By the way sorry if this has already be...

Scheme or Common Lisp?

Hello! I am an intermediate programmer, and have decided to learn either common lisp or scheme. My question is simple, which one would you choose? I don't care much for the difficulty of the syntax, just the power, flexibility, and other aspects of the language itself. Also, which implementation of either common lisp or scheme should I c...

What could be the fastest and least painful way to learn LISP for a C developer?

I have been working as a C developer on Linux platform for sometime now. Recently finished K & R and did a little study of implementing OOP in C. Beside that I have studied C++ and Java. All of it has been on Linux platform. Now I plan to learn LISP. I have gone through LISP discussions directed towards beginners on SO, especially What’...

Defining the defmacro function using only LISP primitives?

McCarthy's Elementary S-functions and predicates were atom, eq, car, cdr, cons He then went on to add to his basic notation, to enable writing what he called S-functions: quote, cond, lambda, label On that basis, we'll call these "the LISP primitives" (although I'm open to an argument about type predicates like numberp) How would you ...

Why does plant1 keep being NIL???

Please, could someone explain me why "make-array" has no effect on plant1? (LET (plant1) ((setq plant1 (make-array '(4 4))) (print plant1) (setf (AREF PLANT1 0 0) 1))) NIL Error: Attempt to do an array operation on NIL which is not an array. [condition type: TYPE-ERROR] ...

Equivalent of 'lein swank' to other Lisp/Scheme implementations with emacs/slime.

I've been using emacs/slime for coding lisp, but with Clojure I found 'lein swank'. I must say that it's pretty useful, as I can connect to a server that runs clojure. How about the other Lisp implementations? What Lisp implementations provide the equivalent of 'lein swank' in Clojure? I mean, is there any other Lisp implementations th...

lisp package differences between repl and compile file

I'm currently playing with lispbuilder-sdl on SBCL under Windows. My source code is as follows: (asdf:operate 'asdf:load-op :lispbuilder-sdl) (asdf:operate 'asdf:load-op :lispbuilder-sdl-binaries) (asdf:operate 'asdf:load-op :lispbuilder-sdl-examples) (sdl-examples:squashed) When I compile the file I get the error: package "SDL-EXAMP...