Here is an example that a forum poster gave, I can't tell if this tail optimized. Also, could someone give a laymans description of how a tail optimized version would trump the normal version.
(defun mylength (s)
(labels ((mylength-inner (s x)
(if (car s) (mylength-inner (cdr s) (+ x 1)) x)))
(mylength-inner s ...
Essentially, I would like to know what a Lisp image is? s it a slice of memory containing the Lisp interpreter and one or more programs or what?
...
I'm reading Paul Graham's A Plan for Spam and want to understand it better but my LISP is really rusty. He has a snippet of code that calculates probability as such:
(let ((g (* 2 (or (gethash word good) 0)))
(b (or (gethash word bad) 0)))
(unless (< (+ g b) 5)
(max .01
(min .99 (float (/ (min 1 (/ b nbad))
...
I was working with a Lisp dialect but also learning some Haskell as well. They share some similarities but the main difference in Common Lisp seems to be that you don't have to define a type for each function, argument, etc. whereas in Haskell you do. Also, Haskell is mostly a compiled language. Run the compiler to generate the execu...
I wrote the function
(defun test ()
(let ((str1 "foo") (str2 "bar"))
(loop for s in '(str1 str2) do (message s))))
but it does not work. The Elisp Backtrace message is:
Debugger entered--Lisp error: (wrong-type-argument stringp str1)
How can I make it work?
P.S.: the following modified version works perfectly, but I need ...
I am starting a new project at work where I will be required to use Lisp as a part of some cognitive work that I will be doing. I'm not very familiar with Lisp. Do any of you know of any books that will help me get up to speed quickly?
...
Ok, so I'm psyched about another list. I got myself a copy of the beta Clojure programming book...
And the one thing I'm noticing most is that it's assumed I know... like all the major java classes.
Except, generally, I don't really care about Java. I just want enough knowledge of it for Clojure to be an option for me.
Any suggestio...
I am looking for a mathematical book on Lisp. Some ideas?
...
I'm interested in building a Texas Hold 'Em AI engine in Java. This is a long term project, one in which I plan to invest at least two years. I'm still at college, haven't build anything ambitious yet and wanting to tackle a problem that will hold my interest in the long term. I'm new to the field of AI. From my data structures class at ...
I am trying to build a Lisp grammar. Easy, right? Apparently not.
I present these inputs and receive errors...
( 1 1)
23 23 23
ui ui
This is the grammar...
%%
sexpr: atom {printf("matched sexpr\n");}
| list
;
list: '(' members ')' {printf("matched list\n");}
| '('')' {printf("matched...
Are the functional programming features provided in C# rich enough? Would a LISP programmer miss LISP when programming in C#.. whats missing??
...
Is this just a bit of historical cruft left over from the 1950s or is there some reason syntactically why multi-expression bodies of (if) forms require (progn)? Why can't you wrap the multiple expressions in a set of parentheses like with (let):
(if some-cond
((exp1) (exp2) (exp3)) ; multi exp "then"
(exp4)) ; single exp "e...
How can I exchange two variables in LISP without using a third variable?
...
I have been reading a lot about Reinforcement Learning lately, and I have found "Reinforcement Learning: An Introduction" to be an excellent guide. The author's helpfully provice source code for a lot of their worked examples.
Before I begin the question I should point out that my practical knowledge of lisp is minimal. I know the basic...
In C++ I'd write something like this:
if (a == something && b == anotherthing)
{
foo();
}
Am I correct in thinking the Clojure equivalent is something like this:
(if (= a something)
(if (= b anotherthing)
(foo)))
Or is there another way to perform a logical "and" that I've missed? As I said the latter form seems to ...
One of the people who took the time to comment on my other question about Clojure/LISP syntax pointed out that I had not written my sample code in the standard LISP way. So he was kind enough to rewrite the code snippet and that's a big help. But it raised another question in my mind. Why would this:
(if (= a something)
(if (= b ot...
I know that this is subjective and all, but still, can you guys (and gals) provide some list of serious applications that were written in Lisp (perhaps along with what Lisp it is)?
...
What's the difference between eq, eql, equal, and equalp in Lisp? I understand that some of them check types, some of them check across types an all that, but which is which? When is one better to use than the others?
...
Hello all,
I just wrote a simple Common Lisp program to find out Simpson's Integral:
;Integration by Simpson's rule; CL code
;Found to be working correctly with 'clisp'
(defun simpsons(f a b n)
(defparameter *summation* 0)
(defvar *h* (/ (- b a) n))
(loop for k from 2 below (- n 1) by 2 do
(setf *summation* (+ *summation* ...
Learning Common Lisp (using GNU CLISP 2.43) .. so might be a noob mistake. Example is the 'print prime numbers between x and y'
(defun is-prime (n)
(if (< n 2) (return-from is-prime NIL))
(do ((i 2 (1+ i)))
((= i n) T)
(if (= (mod n i) 0)
(return NIL))))
(defun next-prime-after (n)
(do ((i (1+ n) (1+ i)))
...