Hi all, I'm new to the group; I have some experience with both CL and
Java, though it's been a while for each. Anyway I really like Clojure
as a way of combining the best parts of the two languages, but I'm
still getting the hang of it and there are often things that confuse
me.
For example, I wan
Also sorry the indentation is so awful. How do I get Google to let me
compose/edit in a fixed-width font?
On Aug 9, 12:09 pm, Alan wrote:
> Hi all, I'm new to the group; I have some experience with both CL and
> Java, though it's been a while for each. Anyway I really like Cloju
=> (drop-while neg? [-3 -2 -1 0 1 2 3 ])
> (0 1 2 3)
> user=> (class (neg? -5))
> java.lang.Boolean
>
> On Aug 9, 12:09 pm, Alan wrote:
>
> > Hi all, I'm new to the group; I have some experience with both CL and
> > Java, though it's been a while for eac
I have the following function as part of a card-game system I'm
developing:
(defn make-suit
[suit owner ranks]
{suit (map (partial struct-map card
:suit suit
:owner owner
:rank)
ranks)})
(make-suit :spad
Depends on what you mean by that. If you mean, create a hashset for
use in clojure that will only accept MyType objects, I'll defer to
someone here who knows more clojure than I do, though it looks like
metadata preconditions are the way to go.
If you mean, create a hashset you can pass to Java ob
Similar experience here. For what it's worth, I found that emacs/swank
made my wildest dreams come true - if you're willing to put in the
effort to learn emacs, you'll love emacs for clojure as much as you
love eclipse for java.
On Aug 10, 11:38 am, gammelgedden wrote:
> Now we are at eclipse /
Funny you should mention this - I was about to post a question about
my own game when I saw your article. My issue is, I assume someone has
written minimax and/or alpha-beta pruning in Clojure (or a java
library that's easy to interop with). My case is slightly different in
that the turn order is n
(defn apply-keys [f ks]
(zipmap ks (map f ks)))
Trivial to write, but it can be quite useful. For example:
(defn whatever [arg]
(let [some-list (make-list-from arg)
mapped (map myfunc some-list)]
(zipmap some-list mapped)))
compared to
(defn whatever [arg]
(apply-keys myfunc (m
t works if I
launch it independently of leiningen, with the clj script provided in
clojure.contrib.
Thanks a bunch,
~Alan
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Not
Ah, that's all it was. I thought it was available after I saw someone
suggest using clojure 1.2. After changing to use RC3, swank
(especially swank.core/break) works beautifully. Thanks!
On Aug 16, 11:23 am, Saul Hazledine wrote:
> Aug 16, 8:03 pm, Alan wrote:
>
>
>
>
>
> > Note that if f is not referentially transparent, you can get different
> > results depending on the order in which the collection is traversed,
> > for unordered collections. See the API function group-by. It makes
> > this behavior explicit by mapping each i
utput arguments, in the same order as their corresponding inputs were
> > traversed.
>
> > - Will Morgan
>
> > On Aug 16, 3:31 am, Alan wrote:
>
> > > (defn apply-keys [f ks]
> > > (zipmap ks (map f ks)))
>
> > > Trivial to write, but it can be
Devious! The OP wanted to handle underflow of the subs collection
though, so you need a tweak:
(apply assoc v (interleave (positions nil? v)
(concat subs (repeat nil
On Aug 17, 1:10 pm, Justin Kramer wrote:
> With the precondition that the first collection is a vect
The indentation is enough of a hint to get it right. For example, in
myfn-a, because you've indented it correctly I can easily tell that
(dec b) is the second argument to recur, without looking at the
parentheses at all. Isolating close-parens would probably help a
little with this task, but the lo
I use Ctrl-D on linux, but Ctrl-C works too, and is what I would try
first on Windows.
(System/exit 0) won't work if you're using leiningen to get your repl,
because it passes I/O through JLine and System.exit terminates the
clojure process without notifying the JLine process:
$ lein repl
user=>
Or if you want to avoid the #(...%...) syntax:
user=> (def a (list 1 2 3))
#'user/a
user=> (def b (list '(4 5 6) '(7 8 9)))
#'user/b
user=> (map (partial map * a) b)
((4 10 18) (7 16 27))
On Aug 19, 4:56 pm, Glen Rubin wrote:
> I want to multiply a list of n items by h lists of n items, so that
or the card game
bridge.
On Aug 16, 3:08 am, Mike Anderson
wrote:
> On Aug 13, 5:33 pm, Alan wrote:
>
> > Funny you should mention this - I was about to post a question about
> > my own game when I saw your article. My issue is, I assume someone has
> > written minimax
Without commenting on the usefulness of this (it doesn't really
interest me), there are a couple style things I would change.
First, :added ought to be 1.3 (maybe 1.2?), not 1.0. Second, the
newsgroup seems to think that if you're changing clojure.core you
might as well update from (. staticMember
Really? I would be interested to hear why; is it maybe because partial
has to take any number of arguments and then (apply even? args)?
I've taken to using partial when I can, precisely because of the
difficulty of nesting anonymous functions, and while performance isn't
a big deal for me I'm curi
I have the same problem, but you can usually figure that out by
looking at the function to which the backtrace refers, as well as the
filename:
4: clojure.lang.RT.nth(RT.java:722)
5: ddsolve.core$play_deal_strategically.invoke(core.clj:177)
6: ddsolve.core$eval2129.invoke(NO_SOURCE_FILE:1)
I think this misses the point. Of course java, c, and clojure will all
have roughly the same wall-clock time for this program, since it is
dominated by the I/O. You can even see that in the output from $ time
java Iterate: less than 0.5s was spent in user space, the rest was
spent in system code -
That was my first thought too, but (hash nil) is zero. So it doesn't
seem like it "should" be caused by that problem. I'm not familiar
enough with the internals of clojure.core to follow all of the stuff
going on in (source case), but it seems to be using (hash x) rather
than (. x hashCode). And (m
I haven't quite figured out type hinting either, but here's one thing
I realized I was doing wrong that you might want to try.
(.length msg) is a reader macro that expands to (. msg length). The
docs for the . special form state that if no arguments are provided
for an instance member, it is assum
I'm afraid if I write my code while this thread is going on, I'll just
have to reformat all of it once the discussion has settled this
decades-old argument.
On Sep 1, 9:45 am, ataggart wrote:
> This is so terribly boring. Don't you guys have any code to write?
--
You received this message beca
A very handy web page to have around; thanks for mentioning it. It
looks nice too, but the accessibility is a bit poor - when I look at
it with an increased text size, the CSS quickly falls apart and
renders it confusing and/or unreadable. So if the maintainer for that
site is on this newsgroup som
You've seen a lot of recommendations for Leiningen. I suggest you try
it out: everyone seems to think it will solve your problem (Hint: it
will). But even if you have no idea what it is, the fact that everyone
is suggesting it means you should try it out before you simply repeat
the question you've
This was actually the article that finally got me to overcome the
inertia and start exploring lisp, as a long-time native Java speaker.
I gave up again in a few weeks, but the possibilities excited me, and
when I found Clojure I was delighted with the number of things that
were better than lisp, as
Are you using the release version of 1.2.0? I get the behavior you
describe when I use a snapshot of 1.2.0 from when I built from source,
but when I use lein repl in a project with a dependency on 1.2.0, all
three forms fail with the same exception.
On Sep 8, 9:44 am, Nicolas Oury wrote:
> Dear a
I happened to be looking at the source for clojure.core/juxt, and I
was a little surprised by the way it handles 4+ arguments
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts
Sorry, Google posted this before I was done. Anyway, it looks like:
(defn juxt
([f g h & fs]
(let [fs (list* f g h fs)]
...)))
Is there a reason to do that instead of the following?
(defn juxt
([& fs]
...))
On Sep 8, 11:02 am, Alan wrote:
> I happened to be loo
This. And to clarify, in case it's unclear: every function in Clojure
must return a value - there are no "void" functions as in Java. print
and println, therefore, in addition to printing their data, must
return something (they choose nil), and the REPL always prints out the
return value of whateve
I assume I'm just clueless here, but the last commit I see at
http://github.com/richhickey/clojure is one from Stuart Halloway in
June. Where do I find this so I can try it out? Or, what version do I
have to tell leiningen I depend on - 1.2.0-snapshot, 1.3.0-snapshot,
or something like that?
On Se
I'm not 100% sure what you're asking, but I think I understand you,
and in that case you can refer to
http://groups.google.com/group/clojure/browse_thread/thread/9c7f726709e24c12/b2e2696b70d924f2?show_docid=b2e2696b70d924f2,
in which I ask this very question and get the answers I am looking
for.
O
user> (bean (java.io.File. "tmp.txt"))
{:path "tmp.txt", :parent nil, :hidden false, :parentFile
nil, :canonicalFile #, :freeSpace 0, :absoluteFile #, :class java.io.File, :name "tmp.txt", :absolutePath
"/home/akm/src/clojure/ddsolve/tmp.txt", :directory
false, :usableSpace 0, :canonicalPath "/home
Did we really get this done in an hour? I haven't been part of the
community for long, but Rayne has been helpful to me already on
#clojure so I was going to donate a bit. Did I already miss my chance?
On Sep 10, 10:39 am, Chas Emerick wrote:
> With a huge helping hand from Relevance, the host of
I actually did this just the other day, to create a simple C-style
enum macro (I assume someone has a better version; this was a learning
exercise). You can see my project at www.github.com/amalloy/enum. It
sounds like your problem might be constructing the symbol to define;
the solution will look
e/= n__1041__auto__ :a))) (.meta (var
synthetic-a
On Sep 10, 1:02 pm, Alan wrote:
> I actually did this just the other day, to create a simple C-style
> enum macro (I assume someone has a better version; this was a learning
> exercise). You can see my project atwww.github.com/amalloy/e
coming in after we hit
> > > our goal, please read the above post anyway. :-)
>
> > > Thanks again to all!
>
> > > - Chas
>
> > > On Sep 10, 2010, at 2:55 PM, Alan wrote:
>
> > > > Did we really get this done in an hour? I haven't
= kw %))
#'user/make-kw-fn
user=>
(def kws [:a :b])
#'user/kws
user=>
(eval (cons 'do (map #(list 'def (symbol (str "test-" (name %))) (make-
kw-fn %)) kws)))
#'user/test-b
user=> (test-b :a)
false
user=> (test-b :b)
true
On Sep 10, 1:37 pm, icemaze
PS this is super-ugly and I'm always embarrassed when I find myself
using eval in a lisp. While this works, I'd love it if someone could
tell me how to do it with macros.
On Sep 10, 3:07 pm, Alan wrote:
> I see. It's hard to imagine how this could work, since macros don&
underbolt.play> (def a 5)
> #'thunderbolt.play/a
> thunderbolt.play> (def b 5)
> #'thunderbolt.play/b
> thunderbolt.play> (ultra-synth "hi" [:a :b])
> #'thunderbolt.play/hib
> thunderbolt.play> (hia 5)
> true
>
> --Robert McIntyre
>
> On Fri,
eturns nil."
+ item for which (pred item) returns logical false."
{:added "1.0"
:static true}
[pred coll]
On Sep 9, 11:46 pm, Jacek Laskowski wrote:
> On Fri, Sep 10, 2010 at 1:08 AM, Alan wrote:
> > I'm not 100% sure what you're asking, but I think I u
Ranjit, try the following to see it in action even at the REPL:
(def xt (make-array Float/TYPE 3 3))
(def myloop (for [x (range 3) y (range 3)] (aset xt x y 1)))
(aget xt 1 1) ;; xt hasn't been changed
myloop ;; force REPL to de-lazify
(aget xt 1 1) ;; changed now
On Sep 13, 9:28 am, Mark Nut
earing that up for me everyone. So the REPL itself acts
> like a consumer of lazy sequences? Is there some logic behind that? I
> guess I would have expected that the REPL would just return a
> reference to a lazy expression rather than evaluate it.
>
> Thanks,
>
> -
0 items in the seq
;; evaluating just myvar causes the REPL to realize the whole seq
On Sep 14, 9:33 am, Alan wrote:
> That would be very awkward:
>
> user=> (-> (range) (filter even?) (drop 10) (take 5))
> LazySeq
> user=> (-> (range) (filter even?) (drop 10) (take 5) fir
First, you could use destructuring to make your map function cleaner.
The following is exactly identical to your definition. It declares
that it will be passed one argument; because that argument is [...],
it will be a seq; it asks that the seq be split into y, the first
element, and z, a seq of th
This is working fine from Clojure. I don't see how you can get help
without providing some information about the code you have that isn't
working.
user> (definterface Printable (print []))
user.Printable
user> (definterface User (use [^user.Printable p]))
user.User
user> (def p (reify Printable (p
I think you could just keep a vector of (color,shape) pairs as an
atom, and reify a subclass of JPanel whose paint() method closes
around that atom, calling (.draw shape color). Then as long as you
call repaint every time you modify the atom, you should be done. Seems
like it's hard to see a librar
Great. Looks shiny and idiomatic to me.
On Sep 14, 12:06 pm, Michael Ossareh wrote:
> Alan and Patrick, thank you so much! I've come across apply in JS and
> it really should have clicked for me!
>
> So I have the following, and it works very well:
>
> (defn make-tables
use (list shape-name...), try [shape-name...]
-- (defn render-shape [shape-name [x y w h] color])
-- (render-shape 'rect (take 4 (repeatedly #(rand-int 400))) blue)
The last two combine to let you avoid writing rand-int so many times.
On Sep 15, 5:32 am, Lee Spector wrote:
> On Sep 14,
My guess is no. It would remove a huge benefit of Clojure, which is
that you can tell, without having to look over the whole codebase,
exactly what a given form does. (my-thing 20 [x y]) invokes my-thing,
a function or macro, with 20 as its first argument, and then a vector
of locals. No need to hu
Binding uses dynamic scope, not lexical scope, right? So any functions
called before the binding expires will be affected by the new
bindings, not just the code explicitly within its lexical scope.
On Sep 15, 11:35 am, Luke VanderHart
wrote:
> Unless I misunderstand something, (binding...) wouldn
pm, Lee Spector wrote:
> On Sep 15, 2010, at 1:57 PM, Alan wrote:
>
> > This looks a lot like what I would do - I'm afraid I don't have any
> > brilliant insights for you. I do have a couple ways you could make
> > this smaller, though:
>
> > - Instead
A few days ago I was thinking about how different it would be to write
flip-map* in Java vs Clojure. A very simple, small program, but easy
to see how Clojure can be more expressive.
public static Map flipMap(Map map)
{
Map result = new HashMap(map.size());
for (K key : map.keys()) {
ot to add to it.
On Sep 20, 9:08 am, Alan wrote:
> A few days ago I was thinking about how different it would be to write
> flip-map* in Java vs Clojure. A very simple, small program, but easy
> to see how Clojure can be more expressive.
>
> public static Map flipMap(Map map)
key) with
reverse - not sure if that's more readable, but there's certainly a
case for it.
On Sep 20, 9:52 am, John Cromartie wrote:
> On Sep 20, 12:08 pm, Alan wrote:
>
>
>
> > A few days ago I was thinking about how different it would be to write
> > flip-map* in J
(defn f
([a b c] ...)
([a b c d]
(if d
...
(f a b c
Not the prettiest solution, I'll grant you; I'm sure someone will come
along with something better. But this will work.
On Sep 27, 11:13 am, Glen Rubin wrote:
> I have a function that will accept 3 or 4 parameters.
C-c C-k in the .clj buffer is easier and equivalent (or at least very
similar)
On Sep 27, 12:27 pm, Linus Ericsson
wrote:
> I recognize that one. The repl haven't loaded the file your editing.
>
> My (temporary) solution is to do a (load-file "")
> after each edit that I want to debug, but that's
I don't have time to watch the whole thing until I get home from work,
but just hearing the first 30 seconds has me drooling all over
myself...
On Oct 1, 1:32 pm, George Jahad wrote:
> For your delectation:http://www.vimeo.com/15462015
--
You received this message because you are subscribed to
I've got a collection of unique objects, and I need to partition them
into sets. That part's easy enough, but I need to have both of the
following be efficient, and preferably easy:
- Given an object, determine what set it's in
- List all the objects in a given set
In an imperative language this w
Hm. How are you connecting to swank? I use M-x slime-connect (then hit
yes/ a few times); as soon as that's done, a new buffer with the
clojure REPL appears. Then I can switch to it just as with any buffer;
C-x C-o or similar. The buffer it creates is called *slime-repl
clojure*. That should be all
(use 'clojure.java.io)
(require 'clojure.string)
(refer 'clojure.string :only [split])
(let [pattern #"case when (\\S+) in \\(([^)]+)\\) then (\\S+) as (\\S
+)"]
(with-open [sql-in (reader "/path/to/file")]
(doseq [line (line-seq reader)]
(let [[_ in-str then-str as-str]
)
Also it occurred to me that my (split) doesn't handle the commas you
have, so the regex should probably be something more like #"[ ,]+"
On Oct 5, 2:49 pm, Avram wrote:
> Alan, thanks for your response, I'm still new at this. Running it,
> the part with refer had an iss
user=> (use 'clojure.string)
WARNING: replace already refers to: #'clojure.core/replace in
namespace: user, being replaced by: #'clojure.string/replace
WARNING: reverse already refers to: #'clojure.core/reverse in
namespace: user, being replaced by: #'clojure.string/reverse
nil
user=> (join "&" (m
I confess I'm a bit baffled by this too, but I have a couple
suggestions that don't address your problem :)
(drop 2 (range)) is the same as (iterate inc 2), and the same as your
convoluted lazy-seq, except that the iterate works here, while for
some reason the range doesn't.
You might consider ze
On Mar 14, 8:15 pm, Daniel Solano Gomez wrote:
> I believe there are two approaches to doing this in Clojure:
>
> 1. Multimethods:http://clojure.org/multimethods
> 2. Protocols:http://clojure.org/Protocols
>
> Of the two, as of Clojure 1.2, protocols are the preferred way of doing
> things.
Wha
draw) color))
>
> (defn rotare [shape degrees]
> ((shape :rotate) degrees))
>
> And is used like this:
>
> (def circle (make-circle 5 5 10))
> (draw circle)
>
> On Mar 15, 9:26 am, Alan wrote:
>
>
>
>
>
>
>
> > On Mar 14, 7:54 pm, stu wro
On Mar 14, 7:54 pm, stu wrote:
> Hi,
>
> I'd like to create a simple library of drawable shapes: lines, circles
> and rectangles. I've placed each type of shape in its own namespace
> with functions that operate on that shape kind:
>
> (ns myshapes.line)
>
> (defn line ... creates new line ...)
>
On Mar 15, 10:30 am, Daniel Solano Gomez wrote:
> In the end, the it all depends on what fits best with what you are
> doing. One approach is to simply avoid using multimethods or
> polymorphism as you start developing. Instead, you can use a custom
> dispatch using if or cond in your polymorphi
On Mar 15, 10:50 am, Mark Engelberg wrote:
> On Tue, Mar 15, 2011 at 10:40 AM, Alan wrote:
> > Seconded. I often know ahead of time I'll want to extend to
> > multimethods eventually, but sometimes I don't. Because multimethods,
> > protocols, and plain-old-functi
On Mar 14, 2:10 pm, Ken Wesson wrote:
> On Mon, Mar 14, 2011 at 4:41 PM, Alan wrote:
> > Thanks Ken, I found this too when I saw Tassilo's problem on irc
> > (didn't notice it was on ML as well). I was going submit a patch for
> > this, but if you've alr
You are asking on the wrong list. Nobody in the Clojure list will ever
tell you that monkey-patching and mutating your data structure is the
right approach in order to traverse it. And that's totally fine: ask
away, if you're willing to accept other solutions. But you've rejected
all ideas aside fr
It's one variety of depth-first. Pre-order, post-order, and in-order
are all viable ways of doing depth-first searches (though in-order
makes less sense for non-binary trees). Assume for the rest of this
post the following tree:
1
--2
--3
4
--5
6
--7
- Breadth-first traversal: 1237465
On Mar 17, 8:34 am, "Bhinderwala, Shoeb"
wrote:
...use the strint *MACRO*...
...works when I specify my string [as a literal]...
...but doesn't work when I pass the string through a variable.
Macros are not functions. << is receiving as arguments a list with the
two elements 'str and 'q. It must
On Mar 17, 11:00 am, Meikel Brandmeyer wrote:
> Hi,
>
> Am 17.03.2011 um 18:11 schrieb Alan:
>
> > From my uninformed position, strint looks like it should have been
> > written as a function, not a macro, but probably there are reasons it
> > was not.
>
> It c
http://www.try-clojure.org/
I hear it's not always working, but it seems to be up now.
On Mar 22, 4:55 pm, Kyle Cordes wrote:
> On Tuesday, March 22, 2011 at 7:16 AM, André Branco wrote:
>
> Hi!
>
> > A good collection of resources:
> >http://learn-clojure.com/
>
> Thanks for the mention (that's
$ is a special character in replacements as well, for indicating
capturing-subgroups.
user> (require '[clojure.string :as s])
nil
user> (s/replace "stuff$@stuff" #"\$@" "\\$@sub")
"stuff$@substuff"
On Mar 22, 8:05 pm, Tim Robinson wrote:
> I'm not well versed in regex functions., so I'm probably
If you don't plan to use the &rest arguments, and in fact don't care
about them at all, why are you binding them to something?
More importantly, it would make the following idiom a lot more clumsy:
(defn sum [list]
(let [[x & xs] list]
(+ x (if xs
(sum xs)
0
Using
This is only half-true. The data exists somewhere, as Jules says, so
that javac can enforce proper use of generics when calling compiled
library code. Eg, rt.jar contains only classes, yet j.u.List still
manages to have generics, which are treated correctly by the compiler.
The *use* of generic cod
On Mar 24, 9:47 am, Alessio Stalla wrote:
> Reflection is aware of generic type
> variables:http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Generi...
>
> What is lost at runtime is information about *instantiation* of those
> variables: e.g. you can't distinguish a method returning
A macro should work fine if you use ~@ instead of just ~.
(defmacro save-article
[path form-params timestamp]
`(ds/save! (Article. ~path ~@(vals form-params) ~timestamp)))
On Mar 24, 1:28 pm, Thorsten Wilms wrote:
> On 03/24/2011 05:40 PM, Meikel Brandmeyer wrote:
>
> > The problem is the
I find it easier to write web apps if my users provide me with their
inputs at compile time anyway.
On Mar 24, 1:45 pm, Meikel Brandmeyer wrote:
> Hi,
>
> Am 24.03.2011 um 21:38 schrieb Alan:
>
> > A macro should work fine if you use ~@ instead of just ~.
>
> > (defmac
It's already possible, but metadata is the wrong tool. Wrap all return
values that "might" have multiple values in a vector, and return/bind
as many elements as you want. Add macros to make it less ugly, stir
awhile, and you have multiple values.
Using metadata for this purpose would have real pro
That error message is coming from some use of (case), usually in your
code but conceivably from somewhere in Clojure. It tries to do some
clever bit-fiddling to generate a constant-time-dispatch on the
hashcodes of its clauses, and if that fails it throws a compiler error
(arguably it could degrade
(1) lazy-cat is old. There's no reason to use it anymore; lazy-seq is
better for generating custom lazy seqs, and concat is already lazy.
(2) declare is overkill for this; just use letfn and avoid creating a
bunch of global functions that nobody else will ever use.
On Mar 27, 9:43 am, Christian Sc
(into-array String [])
(make-array String 0)
On Mar 28, 12:58 pm, Konrad Hinsen wrote:
> For interfacing with some Java code I need to create an empty string
> array in Clojure. Is that possible somehow? The only way I know to
> create a string array is
>
> (into-array ["a" "b"])
>
>
If you need it quoted in the "def" context:
(defmacro def-entity-and-attrs [entity-name key attrs-name attrs]
`(do (def ~attrs-name '~attrs)
(ds/defentity ~entity-name ~(vec (concat ['^:key key]
attrs)
Note the ' before attrs.
PS why is there a ' before ^:key? It doesn't seem to m
My understanding is that it's mostly a hosting problem. I'll ask
Raynes about it - the code is mostly his, as I understand it.
On Mar 29, 5:08 pm, Sean Corfield wrote:
> On Tue, Mar 29, 2011 at 5:00 PM, Ken Wesson wrote:
> >> Pointing out try-clojure.org would probably be a good thing there
> >>
(update-in foo [:a] inc). It also works for nested maps, the same way
assoc-in and get-in do.
On Mar 30, 10:21 am, Jeff Rose wrote:
> Hola,
> I'm looking for a function that updates a map value by calling a
> function on it.
>
> (def foo {:a 1})
>
> So instead of this:
> (assoc foo :a (inc (:
(keyword "abcdef") => :abcdef
(defn metric-diff [metric & json-objs]
(apply - (map (comp :value (keyword metric)) json-objs)))
Probably does what you want.
On Mar 30, 12:04 pm, Avram wrote:
> hi,
>
> I have 2 report files in JSON format like below:
>
> # file 1: a.json
> { "abcdef" : { "value
On Mar 30, 11:29 pm, Jozef Wagner wrote:
> On Wednesday, March 30, 2011 7:29:42 PM UTC+2, Mike Meyer wrote:
>
> > On Wed, 30 Mar 2011 10:21:41 -0700 (PDT)
> > Jeff Rose wrote:
>
> > > Hola,
> > > I'm looking for a function that updates a map value by calling a
> > > function on it.
>
> > > (def
You don't actually need to quote class names: (import com.test.Test)
works. Of course if you're using the list syntax you do, to avoid
calling the package as a function; but you can get around that as well
by using a vector if you'd rather not quote: (import [com.test Test
OtherTest])
On Mar 31, 5
Works fine for me in slime, came repl, and java -jar clojure.jar. The
indentation isn't so hot for the raw repl, but what can you expect?
The repl is fine; perhaps you should tell us how you're launching your
repl, since that seems to be the source of the problem.
;; TABs added by me - the repl pu
(let [c String]
(.newInstance c))
If you need to pass arguments to the constructor there's more work to
do - check out clojure.lang.Reflector.
On Apr 2, 5:53 pm, JonathanBelolo wrote:
> Ok, so here's the thing:
>
> I'd like to keep a reference to a class somewhere, and later retrieve
> it to i
Isn't all this just a special case of partition-by?
(defn drop-by [f coll]
(apply concat (rest (partition-by f coll
(defn take-by [f coll]
(first (partition-by f coll)))
user> (drop-by (partial + 2) [2 2 2 3 3 4])
(3 3 4)
user> (take-by #(mod % 3) [1 4 1 7 34 16 10 2 99 103 42])
(1 4 1 7
I like your version, Roman. It seems as efficient as anything, and is
easy to read. For what it's worth, I'd make a small rewrite:
(defn take-by [f coll]
(lazy-seq
(when-let [[x & xs] (seq coll)]
(let [val (f x)]
(cons x (take-while (comp #{val} f) xs))
On Apr 3, 5:45 am, Rom
I'd write it as (repeatedly num-raindrops #(agent nil)).
On Apr 3, 5:27 pm, Sean Corfield wrote:
> On Sun, Apr 3, 2011 at 4:31 PM, carinmeier wrote:
> > (let [rainagents (vec (repeat num-raindrops (agent nil)))]
>
> Wouldn't that create a vector with N copies of the same agent?
>
> Try:
>
> (le
Yes. Generally push lazy-seq as high in the chain as you can (but no
higher!), for that reason..
On Apr 3, 11:09 pm, Roman Sykora <4rt.f...@gmail.com> wrote:
> Thank you for your time and kind answers. I really enjoy reading this
> group and the whole clojure community. Enough flattery ;)
>
> A qu
You can't turn clojure.core/first into a protocol - it's already a
bare function. When you define a protocol with a first method, you
define a new function in your namespace called first, which delegates
to protocol implementations. The compiler is complaining that you're
shadowing clojure.core/fir
You probably weren't putting it into a java float array, but instead a
Float array (boxed type). Here's a repl session doing what you want. I
don't know anything about colorspaces so it's probably nonsense, but
it creates a Color with that constructor.
user=> (import '(java.awt.color ICC_Profile C
1 - 100 of 1147 matches
Mail list logo