lisp

What are the things that optimize speed declaration do in CL?

What are some of the optimization steps that this command does `(optimize speed (safety 0))` Can I handcode some of these techniques in my Lisp/Scheme program? ...

Can I disassemble my code in PLTScheme?

Can I see the translated machine instruction of a scheme function like (disassemble) in LISP? ...

How can I reuse a gethash lookup in Common Lisp?

I have a hash table where the keys are rather complex lists, with sublists of symbols and integers, and the value should be modified depending on the already existing value. The table is created with :test #'equal. I do something similar to this a lot: (defun try-add (i) (let ((old-i (gethash complex-list table nil))) (if (may-ad...

Setting up a working Common Lisp environment for the aspiring Lisp newbie

I've been a UNIX sysadmin for a long time, and aside from automating tasks with shell scripting, some light PHP work, and a few simple C programs, I've never done much in the way of programming. I recently decided to stretch my mind a bit and learn Common Lisp. I'm half-way through Touretzky's "Gentle Intro" and, having just reached th...

How do I 'get' Lisp?

I've read The Nature of Lisp. The only thing I really got out of that was "code is data." But without defining what these terms mean and why they are usually thought to be separate, I gain no insight. My initial reaction to "code is data" is, so what? ...

Lisp: Elegant way to strip trailing nil's from a list? (Review)

I want to write a function that removes trailing nil's from a list. I first tried to write it elegantly with recursion, but ended up like this: (defun strip-tail (lst) (let ((last-item-pos (position-if-not #'null lst :from-end t))) (if last-item-pos (subseq lst 0 (1+ last-item-pos))))) ; Test cases. (assert (eq nil (strip-t...

Newbie question about Lisp and Packages

Here is the back story skip to the bottom if you do not care and only want to see the question. So I have been playing around in LISP for a little while. Some basic functions, some classes ,and file IO. When I run across this article: http://www.adampetersen.se/articles/lispweb.htm And I am excited to try and use lisp for a web appli...

Clojure/Java Mandelbrot Fractal drawing

I am trying to port this algorithm to clojure. My code is (defn calc-iterations [x y] (let [c (struct complex x y)] (loop [z (struct complex 0 0) iterations 0] (if (and (< 2.0 (abs z)) (> max-iterations iterations)) iterations (recur (add c (multiply z z)) (inc iterations)))))) ...

Since everyone is coding Lisp and Erlang now, does that mean that we will see Forth coders in 2010?

I'm think I see more and more coders looking into Erlang and Lisp. Since I learned it in exactly the same order, and now, I'm looking into Forth, does it mean that Forth is the next language on everyone's TODO list? What is your next language? ...

How to add up the elements for a structure in Scheme/Lisp

I have an input which is of this form: (((lady-in-water . 1.25) (snake . 1.75) (run . 2.25) (just-my-luck . 1.5)) ((lady-in-water . 0.8235294117647058) (snake . 0.5882352941176471) (just-my-luck . 0.8235294117647058)) ((lady-in-water . 0.8888888888888888) (snake . 1.5555555555555554) (just-my-luck . 1.3333333333333333)))...

How do I make a module in PLT Scheme?

I tried doing this: #lang scheme (module duck scheme/base (provide num-eggs quack) (define num-eggs 2) (define (quack n) (unless (zero? n) (printf "quack\n") (quack (sub1 n))))) But I get this error: module: illegal use (not at top-level) in: (module duck scheme/base (provide num-eggs qu...

In what languages can you dynamically rewrite functions on the fly?

I recently had the necessity of rewriting a javascript function in javascript, dynamically. The ease with which I did it, and how fun it was, astounded me. Over here I've got some HTML: <div id="excelExport1234" onclick="if(somestuff) location.href='http://server/excelExport.aspx?id=56789&amp;something=else'; else alert('not imp...

Looking for a recommendation for an AutoLisp / VisualLisp book

Can anyone recommend a good introductionary book dealing with AutoLisp and VisualLisp? I found some general Lisp books out there, but I'm uncertain how much Lisp variants differ. I haven't found any in the old questions in here, either. ...

List comprehension python

What is the equivalent list comprehension in python of the following Common Lisp code: (loop for x = input then (if (evenp x) (/ x 2) (+1 (* 3 x))) collect x until (= x 1)) ...

How do you perform arithmetic calculations on symbols in Scheme/Lisp?

I need to perform calculations with a symbol. I need to convert the time which is of hh:mm form to the minutes passed. ;; (get-minutes symbol)->number ;; convert the time in hh:mm to minutes ;; (get-minutes 6:19)-> 6* 60 + 19 (define (get-minutes time) (let* ((a-time (string->list (symbol->string time))) (hour (first a-time)...

Resources for Learning about Non-C Compilers?

When it comes to learning about C compilers LCC seems like the compiler of choice for many. Also, there is another StackOverflow article here on learning compilers in general. However, I've previously studied C compilers and am looking for something a bit deeper in terms of programming paradigms. To be clear, what I am looking for are...

Rule of thumb for capitalizing the letters in a programming language

I was wondering if anyone knew why some programming languages that I see most frequently spelled in all caps (like an acronym), are also commonly written in lower case. FORTRAN, LISP, and COBOL come to mind but I'm sure there are many more. Perhaps there isn't any reason for this, but I'm curious to know if any of these changes are d...

About "If.." in Scheme (plt-scheme)

I had a pretty simple requirement in my Scheme program to execute more than one statement, in the true condition of a 'if'. . So I write my code, something like this: (if (= 1 1) ((expression1) (expression2)) ; these 2 expressions are to be executed when the condition is true (expression3) ) Obviously, the above doesn't work, ...

How to write the Average Function for this Data structure in Scheme/Lisp?

I want to find the price of a new-item based on the average prices of similar items. The function get-k-similar uses k-Nearest Neighbors but returns me this output ((list rating age price) proximity). For example, 2-similar would be: (((5.557799748150248 3 117.94262493533647) . 3.6956648993026904) ((3.0921378389849963 7 75.614925605968...

How can I use Scheme/Lisp/Clojure for Matrix/LP problems?

I need to perform numerical analysis like that supported by MatLab or NumPy. Is there a good library that is supported by Scheme/Lisp/Clojure(Java)? I don't want to leave my round braces. Thanks a lot. ...