Hi,
Am Montag, 27. Juni 2011 23:50:52 UTC+2 schrieb Ken Wesson:
a) it isn't found by searching the docs in many of the usual ways;
Is that really so hard? http://clojure.github.com/clojure top-right TOC:
clojure.java.io If I look for stream handling, wouldn't that sound
interesting?
Sadly
Hi, I'm currently working on my first real Clojure project, and I find
myself wanting a mocking tool. So I was wondering what you are using?
I tried googling, but I can't seem to find the Mockito of the clojure
world. Searching for a mocking tool in Clojure it looks like there is
a lot of small
Hi,
maybe Ken's solution needs some clarification
1. Use a map, not a struct. defstruct is kinda deprecated.
2. Use a keyword (preceded by a colon) to code the nationality. A keyword
is created only once and won't consume any more memory if you use it
repeatedly. I'm not sure whether you
Justin,
Sorry about the missing link. Github upload had some issues with
Chrome and hence took a while for me to update the latest jark-0.3
binary. It is up now:
https://github.com/downloads/icylisper/jark/jark-0.3
--
isaac
http://icylisper.in
--
You received this message because you are
Hi Erik,
Take a closer look at Midje, especially
https://github.com/marick/Midje/wiki/Metaconstants
I'm not an subject matter expert but to me it's close enough to
mocking/stubbing.
Cheers,
Ola
Erik Bakstad skrev 2011-06-28 08:56:
Hi, I'm currently working on my first real Clojure
jay fields has a good blog post on this:
http://blog.jayfields.com/2010/09/clojure-mocking.html
On Tue, Jun 28, 2011 at 2:52 AM, Ola Ellnestam ola.ellnes...@agical.se wrote:
Hi Erik,
Take a closer look at Midje, especially
https://github.com/marick/Midje/wiki/Metaconstants
I'm not an
...and a classic (not clojure specific)
http://codebetter.com/gregyoung/2008/02/13/mocks-are-a-code-smell/
(Disclaimer: I don't necessarily share Greg's opinion, but interesting
nonetheless)
2011/6/28 gaz jones gareth.e.jo...@gmail.com
jay fields has a good blog post on this:
Given this test program:
(ns test-csv
(:gen-class)
(:use clojure.contrib.command-line)
(:use clojure-csv.core))
(defn process-file
Process csv file and prints first item in every row
[file-name]
(let [data (slurp file-name)
rows (parse-csv data)]
(dorun (map #(println
If you are trying to get the 6th row, you might use the nth
function. It allows you to grab an element based on its index. That'd
be better than tons of (next (next (next rows))) stuff.
user= (doc nth)
-
clojure.core/nth
([coll index] [coll index not-found])
Returns the
On Tue, Jun 28, 2011 at 2:19 AM, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
Am Montag, 27. Juni 2011 23:50:52 UTC+2 schrieb Ken Wesson:
a) it isn't found by searching the docs in many of the usual ways;
Is that really so hard? http://clojure.github.com/clojure top-right TOC:
On Tue, Jun 28, 2011 at 10:40 AM, Ken Wesson kwess...@gmail.com wrote:
How else do you propose to explain the observation that if it isn't
in clojure.core, it tends to be underused? :)
Well, that's your observation so it's rather circular logic :)
--
Sean A Corfield -- (904) 302-SEAN
An
Thanks. That works perfectly.
(ns test-csv
(:gen-class)
(:use clojure.contrib.command-line)
(:use clojure-csv.core))
(defn x1
[val1 val2]
(println val1 val2))
(defn process-file
Process csv file and prints a column in every row
[file-name]
(let [data (slurp file-name)
Given this sample:
(ns test-csv
(:gen-class)
(:use clojure.contrib.command-line)
(:use clojure-csv.core))
(defn x1
[val1 val2]
(println val1 val2))
(defn process-file
Process csv file and prints a column in every row
[file-name]
(let [data (slurp file-name)
rows
map takes a function and a collection. So, that function can be:
1. named:
- define the function on it own, using the defn macro
- pass it as first argument to map
(def coll [[1 2] [3 4] [4 5]])
(defn foo [x y]
(println x y))
(map foo coll)
2. anonymous:
- use
Thanks. I've followed most of what you've written except how the
symbol col fits into this, unless you're using it as map values.
On Jun 28, 3:11 pm, Mark Rathwell mark.rathw...@gmail.com wrote:
map takes a function and a collection. So, that function can be:
1. named:
- define the
coll is the vector defined at the top of each code listing in the examples
given, and is used as the second argument to map in all examples.
Sent from my iPhone
On Jun 28, 2011, at 3:20 PM, octopusgrabbus octopusgrab...@gmail.com wrote:
Thanks. I've followed most of what you've written
Alan Malloy a...@malloys.org writes:
Hi Alan,
ArrayMap isn't very performant for large collections. You might like
https://github.com/flatland/ordered
in my clojure app, I totally rely on ordered sets. Currently, I use
https://github.com/ninjudd/ordered-set
for which I've implemented
I'm looking to do something like this:
(defprotocol Addable
(add-fields [this]))
(defrecord MyRecord [a b]
Addable
(add-fields [this] (+ a b)))
;;; Magic happens here
(defn indirect-adder [a b]
(add-fields (MyRecord. a b)))
(with-definition-of-add-fields-changed-to (fn [_] hi
It's been a year and I'm still using dj and still developing for it.
git://github.com/bmillare/dj.git
Some recent additions:
* You can depend on clojure contrib github projects via:
:src-dependencies [clojure/core.logic]
All projects with clojure/ prefixed to the name are considered to be
a
The protocol method `add-fields` becomes an ordinary Clojure Var. You can
temporarily change its root binding using `with-redefs` in 1.3.
-S
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
On Jun 28, 2011, at 7:23 AM, László Török wrote:
...and a classic (not clojure specific)
http://codebetter.com/gregyoung/2008/02/13/mocks-are-a-code-smell/
One thing I'm trying to emphasize with Midje is that mocking in the context of
a functional language is (can be) about the logical
On Jun 28, 2011, at 4:17 PM, Stuart Sierra wrote:
The protocol method `add-fields` becomes an ordinary Clojure Var. You can
temporarily change its root binding using `with-redefs` in 1.3.
`with-redefs` has no effect on an already-compiled function that uses a
defrecord-defined function. I
I've done a bit of reading on fnparse and found it be a cleanly implemented
parser, suitable to my purposes. That said, it appears to still be dependent
upon an external lexer for its feed, similar to most parsers. Aside from those
lexers implemented directly in Java such as JLex is anyone
Hi
I have been learning clojure for some time but am a bit stumped when
translating code with nested for loops.
Can someone help me to translate the following java code to clojure
elegantly:
The inputs are two arrays of type double of the same length -
dailyValues and totalValues. The output
I'm trying to do a simple print-json, and am getting a ClassCastException in
the data.json library. I'm using [org.clojure/clojure 1.3.0-beta1] and
[org.clojure/data.json 0.1.0]. So…
* lein repl *
*…*
*user = (require 'clojure.data.json)*
*nil *
*
*
*user = (clojure.data.json/print-json
Hi,
I'd like to bundle a collection of (JSON) datafiles with a Clojure
project source tree so that Clojure functions can reliably find and
open those datafiles.
What's the idiomatic way of going about this? In the past with other
languages I've used tricks like Ruby's .dirname(__FILE__)/...
Ok, so I fixed the problem by changing A) to B)
A)
(*defn *print-json
...
(*write-json* x **out** escape-unicode)))
to
B)
(*defn *print-json
...
(*write-json* *(PrintWriter. *out*)* escape-unicode)))
The only thing now, is that the 'nil' return value suffixes itself. I can
Hey,
I don't have a good example, but the right way to do is with resources
which are basically just files that live on the classpath:
* Put the files in a folder on your classpath. If your using
leiningen, the resources/ directory does this by default.
* Get a URL to the file with
I'd like to bundle a collection of (JSON) datafiles with a Clojure
project source tree so that Clojure functions can reliably find and
open those datafiles.
What's the idiomatic way of going about this?
One idiomatic way to do this in Clojure is:
- store the files within a directory
are you trying to turn something into a json string? if so, the
json-str function is probably what you are looking for:
user (json/json-str {:a b})
{\a\:\b\}
by the way, the nil in your previous email is not being suffixed to
the string, its simply the return of the function getting written to
I'm fairly new to Programming, Clojure and Blogging, but I did manage
to write a few posts about Clojure in my spare time.
http://blackstag.com/blog.posting?id=5
I have now have a newly found appreciation for how much effort this
kind of stuff can be :)
Feedback is always welcome.
Regards,
Tim
On Jun 28, 2011, at 8:20 PM, Bhinderwala, Shoeb wrote:
The inputs are two arrays of type double of the same length – dailyValues and
totalValues. The output is the array contrib of the same length.
int n = dailyValues.length;
for (int i = 0; i n; i++)
{
Hey Gareth,
Yes, in my library, I'm returning a string. So indeed I will be using
json-str. But on the command-line, I sometimes want to print or pretty-print
something out. I forked data.json and submitted a pull request with the
'(PrintWriter. *out*)' fix put in. Hopefully it solves the
On Jun 29, 12:17 pm, Stephen C. Gilardi squee...@mac.com wrote:
I'd like to bundle a collection of (JSON) datafiles with a Clojure
project source tree so that Clojure functions can reliably find and
open those datafiles.
What's the idiomatic way of going about this?
Many thanks to
Here's one way.
(defn tails [coll]
(take-while seq (iterate rest coll)))
(defn calc [total-values daily-values]
(map * daily-values (for [tail (tails total-values)]
(reduce #(* %1 (inc (/ %2 100.0)))
1.0
Well, I wrote the clojure version after boasting to ninjudd that
deftype would let you do it without writing any java at all. I did
some simple-minded benchmarking, and while I don't recall the exact
numbers his java version is ~10-50% faster. If you look through the
git logs, somewhere I have a
Hi,
I'd like to use Java2D objects in a Clojure application. I understand
that these mutable objects will be operating in a Clojure environment
where immutability is the order of the day, and this is likely to
cause problems.
Can someone point me to some good examples of, or techniques for
On Jun 28, 2011, at 11:37 PM, David Sletten wrote:
On Jun 28, 2011, at 8:20 PM, Bhinderwala, Shoeb wrote:
The inputs are two arrays of type double of the same length – dailyValues
and totalValues. The output is the array contrib of the same length.
int n = dailyValues.length;
38 matches
Mail list logo