scheme

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. ...

SCHEME: how to input html and output it as html source?

Hi, I am trying to write a simple web app in scheme and I am using Drscheme for the job. I am wondering if there is a way to input html code into a form which then outputs it in html format (into source)? Is there a library that does the job? Everytime I input something it turns out as a string, I need it to be read as html. Can someone ...

Can I use Common Lisp for SICP or is Scheme the only option?

Also, even if I can use Common Lisp, should I? Is Scheme better? ...

Question about SimpleHTTPServer.py

I am partially through implementing the functionality of SimpleHTTPServer.py in Scheme. I am having some good fun with HTTP request/response mechanism. While going through the above file, I came across this- " # redirect browser - doing basically what apache does" in the code". Why is this redirection necessary in such a scenario? ...

What is the rationale behind using def and defn instead of just define?

In Scheme, we just had define for all the definition, why does Clojure and Lisp use different keywords for different declarations? ...

Small SICP/Scheme question (local state)

I'm actually reading the book for fun but it might be considered homework. At any event, I don't feel comfortable with local state variables at all with this language... Take for example this code: (define flip (let ((count 0)) (lambda () (if (= 0 count) (begin (set! count 1) count) (begin (set! count 0) ...

Continuations in Clojure.

I read somewhere where rich hickey said: "I think continuations might be neat in theory, but not in practice" I am not familiar with clojure. 1. Does clojure have continuations? 2. If no, dont you need continuations? I have seen a lot of good examples especially from this guy. What is the alternative? 3. If yes, is there a docu...

Running Scheme from the command line

How do you run Scheme programs from the terminal in linux(ubuntu)? Also how to accept arguments from the command-line in a Scheme program? Edit: Im using the DrScheme implementation. ...

Recommendations for a lisp setup on Mac OS X (any dialect)?

What is your Mac OS X (Intel) based lisp setup (of any dialect), how do you like it, and how painful was it to set up? I'm looking for a versatile lisp that is easy to set up, but if you feel strongly about investing more effort, or even money, I would like to hear why you think it's worth it. I am currently using newLisp, which was a b...

Which is better?: (reduce + ...) or (apply + ...) ?

Should I use (apply + (filter prime? (range 1 20))) or (reduce + (filter prime? (range 1 20))) Edit: This is the source for prime in clojure from optimizing toolkit. (defn prime? [n] (cond (or (= n 2) (= n 3)) true (or (divisible? n 2) (< n 2)) false :else (let [sqrt-n (Math/...

Simple (to code) secure hash function

I need a secure (cryptographic) hash function with the following properties: Can be coded in as few lines as possible (in R5RS Scheme). Hopefully under 50. Memory and CPU performance within reason for password-length data. (e.g. it does not have to be super efficient or create hashes for millions of bytes of data) Most secure hash fu...

Seemingly unnecessary case in the unification algorithm in SICP

Hi guys, I'm trying to understand the unification algorithm described in SICP here In particular, in the procedure "extend-if-possible", there's a check (the first place marked with asterix "*") which is checking to see if the right hand "expression" is a variable that is already bound to something in the current frame: (define (extend...

Can a compiled language be homoiconic?

By definition the word homoiconic means: Same representation of code and data In LISP this means that you could have a quoted list and evaluate it, so (car list) would be the function and (cdr list) the arguments. This can either happen at compile- or at run-time, however it requires an interpreter. Is it possible that compiled l...

Language Evaluation question: Eager Vs. Lazy

I was reading Shriram's PLAI and this I got stuck in these questions: Can you prove that the eager and lazy regimes will always produce the same answer? (Shriram asks to look at the language he developed but is there another way to prove this and how?) Will eager evaluation always reduce with fewer steps? Here is the Code of Substitu...

Intuitive motivation for Literate Programming?

So, I used the scribble/lp module to write my first literate program using plt-scheme: #lang scribble/lp (require scribble/lp) <<lp_scheme.ss>> @chunk[<squarefunction> (define (f x) (* x x))] Nothing useful there, of course. Now I am sort of wondering why would I just not use plain comments, instead of literate prog...

Difference between deftype in Common Lisp and Scheme

I'm trying to translate some Common Lisp code into Scheme code. The Common Lisp code has a deftype. Are deftypes in Scheme the same as deftypes in Common Lisp? How do you translate a deftype in Common Lisp into equivalent code in Scheme? ...

Suitable functional language for scientific/statistical computing?

I use mostly R and C for statistics-related tasks. Recently I have been dealing with large datasets, typically 1e7-1e8 observations, and 100 features. They seem too big for R too handle, and the package I typically use are also more prone to crashing. I could develop tools directly in C or C++, but this would slow down the development cy...

Equivalent of defsetf in Scheme

Is there an equivalent in Scheme of Common Lisp's defsetf? ...

How I Can do web programming with Lisp or Scheme?

I usually write web apps in PHP, Ruby or Perl. I am starting the study of Scheme and I want to try some web project with this language. But I can't find what is the best environment for this. I am looking for the following features: A simple way of get the request parameters (something like: get-get #key, get-post #key, get-cookie #ke...