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? ...
Is there a Common Lisp function that will swap two elements in a list given their indices and return the modified list? ...
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? ...
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? Thanks ...
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. ...
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? ...
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)). ...
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...
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"...
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...
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. ...
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...
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, ...
Is it possible to play a MIDI file (existing on the hard drive) from Common Lisp? If so, how? ...
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...
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 ...
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...
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). ;;; ...
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...
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)) ...