While writing JSON is fast, reading it back into a Clojure map is
slow; even with clj-json, based on Jackson.
Here's an idea: use Jackson's ObjectMapper. The following line
extracts a Java Map:
Map userData = mapper.readValue(new File("user.json"),
Map.class)
(from http://wiki.fasterxml.com/Jac
Hi,
On Jun 23, 11:23 pm, James Reeves wrote:
> 1. Have you written, or are you writing, a web application that uses
> Clojure? What does it do?
I'm guerilla coding a small web app to do some very non-standard
statistical analysis of customer returns (ABS/ESC systems for cars).
The whole thing i
On Wed, Jun 23, 2010 at 8:36 AM, Manuel wrote:
> I created a new project using leinigen; told it to download and
> install clojure-contrib (along with some other things), which it does,
> and everything works fine except that I can't use
> clojure.contrib.math.
>
> If I try (:use clojure.contrib.m
Interesting. Here are the times I get:
LINUX:
slurp, *in* 18.8 seconds
slurp, System/in 18.2 seconds
slurp2, *in* 6.7 seconds
slurp2, System/in 5.7 seconds
I have an intel iMac here too, running 10.6.4:
slurp, *in* 20.4 seconds
slurp, System.in 19.0 seconds
slurp2, *in* 7.2 seconds
slurp2, System
Adrian/Alex -
Thank you for both of your responses.
As I'm new to clojure (and lisp in general), it'll take me a bit to
puzzle through your code and links. However, I'll use it as an example
to study the language. Thanks again!
-Todd
--
You received this message because you are subscribed to
You might also want to check out Redis, which is supposed to act like
disk persistent data structures in memory. The author just added a
virtual memory module, so now Redis can handle datasets larger than
the memory you assign it.
Mark
On Jun 22, 10:57 am, Timothy Baldridge wrote:
> Greetings,
I'm wondering if we're going about this slightly the wrong way. Let's
take a look at CouchDB. CouchDB prefers to keep all data on the disk
at all times. As docs (or items) are added to a database they extend
that database, but never overwrite it. In addition all changes are
written instantly to dis
Hello there,
I'm new to Clojure and encountered a problem which I couldn't solve on
my own.
I created a new project using leinigen; told it to download and
install clojure-contrib (along with some other things), which it does,
and everything works fine except that I can't use
clojure.contrib.math
clojure.xml/parse is not documented to handle filenames-as-strings at all. It
treats strings as URIs, deferring to the host (JVM) notion of URI as
implemented in the underlying API.
I can certainly see why this would be confusing! Is there a way to make it
better without violating the expectati
On my laptop (Mac) the biggest difference here has nothing to do with buffering
in slurp. It is whether you use System/in (fast) or *in* (slow). The latter is
a LineNumberingPushbackReader.
Can you check and confirm? When I slurp System/in it is more than twice as fast
as slurping *in*.
I beli
It looks like it's having trouble figuring out if "test#1.log" is a
file path or a URI.
Not sure what a real solution is but this seems to work as a
workaround:
(clojure.xml/parse (java.io.File. "test#1.log"))
On Jun 23, 12:30 pm, Zak Wilson wrote:
> (clojure.xml/parse "test1.log")
> works cor
Another example. I'm running this on a Ubuntu 10.04 laptop with this
java:
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
and this command line:
java -Xmx3G -server clojure.main cat2.clj
(require '[clo
Sure. Here's my clj script:
#!/bin/sh
if [ -z "$1" ]; then
exec java -server jline.ConsoleRunner clojure.main
else
SCRIPT=$(dirname $1)
export CLASSPATH=$SCRIPT/*:$SCRIPT:$CLASSPATH
exec java -Xmx3G -server clojure.main "$1" "$@"
fi
(Usually I don't have the -Xmx flag there. I add
I am seeing more like 1.8 seconds for the raw version, vs. 2.8 seconds for
slurp (master branch). Can you post a complete example (including the clj
script you use, and what version of Clojure), so we can be apples-to-apples?
Stu
> For the record, this program runs in 3.3 seconds so I guess tha
On Wed, 23 Jun 2010 17:23:16 -0400, James Reeves
wrote:
1. Have you written, or are you writing, a web application that uses
Clojure? What does it do?
I'm writing cloudhoist.com, a cross cloud management console and api, that
lets you start and stop nodes on Amazon, Rackspace, etc, config
On Jun 23, 2:23 pm, James Reeves wrote:
> 1. Have you written, or are you writing, a web application that uses
> Clojure? What does it do?
My blog and a couple of other blog-like hobby sites. I also wrote a
small standalone data-collection app at work. It collects survey data
for psych research
James,
First, thank you for all of your work in this area. It is greatly
appreciated. My answers follow:
1. DocuHarvest ( https://docuharvest.com ), which I've already talked
about here. Broadly speaking, it extracts data from documents, and
it's just getting started.
2. Relevant to
On Jun 24, 1:55 am, Joost wrote:
> compojure in whatever was the last release version - with a few lines
> of patches.
This may be interesting to anyone in the US or Japan:
All the patches I made were to fix UTF-8 handling. I live in Europe.
We use characters like Ø and ß and you'd better get us
On Jun 23, 11:23 pm, James Reeves wrote:
> Hello there!
Hi James!
:)
> 1. Have you written, or are you writing, a web application that uses
> Clojure? What does it do?
I've written one very simple "internal organsiation" site in clojure
that's finished except for a few little bugs. Should be
Thank you for your ideas, feedback and criticisms.
rb and Jeff
Future versions of Carte will not force you to list the column names
but will retrieve them from the database.
Jeff
The model macro produces a map which may then be merged with other
model maps so you could define the model in vario
For the record, this program runs in 3.3 seconds so I guess that
points to the implementation of slurp:
(import '[java.io BufferedReader InputStreamReader])
(let [reader (BufferedReader. (InputStreamReader. System/in))
file-data (StringBuffer.)
buffer (char-array 4096)]
(loop [total
On Wed, Jun 23, 2010 at 2:23 PM, James Reeves
wrote:
> 1. Have you written, or are you writing, a web application that uses
> Clojure? What does it do?
I don't know that I'll be writing entire web applications in Clojure
any time soon but I expect to be using Clojure in some form from
(essentiall
Not sure if this is a clojure issue or a something else but I'm seeing
surprisingly slow I/O on large text files.
For example, on a unix machine try this:
1. create a large file
rm -f words; for x in $(seq 300); do cat /usr/share/dict/words >>
words; done
2. create a clj file that just slurps it
Hello there!
Chas Emerick's recent "State of Clojure" survey [http://bit.ly/dtdAwb]
indicated that a significant proportion of Clojure users are beginning
to use Clojure for web development. A recent Hacker News posting
[http://bit.ly/91Bu5J] seems to corroborate these results, with
several Clojur
On Jun 22, 7:57 pm, Timothy Baldridge wrote:
> system it uses. Has anyone tried marrying the two system systems to
> create a truly persistent data primitive where any "updates" to a map
> is written to the disk?
There has been an attempt at integrating STM transactions with DB
transactions, even
When the docs say not to use side-effects in a function or block of code,
they're not saying you can't use side-effects at all; it's just a reminder
that using side-effects can cause nasty surprises for one or more of these
reasons:
1. The code may be evaluated later than you expect.
2. It might no
(clojure.xml/parse "test1.log")
works correctly, output omitted
(clojure.xml/parse "test#1.log")
Premature end of file.
[Thrown class org.xml.sax.SAXParseException]
$ mv test\#1.log test2.log
(clojure.xml/parse "test2.log")
works correctly, output omitted
test#1.log is a copy of test1.l
Hello Ryan,
On Jun 21, 7:34 am, Ryan Senior wrote:
> 1 - I think a good improvement would be updating the docs for the future
> related functions to indicate what kind of objects are passed in and
> returned. Users would then not have to go through the source to see what's
> being returned. Thi
Sorry I didn't provide enough detail on that last post. Please send
your interest to jobs on sonian.net with "clojure" in the subject.
On Wed, Jun 23, 2010 at 8:24 AM, Tim Dysinger wrote:
> Hello,
>
> It's that time again. I need to hire some more full-time
> work-from-home pair-programming ema
On Sat, Jun 19, 2010 at 5:41 AM, Heinz N. Gies wrote:
> Lets get away from the argument already cast and bring a new one. It is an
> impossible situation that the literal 1 in one place has a different meaning
> and behavior then in another place. This is in fact a show stopper, I'm
> serious, th
I'm afraid I have nothing to contribute to the on-going discussions of
what the default numerical behavior should be and what the prime
version operations should do. I did, however, notice that the prime
ops tend to be clustered together in the examples given and seem
likely to be clustered in real
On Jun 18, 9:52 am, rob levy wrote:
> As an informal survey of people who use both Clojure and Common Lisp for
> different projects, what do you see as the main determining factors behind
> your choice to use either Clojure or Common Lisp for a project, given the
> present state of Clojure. Let
My first thought for an agent error handler was to send the exception to
another agent.
user=> (let [handler (agent nil)
a (agent 42
:error-handler
(fn [_ ex] (send handler
(fn [_] (println ex)]
Hello,
It's that time again. I need to hire some more full-time
work-from-home pair-programming emacs/unix/math-loving clojure devs.
Join our team of 7 devs who write clojure full time. We will be
bringing on a dev a month over the summer. The ideal candidate has
some unix, jvm & coljure/lisp/f
I've been seeing this as well.
On Wed, Jun 23, 2010 at 11:17 AM, Michał Marczyk
wrote:
> Hi,
>
> just noticed that
>
> (defprotocol Foo (foo [self]))
> (defrecord Bar [x] Foo (foo [self] x))
>
> gives a reflection warning -- "call to contains can't be resolved".
>
> My initial guess is that this
Hi,
just noticed that
(defprotocol Foo (foo [self]))
(defrecord Bar [x] Foo (foo [self] x))
gives a reflection warning -- "call to contains can't be resolved".
My initial guess is that this is due to a missing hint on line 215 in
core_deftype.clj.
Sincerely,
Michał
--
You received this messa
On Jun 22, 12:57 pm, Timothy Baldridge wrote:
> Greetings,
>
> I've recently started learning Clojure. For the past year or so I've
> been using CouchDB, and am very happy with the MVCC disk storage
> system it uses. Has anyone tried marrying the two system systems to
> create a truly persistent
I'd like to resurrect this thread, because I have the exact same
requirement Laurent had and I'm hoping there's been some additional
progress in this area.
I'm set to give a Clojure presentation to our company's Java
developers, and I'm looking for a way to excite the audience about FP
concepts in
On Wed, Jun 23, 2010 at 7:17 AM, Stuart Halloway
wrote:
> I am trying to track down and solve the issues Phil Hazelden
> reported on Hacker News [1]. I suspect that the XML issue was
> this one:
>
> It appears that the code has moved on since this report-- the
> emit-element fn mentions a :pad opt
Hmm yesterday Rick said that the new changes give clojure a chance to put down
the 'scala is faster then clojure' argument. So I figured I give it a try and
implemented some of the shootouts: fannkucken-redux and the regexdna example. I
found some interesting things especially once I got carried
I think the behavior you are seeing here is reasonable. When you mix
compilation and dynamic access to vars, you need to reason carefully about the
order in which things will happen.
More usefully: you can write a test in your var-get expression that will make
it do what you want in all scenari
I am trying to track down and solve the issues Phil Hazelden reported on Hacker
News [1]. I suspect that the XML issue was this one:
It appears that the code has moved on since this report-- the emit-element fn
mentions a :pad option but I don't see it being used anywhere. Is there an
issue her
Hi Michele,
Pass a sequence of maps, not just a map:
(every? #(:x %) [{:x "s"}])
-> true
Cheers,
Stu
> In the book "Programming Clojure" (p2_0, pdf, page 185) "Adding
> Validation to Refs" there is this code:
>
> (def validate-message-list (partial every? #(and (:sender %) (:text
> %
>
>
In the book "Programming Clojure" (p2_0, pdf, page 185) "Adding
Validation to Refs" there is this code:
(def validate-message-list (partial every? #(and (:sender %) (:text
%
This works fine as a validator, but when I try the code directly - not
as a validator - it returns false. I also tested
Thanks again. I have to be away from home and my iMac for the next ten
days so it will be some time before I can work through your suggestions,
but I will certainly give them a try. I'll let you know what kind of
success I have. I very much appreciate your help.
--Larry Travis
Joost wrote:
Thanks for the clarification Stuart! I think I see how to think about
protocols ... and not as an interface, in the java sense. I think it
makes sense to me now.
Love your book, btw!
-Travis
On Jun 21, 12:31 pm, Stuart Halloway
wrote:
> Hi Travis,
>
> The choice of "extend" follows from this r
Perfect! And Thanks!
Tim
On Jun 22, 7:00 pm, Michał Marczyk wrote:
> Firstly, consider using Delays rather than IFn. See (doc delay) and
> (doc delay?). In Clojure, many sorts of things are IFns, including
> (among others) sets, vectors and maps, and you probably don't want to
> call those.
>
> (d
How about this (using only map, reduce) -
user=> (def data1 [[:a1 :b1 :c1]
[:a1 :b1 :c2]
[:a1 :b2 :c3]
[:a1 :b2 :c4]
[:a2 :b3 :c5]
[:a2 :b3 :c6]
[:a2 :b4 :c7]
[:a2 :b4 :c8]])
user=> (pprint
(reduce
(fn f [tree r
Other math functions as max, min and so on should behave the same as +, - I
think it is kind of confusing if you've a loop with a max and have to cast it
to long by hand :)
Regards, heinz.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to
Not really tried that, but something that goes somewhat in the direction,
stupiddb - (see on github or explanations on my blog http://blog.licenser.net
). It is not guaranteed persistent sadly since it's not easy to couple IO and
Memory transactions and it might be a bit too heavy for a stupid d
50 matches
Mail list logo