lisp

reduce, or explicit recursion?

I recently started reading through Paul Graham's On Lisp with a friend, and we realized that we have very different opinions of reduce: I think it expresses a certain kind of recursive form very clearly and concisely; he prefers to write out the recursion very explicitly. I suspect we're each right in some context and wrong in another, ...

A way to strip returned values from java.io.File.listFiles in Clojure

Hi I call a java function in Clojure to get a list of files. (require '[clojure.java.io :as io]) (str (.listFiles (io/file "/home/loluser/loldir"))) And I get a whole bunch of strings like these #<File /home/loluser/loldir/lolfile1> etc. How do I get rid of the brackets and put them in some form of an array so another function can...

Is there a Scheme interpreter that uses Normal-order evaluation?

I've been slowly working my way though the exercises in Structure and Interpretation of Computer Programs. Section 1.1.5 talks about applicative vs. normal-order evaluation, and the topic has come up several times in the text afterward. Since the interpreter uses applicative-order evaluation, it's easy to just insert display debug stat...

How does a macro-enabled language keep track of the source code for debugging?

This is a more theoretical question about macros (I think). I know macros take source code and produce object code without evaluating it, enabling programmers to create more versatile syntactic structures. If I had to classify these two macro systems, I'd say there was the "C style" macro and the "Lisp style" macro. It seems that debu...

how to do file selection using mouse with emacs cedet?

I am using emacs 23.2 on Ubuntu 10.04 & Windows XP along with cedet extention. Cedet seems to work fine but I could not select the file using mouse. Rather I need to use the Key press to select the file from cedet (placed at left side).. how to do file selection using mouse with emacs cedet? Any clue shall be appreciated... ...

Stuck in a Clojure loop, need some guidance

Hi, I am stuck in a Clojure loop and need help to get out. I first want to define a vector (def lawl [1 2 3 4 5]) I do (get lawl 0) And get "1" in return. Now, I want a loop that get each number in the vector, so I do: (loop [i 0] (if (< i (count lawl)) (get lawl i) (recur (inc i)))) In my mind this is supposed...

10 LISP primitives analogous to 5 axioms of Euclidean geometry?

LISP can be built from ten primitives: The primitives are: atom, quote, eq, car, cdr, cons, cond, lambda, label, apply. Apparently these are equivalent to the 5 axioms of Euclidean geometry. http://hyperpolyglot.wikidot.com/lisp Can anyone explain how they are equivalent? ...

common lisp cons creates a list from two symbols, clojure cons requires a seq to cons onto?

(Disclaimer - I'm aware of the significance of Seqs in Clojure) In common lisp the cons function can be used to combine two symbols into a list: (def s 'x) (def l 'y) (cons s l) In clojure - you can only cons onto a sequence - cons hasn't been extended to work with two symbols. So you have to write: (def s 'x) (def l 'y) (cons s '(l...

In Clojure: Error executing a Java call with let inside a function but not in REPL

I have the following code: (defn post [title content timestamp] (let [[innholdet tajm] [(str "<html> <head> <title>" title " :: " blog_title "</title></head> <body><h1>" title "</h1> <br/>" content "<br/><i>posted " (Date. timestamp) "</i> <br/><a href=\"...

idiomatic way to replace (null x) function from common lisp in clojure

In Common Lisp you use the (null x) function to check for empty lists and nil values. Most logically this maps to (or (nil? x) (= '() x)) In clojure. Can someone suggest a more idiomatic way to do it in Clojure? ...

Why do you love Ruby, [Other programming language]?

I've reached the point of burnout and I haven't even started my career. Whenever I look at C it looks nice and light and just clean until I start writing anything in it. C++ is just plain and simply ugly, I won't even say anything about PHP, Lua and Python kinda ok but quickly gets to the point where I just can't enjoy writing anything i...

Android without Java

After doing the whole "enterprise" programming for a while, I'm seriously disillusioned by the language itself and always feel quite hampered if I have to go back to it. The project size of your average Android app isn't too intimidating and the libraries are actually quite nice regarding their coding style, but if I could avoid Java, I'...

(define (average ....)) in Lisp

I'm just playing around with scheme/lisp and was thinking about how I would right my own definition of average. I'm not sure how to do some things that I think are required though. define a procedure that takes an arbitrary number of arguments count those arguments pass the argument list to (+) to sum them together Does someone have...

How Are Lazy Sequences Implemented in Clojure?

I like Clojure. One thing that bothers me about the language is that I don't know how lazy sequences are implemented, or how they work. I know that lazy sequences only evaluate the items in the sequence that are asked for, how does it do this? What makes lazy sequences so efficient that they don't consume much stack? How come you can ...

Why do I get NPE in the following code?

The following code executes as expected but gives a NullPointerException at the end. What am I doing wrong here? (ns my-first-macro) (defmacro exec-all [& commands] (map (fn [c] `(println "Code: " '~c "\t=>\tResult: " ~c)) commands)) (exec-all (cons 2 [4 5 6]) ({:k 3 :m 8} :k) (conj [4 5 \d] \e \f)) ; Output: ; Clojure 1.2.0-...

Lisp code debugging

During web searching, I found the following comment : Traditional Lisp debugging practices can still be used. What are the traditional debugging practices? Normally, what tools are used for debugging lisp (with/without emacs)? ...

evaluate expression before it is put in lambda

I have the following piece of code in my .emacs: (dolist (mode '(scheme emacs-lisp lisp clojure)) (add-hook (intern (concat (symbol-name mode) "-mode-hook")) (lambda () (progn (run-programming-hook) (message "%s" (concat (symbol-name mode) "-mode"))) Obviously the mode variable is void when lambda gets to ...

SQLITE user-defined functions in Lisp

In SQLITE there is a possibility to relatively easily create User-Defined Functions and Aggregates in (extension) languages such as C, Perl, Python and others. Is there also such possibility using common-lisp as SQLITE language extension? I know there are libraries like cl-sqlite and plain-odbc but they don't seem to offer this possibil...

Is there a Scheme implementation that parallelizes?

Is there a R5RS-or-higher Scheme implementation that does parallelization? For example, if I say to do: (map (lambda (x) (pure-functional-stuff x)) '(1 3 5 7 11 13)) it will process 1, 3, 5, and 7 simultaneously if the machine can do it? That's supposed to be one of the big advantages of functional programming, but I c...

Clojure: No implementation of method in protocol

I am trying to load the Clojure library for RDF clj-plaza in Clojure REPL like so: user=> (use 'plaza.rdf.core) nil I have a folder named plaza, and a subfolder named rdf and the file core.clj available and as far as I can tell, Clojure REPL loads the library as it should. Now, if I do user=> (alter-root-rdf-ns “http://www.example.o...