clojure

Clojure apply vs map

I have a sequence (foundApps) returned from a function and I want to map a function to all it's elements. For some reason, apply and count work for the sequnece but map doesn't: (apply println foundApps) (map println rest foundApps) (map (fn [app] (println app)) foundApps) (println (str "Found " (count foundApps) " apps to delete")))) ...

Symbols in Clojure

What is the rationale for Symbols in Clojure to be bound to an underlying object and have an optional separate value ? Perhaps something elementary I am missing but would be great if someone could point out the Why. ...

What's the recommended way of running a stand-alone clojure REPL?

I'm using rlwrap, but I don't have tab-completion, and characters with accents get mangled. This is on OSX 10.6 in Terminal.app. ...

Clojure: Is it possible to make a macro to create the two elements in a single condp clause?

The condp clauses look like this: "plet" (make-adj 2 "ète") "iet" (make-adj 2 "ète") "nin" (make-adj 1 "gne") I want to add the condition to the make-adj function call without repeating the condition twice in one line. I'd like a macro that turns this: (test-make-adj "plet" 2 "ète") (test-make-adj "iet" 2 "ète") (...

How can I update a vector item in Clojure?

Given: (def my-vec [{:id 0 :a "foo" :b "bar"} {:id 1 :a "baz" :b "spam"} {:id 2 :a "qux" :b "fred"}]) How can I idiomatically update* the item in my-vec with :id=1 to have values :a="baz2" and :b="spam2"? *(I recognize that I wouldn't actually be updating my-vec, but really returning a new vector that is identical to my...

Question about clojure namespaces and macros

Suppose I've got a bunch of namespaces (apple, banana, orange). In these namespaces I use the eat macro, which calls (not "generates", calls) the peel function. The peel function is different for each fruit, but the macros are identical, and fairly big, so I'd like to create a fruit namespace that contains the eat macro. But when I call ...

How to check the equality of strings in clojure without invoking java.lang.String?

Hi. Is there any way in clojure to check the equality of strings? i.e. I need to know, whether their contents is equal, not location. thanks. ...

Clojure macro to collect strings in constant.

I've got a Clojure file with a lot of string constants. I want to collect these strings in a collection by wrapping them in a macro. After several tries I succeeded, but my solution looks fairly hideous. (ns Memorable) (def MEMORY (atom [])) (defmacro memorize [s] (swap! MEMORY conj s) s) (prn (str (memorize "hello") " brave new " (mem...

Clojure and SSL/x.509 certs quetion

I need to write a simple program for work that does the following: read a config file connect to a bunch of servers establish a ssl socket pull info form the server's x509 cert, expire date and hostname for now email a report when its done items 3 and 4 are things that I have had bad luck researching/googleing and I do not know java ...

Debugging in Clojure ?

Hi, What are best ways to Debug Clojure code, while using the repl in Clojure-box ? ...

Why can't I bind + in clojure?

Can anyone explain why I can rebind list but not +? (binding [list vector] (list 1 3)) (binding [list +] (list 1 3)) (binding [+ list] (+ 1 3)) I'd like to rebind + so I can do partial evaluation. ...

How can I embed Clojure in an RCP application

I am currently using javascript to add scripting to an Eclipse RCP application, but I would prefer to be able to use Clojure. However, I have run into classpath difficulties because while Eclipse can find the Clojure classes, Clojure itself can't. The plugin activator's start method: public void start(BundleContext context) throws Exce...

How do I operate on every item in a vector AND refer to a previous value in Clojure?

Given: (def my-vec [{:a "foo" :b 10} {:a "bar" :b 13} {:a "baz" :b 7}]) How could iterate over each element to print that element's :a and the sum of all :b's to that point? That is: "foo" 10 "bar" 23 "baz" 30 I'm trying things like this to no avail: ; Does not work! (map #(prn (:a %2) %1) (iterate #(+ (:b %2) %1) 0)) my-vec) ...

sequence of a rolling average in Clojure

I'm looking for an elegant way to generate a sequence of the rolling average of a sequence of numbers. Hopefully something more elegant than using lazy-seq ...

= and == in Clojure

Hi On REPL, if I define (def fits (map vector (take 10 (iterate inc 0)))) and then call (== [2] (nth fits 2)) I get false. But (= [2] (nth fits 2)) returns true. Is this expected ? I tried (class [2]) and (class (nth fits 2) and both return Persistent Vector. ...

Jump to function definition in Emacs + Slime/leiningen-Swank + Clojure

I'm using Emacs with clojure mode and slime connected to a swank server produced by running lein swank and would really love to be able to easily jump to function definitions within my project. Can I do this with out having to manually rebuild tags every time I change branches? ...

Can I connect two emacs/slimes to the same swank instance?

when I start swank through leiningen it accepts the next slime connection and off I go. I would really like to have several emacs instances connect to the same swank instance. Can I do this? can I do this through leiningen? ...

Language/libraries for downloading & parsing web pages?

What language and libraries are suitable for a script to parse and download small numbers of web resources? For example, some websites publish pseudo-podcasts, but not as proper RSS feeds; they just publish an MP3 file regularly with a web page containing the playlist. I want to write a script to run regularly and parse the relevant pag...

Best practices in building and deploying Clojure applications: good tutorials?

I am new to Clojure, and am beginning to experiment with building an application. So far, everything I've seen about tutorials on compiling Clojure programs involves interactivity. For example, "load up the REPL and type (load-file "this-or-that") to run. This is fine, but it's not enough. I am so used to the edit-compile-run idiom...

How to install a leiningen plugin?

How do I install a leiningen plugin? For example, leiningen-run? I see this thing called "clojars.org", and how to "push" to it, but I don't see anything about "pulling" from it. ...