In Peter Seibel's Practical Common Lisp, he gives this example:
(do ((nums nil) (i 1 (1+ i)))
((> i 10) (nreverse nums))
(push i nums))
I can see how it works, using nums inside the loop but not giving it a step-form. Why would you put nums in the variable-definition rather than do this:
(let (nums) (do ((i 1 (+ i 1)))
...
I'm a Lisp beginner. I'm trying to memoize a recursive function for calculating the number of terms in a Collatz sequence (for problem 14 in Project Euler). My code as of yet is:
(defun collatz-steps (n)
(if (= 1 n) 0
(if (evenp n)
(1+ (collatz-steps (/ n 2)))
(1+ (collatz-steps (1+ (* 3 n)))))))
(defun ...
I have been using PLT Scheme, but it has some issues. Does anyone know of a better implementation for working through SICP?
...
I'm doing an AutoLisp project which uses long associative structures to do heavy geometrical processing - so I'm curious about the associative list intense use timing results.
How simple/complex is the implementation? It uses some data structure or a normal list of dotted pairs?
The are any extension for b-tree or something?
...
Reading Paul Graham's essays on programming languages one would think that Lisp macros are the only way to go. As a busy developer working on other platforms I have not had the privledge of using lisp macros. As someone who wants to understand the buzz please explain what make's this feature so powerful.
Please also relate this to somet...
I've been researching modules for Nginx (my preferred webserver) to serve a Lisp webapp, but I haven't been able to find anything.
Is there modules for Nginx, or is there better ways to serve Lisp webapps? If so, what are they?
...
Are there any libraries out there that do this? Playing around with Common Lisp it seems like this would be one of the most useful things to lower barrier of entry for newcomers. ASDF seems mostly designed for deployment, not for rapid prototyping and development. Following threads on comp.lang.lisp it seems like people agree that CL's...
I recently downloaded PLT Scheme and DrScheme. When I open DrScheme, I am told to choose a language. However, I'm not familiar with any of my options, and the help guides don't really break it down to help me easily choose which choice.
So, first - is DrScheme and PLT Scheme really the tools I need to learn Lisp and/or Scheme? If so, wh...
(define (repeated f n)
if (= n 0)
f
((compose repeated f) (lambda (x) (- n 1))))
I wrote this function, but how would I express this more clearly, using simple recursion with repeated?
I'm sorry, I forgot to define my compose function.
(define (compose f g) (lambda (x) (f (g x))))
And the function takes as inputs a procedu...
I was wondering for a while about this topic and i would like to hear some opinions from the community. What i am wondering about is how to explain to a non-programmer the conceptual difference between a language like C and a language like Lisp. What I find challenging about this is to translate the knowledge of the language itself into ...
The kind of functions are of the sort of:
(defun display-all ()
"Display all items in the database."
(dolist (item database)
(format t "~{~a:~10t~a~%~}~%" item)))
(defun prompt-read (prompt)
(format query-io "~a: " prompt)
(force-output query-io)
(read-line query-io))
(defun prompt-for-item ()
(make-database
(prompt...
Still struggling to understand what best practices are with respect to macros. I'm attempting to write a macro which defines packages on the fly.
(defmacro def-dynamic-package (name)
`(defpackage ,(intern (string-upcase name) "KEYWORD")
(:use :common-lisp)))
This works fine only for expressions such as:
(def-dynamic-package "...
I'm looking for an alternative, since I find emacs difficult to use. I'd rather use an editor that supports all the usual shortcuts I'm used to, such as arrow keys to move the cursor around, CTRL+SHIFT+RightArrow to select the next word, etc.
Basically, I don't want to have to relearn all my familiar shortcuts just so I can use emacs.
...
Is there any persistence solution for Common Lisp, such as Elephant, that allows function persistence? Currently my app stores an identifier on the db and later searches in a function table which it is, but this method does not allow dynamically created functions to be stored.
...
Being relatively new to functional programming, I expend lots of energy wondering “is this the functional way to do things?” Obviously recursion vs. iteration is pretty straightforward and it’s obvious that recursion is the functional way of doing things. But take closures for instance.
I’ve learned about closures using Lisp and I under...
Hello,
I have a big list of global variables that each have thier own setup function.
My goal is to go through this list, call it's setup function, and generate some stats on the data loaded in.
The globals and thier setup functions are case-sensitive (this came from xml and is necessary for uniqueness).
The data looks something like ...
I find myself attached to a project to integerate an interpreter into an existing application. The language to be interpreted is a derivative of Lisp, with application-specific builtins. Individual 'programs' will be run batch-style in the application.
I'm surprised that over the years I've written a couple of compilers, and several dat...
I've decided to get back into LISP (haven't used it since my AI classes) to get more comfortable with functional programming in general, so I downloaded Lisp In A Box (which we actually used in a previous class) which comes with CLISP and Emacs.
When I run it, it says:
Connected on port 1617. Take this REPL, brother, and may it serv...
What's better for DSL: TCL or Lisp?
What can you say about Java(C#)-TCL binding versus Lisp(Scheme)?
What DSL tool is applicable for .Net development? (excepting Microsoft DSL tools)
...
What is the Emacs mode or package that highlights Lisp forms changing the color of the backgrounds so that the form you are in has one color, the outer form another, the outer outer form another and so on?
...