lisp

Swapping elements in a Common Lisp list.

Is there a Common Lisp function that will swap two elements in a list given their indices and return the modified list? ...

Using Hadoop map/reduce for programming language design course project

I need to design an exercise for my students in programming language design, My idea is help them to learn ideas in lisp, ML and other functional languages by force them to implement a mapreduce exercise with hadoop. Is here any suggestion that help me detail my idea? ...

Clojure: gc overhead limit exceeded, lazy evaluation, pi sequence

For the next code: (ns clojure101.series) (defn avg [[x y]] (/ (+ x y) 2)) (defn avg-damp [seq] (map avg (partition 2 seq))) (defn avg-damp-n [n] (apply comp (repeat n avg-damp))) (defn sums [seq] (reductions + seq)) (defn Gregory-Leibniz-n [n] (/ (Math/pow -1 n) (inc (* 2 n)))) (def Gregory-Leibniz-pi (map #(...

Have some way to save the REPL state of Common Lisp or Scheme?

Have some way to save the REPL state of Common Lisp or Scheme? Thanks ...

large output in common lisp linux terminal

I wrote a clisp program that prints out n sets of x*y random integers. I'd like to make n=100, but I can't copy and paste the whole thing because my linux terminal doesn't go back far enough, for lack of a better word. I'd like the simplest way possible to capture 2200 lines of linux terminal readout. ...

Common Lisp Wildcard for eql

Is there a wildcard in Common Lisp that is eql to any atom? That is, is there any wildcard such that (eql wildcard any-atom) returns true? ...

LISP function to remove nils

I want to write a function in LISP that will completely remove all NILS in a list. The list may be nested, meaning it can contain other lists inside. For example the list '((state L L L L) NIL (state L L R L) NIL) should be tranformed into '((STATE L L L L) (STATE L L R L)). ...

cl-pdf output error

I'm trying to use cl-pdf for some fairly basic PDF generation, but I'm getting tripped up at the examples (which is embarassing to say the least). When I run the first example included in the package (defun example1 (&optional (file #P"/tmp/ex1.pdf")) (pdf:with-document () (pdf:with-page () (pdf:with-outline-level ("Example...

Data structure with two primary keys? (caching lat/lon address pairs)

I'm trying to cache lat/lon address pairs from Google Maps, so I need a data structure where the key is two ints (lat and lon). What's the simplest data structure for that? I thought of two ways so far: Nested hash: {37.734608 {-121.913019 "San Ramon, CA" -121.6 "Tracy, CA"}} Concat the two to make the key: {"37.734608,-121.913019"...

hacker news algorithm in php?

this is the hacker news ranking algorithm, which i think is a simple way of ranking things, espcially if users are voting on items, but i really dnt understand this, can this be converted to php, so i can understand it fully? ; Votes divided by the age in hours to the gravityth power. ; Would be interesting to scale gravity in a sli...

What does #[...] mean in emacs-lisp?

Hello everyone! I am puzzled by the expression #[nil "\300\207" [nil] 1] as a value of skeleton-pair-filter-function. Is this an alternative way of writing function in elisp? Or lisp in general? Thanks. ...

Strange Lisp Quoting scenario - Graham's On Lisp, page 37

I'm working my way through Graham's book "On Lisp" and can't understand the following example at page 37: If we define exclaim so that its return value incorporates a quoted list, (defun exclaim (expression) (append expression ’(oh my))) > (exclaim ’(lions and tigers and bears)) (LIONS AND TIGERS AND BEARS OH MY) > (nconc * ’(goodnes...

Reorder function arguments in Lisp

I'm interested in an operator, "swap-arg", that takes as input 1) a function f of n variables, and 2) index k, and then returns a the same function except with the first and kth input variables swapped. eg (in mathematical notation): (swap-arg(f,2))(x,y,z,w) = f(z,y,x,w) Now my first idea is to implement this using rotatef as follows, ...

Play MIDI file from Common Lisp

Is it possible to play a MIDI file (existing on the hard drive) from Common Lisp? If so, how? ...

How would a LISP developer solve the problem that AutoMapper solves in .NET?

I.e. transferring the state from one object to another object, which shares some (but not all) of the first object's members. I'm not applying this question to any real-life problem yet, but I guess I'm asking it to get a feel for the differences between the problem-solving approach in LISP as opposed to object-oriented languages like C...

Common Lisp Error Not Understood

I'm trying to write a number guessing game in Lisp as a time-killing project. However, when I try to load up the program using SBCL, I get the following error: debugger invoked on a SB-C::INPUT-ERROR-IN-COMPILE-FILE in thread #<THREAD "initial thread" RUNNING ...

How viable is emacs LISP aside from editing emacs?

I'm in my second year of my CS major, and I've only had courses in C (first course and then a polymorphic data structures course), C++ (OOP focus), MIPS assembly, and a compiler course. I worked in WinForms and C# over the summer. I worked through the Little Schemer and I'm really interested in learning some sort of LISP. Emacs is my e...

Read Statement Being Skipped Over, Unbound Variable

I'm still working on my number guessing game in Common Lisp, and I've reached a standstill. When the following code is invoked: ;;;; number-game.lisp ;;;; ;;;; Andrew Levenson ;;;; 10/25/2010 ;;;; ;;;; Simple number guessing game. User has ;;;; five guesses to determine a number between ;;;; one and one hundred, inclusive (1-100). ;;; ...

Integer Value is Not a Number in Common Lisp?

When I execute the following Common Lisp program by calling (play), I get the error: Argument X is not a NUMBER: Guess ;;;; number-game.lisp ;;;; ;;;; Andrew Levenson ;;;; 10/25/2010 ;;;; ;;;; Simple number guessing game. User has ;;;; five guesses to determine a number between ;;;; one and one hundred, inclusive (1-100). ;;; Set globa...

What is the simplist way to ensure that 2 lists in lisp are the same length?

Given 2 lists, I want to ensure that they are the same size, I'm having a tough time with this code. Should I be using variables to do this? (defun samesize (list1 list2) (cond (;logic here) T)) ...