clojure

writing a multiplexing server in clojure?

I would like to write a simple multiplexing server in Clojure (as a sample project to learn the language) but I am having a very hard time finding resources to aid me in this on the web. does anyone have any resources that can point to the basics of socket programming in Clojure and the best way to go about writing such a server? ...

can I use two different lisp+slime/swanks from the same emacs?

can I use common lisp and Clojure from within emacs at the same time? I would like to have each lisp-REPL in its own buffer, and If i did this how could I controll which buffer sent its data to which lisp? ...

programatically using Hardware Random number generator

I'm working on a desktop application and would love to use any hardware random number generators that happen to be available, though I dont want the user to have to do any confusing setup to use it. its Java/Clojure based so something in the java world would be nice though I'm willing to work with just about anything. Know of any program...

How do I write :else in condp in Clojure?

I want to use the condp clause but I dont know how to catch any unmatched clause. How do I do that? (defn subst[id value W-lang] (let [[type expr][(first W-lang)(rest W-lang)]] (condp = type 'num (first expr) 'add expr ***** expr))) ...

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

Help in designing a small Unit Test Macro in Clojure

I have a small unit test macro (defmacro is [expr value] `(if (= ~expr ~value) 'yes (println "Expected " ~value "In" ~expr "But Evaluated to" ~expr))) How do I correctly write the error message? Right now it gives Clojure 1.0.0- 1:1 user=> (is (+ 2 2) 4) user/yes 1:2 user=> (is (+ 2 2) 5) Expected ...

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

Why should I use 'apply' in Clojure?

This is what Rich Hickey said in one of the blog posts but I don't understand the motivation in using apply. Please help. A big difference between Clojure and CL is that Clojure is a Lisp-1, so funcall is not needed, and apply is only used to apply a function to a runtime-defined collection of arguments. So, (apply f [i]) can be writ...

URL Checker in Clojure?

I have a URL checker that I use in Perl. I was wondering how something like this would be done in Clojure. I have a file with thousands of URLs and I'd like the output file to contain the URL (minus http://, https://) and a simple :1 for valid and :0 for false. Ideally, I could check each site concurrently, considering that this is on...

What's the most useful thing you've done in less than 50 lines of Clojure?

Clojure seems likes it might have a good shot at being a popular Lisp. I was wondering how many people have actually adopted it to solve some of the small, yet real, problems that they have encountered. Since Clojure doesn't have an entry in Pleac, I thought that it would be great if people posted their small solutions to problems that...

Help me write Cond Macro in Clojure.

I am learning Macros in Clojure and wanted to write the "cond" macro. I am having problem de-structuring the arguments into (condition) (arguments) and writing a recursive macro. Please help me. ...

Source code of well designed functional web apps?

What are examples of well designed functional (as opposed to object oriented) web apps that make their source code available? I am currently studying the Hacker News source but I'd like to see some other non-trivial examples, ideally in clojure. For MVC there are lots of Rails and PHP apps, frameworks, and tutorials to study - what is t...

What is the time complexity of count function in clojure?

What is the time complexity of count in clojure? ...

How can I find the difference in 2 data sets?

If I have 2 pipe delimited files containing bookmark data, for example. How can I read in the data then determine the difference in the two sets of data? Input Set #1: bookmarks.csv 2|www.cnn.com|News|This is CNN 3|www.msnbc.com|Search| 4|news.ycombinator.com|News|Tech News 5|bing.com|Search|The contender Input Set #2: bookmarks2.csv...

What would be the correct way to serialize this Java Object in Clojure?

I have a dummy Java Program, which I want to write in Clojure. It has a class which implements Serializable and a function which saves it. Since I have never written such programs in Clojure, I wanted to know what would be the correct way to approach this problem, what Clojure data structures, and api calls would you use? import java. i...

How do I persist and restore my defstruct's to a file?

I want to persist my data to a file and restore the data when I rerun the program. I've defined my defstruct as such: (defstruct bookmark :url :title :comments) Program will simply do the following: 1. Load the defstruct's from url-db.txt 2. Read from an import file(s) passed into *command-line-args* and add to internal data var. 3. ...

Eval not working on unexpanded macro quote

In common lisp I can do this: src-> (defmacro macro-hello () `"hello") (eval '(macro-hello)) no problem. In clojure: (defmacro macro-hello [] `"hello") (eval '(macro-hello)) gives me an error. Have I done something wrong? Clojure Error: Exception in thread "main" java.lang.Exception: Unable to resolve symbol: macro-hello i...

Scala vs. Groovy vs. Clojure

Can someone please explain the major differences between Scala, Groovy and Clojure. I know each of these compiles to run on the JVM but I'd like a simple comparison between them. ...

Clojure macro to create a synonym for a function

Probably an easy one for anyone who actually knows how to write macros in any Lisp. I want to be able to define synonyms for function names. I've been copy-and-paste hacking core.clj to do this, but I don't want to be such a dunce forever! It seems obvious a macro that rewrites the call to a synoym-function into a call to the original...

define a synonym for a Clojure macro

So following on from http://stackoverflow.com/questions/1315099/clojure-macro-to-create-a-synonym-for-a-function , I discovered that def can't be used to define a synonym for a macro. Below are examples I tried that Clojure doesn't allow. ;(def def-function defn) ;(def case cond) ;(def function fn) Is it possible to define synonyms/al...