I am trying to scrape some data from a page with a table based layout. So, to get some of the data I need to get something like 3rd table inside 2nd table inside 5th table inside 1st table inside body. I am trying to use enlive, but cannot figure out how to use nth-of-type and other selector steps. To make matters worse, the page in ques...
I'm using Clojure, so this is in the context of Java regexes.
Here is an example string:
{:a "ab,cd, efg", :b "ab,def, egf,", :c "Conjecture"}
The important bits are the commas after each string. I'd like to be able to replace them with newline characters with Java's replaceAll method. A regex that will match any comma that is not su...
There has got to be a better way.
I am a Clojure newbie. I am trying to get two copies of a vector of card suits. The non-DRY way that I can come up with is
(def suits [:clubs :diamonds :hearts :spades])
(def two-times (concat suits suits))
There must be a more functional way (even if it takes more characters :-)). What if i want N t...
Does the Clojure language have a standard put out by an organization?
...
I am trying to write a Spider Solitaire player as an exercise in learning Clojure. I am trying to figure out how to deal the cards.
I have created (with the help of stackoverflow), a shuffled sequence of 104 cards from two standard decks. Each card is represented as a
(defstruct card :rank :suit :face-up)
The tableau for Spider will ...
I am writing a web application using ring and clojure. I am using the jetty adapter for the development server and emacs/SLIME for IDE. While wrap-reload does help, run-jetty blocks my slime session and I would like to be able to start/stop it at will without having to run it in a separate terminal session. Ideally, I would like to defin...
Would it be possible to override the 'require' command so that it will try to download a certain resource if it was not found on the local machine. For example:
(require 'examples.introduction)
; if not found => download from the net
; (url: http://media.pragprog.com/titles/shcloj/code/examples/introduction.clj)
...
I need some help understanding some of the points from Paul Graham's article http://www.paulgraham.com/diff.html
A new concept of variables. In Lisp, all variables are effectively pointers. Values are what have types, not variables, and assigning or binding variables means copying pointers, not what they point to.
A symbol type. Symbol...
Calling concat on vectors returns a list. Being a total noob I would expect that the result would also be a vector. Why the conversion to list?
Example:
user=> (concat [1 2] [3 4] [5 6])
(1 2 3 4 5 6)
; Why not: [1 2 3 4 5 6] ?
...
In Scala 2.8.x, a new annotation (@tailrec) has been added that gives a compile-time error if the compiler cannot perform a tail-call optimization on the annotated method.
Is there some similar facility in Clojure with respect to loop/recur?
EDIT:
After reading the first answer to my question (thanks, Bozhidar Batsov) and further searc...
I am currently trying to pick between different NoSQL databases for my project. The project is being written in clojure and javascript. I am currently looking at three candidates for storage. What are the relative strengths and weaknesses of MongoDB, FleetDB and CouchDB? Which one is better supported in Clojure? Which one is better suppo...
In a Clojure program, I have a sequence of numbers:
(2 3 4 6 8 1)
I want to find the longest sub-sequence where the items are sequential:
(2 3 4)
I am assuming that it will involve (take-while ...) or (reduce ...).
Any ideas?
Clarification: I need the longest initial list of sequential items. Much easier, I'm sure. Thanks for the...
For this example Java class:
package foo;
public class TestInterop
{ public String test(int i)
{ return "Test(int)"; }
public String test(Object i)
{ return "Test(Object)"; }
}
When I start Clojure and try to call the test(int) method, the test(Object) method is called instead, because Clojure automatically boxes the in...
Be gentle, as my macrofoo is weak.
What I'd like to do is something like this:
(defmacro foo [x] `(dosync (alter x# conj x)))
(defmacro bar [] `(let [x# (ref [])] (foo 3)))
Is this possible? I can't just (let [x ..] ..) because of symbol capturing.
NOTE: I'm aware this example is trivial and not macro-worthy, but it's the simplest e...
Hi,
there seems to be a limit to the number of parameters a clojure function can take.
When defining a function with more than 20 parameters I receive the following:
#<CompilerException java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Can't specify more than 20 params (NO_SOURCE_FILE:0) (NO_SOURCE_FILE:0)>
...
In MVC web development frameworks such as Ruby on Rails, Django, and CakePHP, HTTP requests are routed to controllers, which fetch objects which are usually persisted to a backend database store. These objects represent things like users, blog posts, etc., and often contain logic within their methods for permissions, fetching and/or muta...
Hello,
I'm stuck with "Programming Clojure" on page 37 on a Windows 7
machine. After downloading the "examples" dir into "C:/clojure", I
typed:
user> (require 'examples.introduction)
and I got
; Evaluation aborted.
java.io.FileNotFoundException: Could not locate examples/
introduction__init.class or examples/introduction.clj on clas...
I would like to know how to list a functions in a Clojure namespace. I've done some research but I'm not there yet. I already found out how to list the methods of a Java class using the show method:
(show java.awt.Graphics)
To list the functions of a Clojure namespace I've tried the show method like this:
(show 'clojure.contrib.repl-...
Hi
I've been playing around with clojure and have been using it to build a simple little audio player. The strange thing is that sometimes, maybe one out of twenty, when contacting the server I will get the following error:
2010-04-20 15:33:20.963::WARN: Error for /control
java.lang.StackOverflowError
at clojure.lang.RT.seq(RT.jav...
A while ago this code seemed to work, but now it doesn't anymore. Is there something wrong with it?
user=> (defn sum [a b] (a + b))
#'user/sum
user=> (sum 3 4)
java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)
user=>
It's probably time to take a break :)
...