You can use the erlang-otp Java library from Clojure.
I think there are bindings on github. If not, they are simple to
generate.
(I actually had clojure hooked up to a yaws webserver (yaws pattern
matches requests, clojure generates pages) for a while, using LFE and
the OTP libraries. Clojure wri
On May 4, 8:50 am, Simon Katz wrote:
> > For example Common Lisp does support this.
>
> That's not true, or at least it's only partly true.
>
> Here's a translation of your example into Common Lisp (I added a use
> of a# in the macro to avoid compiler optimization making the problem
> go away):
>
On May 3, 5:22 pm, André Thieme wrote:
> Am 02.05.2011 23:14, schrieb David Nolen:
>
> > The relevant clojure-dev thread.
> >http://groups.google.com/group/clojure-dev/browse_thread/thread/f4907...
>
> > It's not clear whether the core team and the various contributors are
> > interested in suppor
You might want to read through the source of scriptjure:
https://github.com/arohner/scriptjure
For one way to do this sort of thing. Pretty much, you would make a
basic recursive descent parser that operates on a tree of clojure
primitives. You could then wrap this in a macro, and go from there.
I'm wondering if it wouldn't be better to simply implement it using a
mutable 2d Java array? (the standard imperative implementation).
It wouldn't be a 'purely functional' answer, but the array wouldn't
leak out of the levenshtein-distance function.
On Mar 22, 3:09 am, Christian Schuhegger
wrot
Ah, interesting.
You'll notice that the gensym is created outside the defn and
captured, so I'm not sure speed is important.
On Mar 21, 11:26 am, Mikhail Kryshen wrote:
> On Mon, 21 Mar 2011 07:52:45 -0700 (PDT)
>
> Jonathan Smith wrote:
> > Here is a way that should
Here is a way that should work.
(let [missing (gensym)]
(defn get-with-exception [map key]
(let [res (get map key missing)]
(if (= res missing)
(throw (new Exception "my-exception"))
res
Gensyms are unique so you also don't have the problem of 'what happens
if I
Actually I've got to disagree here, it is really easy to do.
Here is one example of something esessoms did:
http://github.com/esessoms/clj-interface
And here is an example of the rewrite I did when I decided that his
version didn't quite do what I wanted.
http://gist.github.com/369114
On Apr 15
A function would be named based on what it is that it does.
Difficulty naming functions would imply to me that the functions
involved do not contain a clear functionality.
The names of the functions should sort of be an 'emergent property' of
a larger process of reasoning through the programming
Lisp Flavored Erlang is an extremely interesting lisp. in my opinion.
You get Erlang, and you also get s-expressions and macros.
Common Lisp and Scheme are the obvious choices, I suppose.
Learning common lisp I would probably go towards clozure common lisp,
or clisp.
(SBCL is fine (great, even)
On Nov 25, 2:09 pm, Martin DeMello wrote:
> On Thu, Nov 26, 2009 at 12:31 AM, Jonathan Smith
>
> wrote:
>
> > I think a better way to do this is to not use a regex at all.
> > Canonically I think this sort of thing is (would be?) implemented by
> > constructing a
--
> is still slow, but dropping down to
>
> (def wlistdata (to-array (take 26 (words-with "..."
>
> (def update-wlist #(let [w (take 26 (words-with (current-word)))]
>(. words setListData wlistdata)))
>
> leaves everything running smoothly. Is there a more e
On Nov 14, 1:50 pm, John Harrop wrote:
> On Sat, Nov 14, 2009 at 8:55 AM, Albert Cardona wrote:
> > On Fri, Nov 13, 2009 at 11:26 PM, Mike Hogye
> > wrote:
> > > Why is there an easy way to def a private function (defn-), but no
> > > similarly easy way to def an arbitrary var as private?
>
> >
Maybe I'm confused, but can't you just do a regular java thread for
this?
(defn periodicly [fun time]
"starts a thread that calls function every time ms"
(let [thread (new Thread (fn [] (loop [] (fun) (Thread/sleep time)
(recur]
(.start thread)
thread))
(periodicly #(println "foo
When figuring these things out it can sometimes help to look at the
implementations of stuff like defn (in clojure.core).
I'll leave it as an exercise to you, but you should note that you may
want to name-space qualify the database (depending on what you are
doing with it and where the database s
its fine in firefox 3.0.14 on Ubuntu here.
On Oct 11, 5:29 pm, Raoul Duke wrote:
> it seems to get chopped off part way down the page for me, of late.
> (it doesn't get chopped off in ie for me.)
--~--~-~--~~~---~--~~
You received this message because you are subs
I use a let at the top of the file to denote things that I want to
have as captured and constant.
... you can do things like
(let [x 1]
(defn foo-that-uses-x [y]
(function-here x y)))
On Oct 2, 10:29 am, Mark wrote:
> Is there a way to make a declaration in Clojure that cannot be rebound
>
On Sep 30, 1:18 pm, Matt Brown wrote:
> Hi.
>
> Thanks all, for your comments.
>
> > You need to use a bigger number than 1000 for these results to be
> > meaningful.
>
> Out of curiousity, why is this?
> Does the JIT do something different after 1000 iterations?
> Or is the concern simply tha
You need to use a bigger number than 1000 for these results to be
meaningful.
FWIW, I've run both on my Toshiba dual core laptop with ubuntu, and
they return approximately the same values.
(and there is some JIT trickery going on, as I got:
user=> (myavgtime (+ 1 2 3) 1000 mytime1)
(myavgtime (+
ricky subject, and probably not worth
worrying about for the minimal speed difference that it makes.
Interesting though,
-Jon.
On Sep 28, 2:45 am, Jonathan Smith wrote:
> On Sep 27, 9:17 am, Timothy Pratley wrote:
>
>
>
> > As far as I can tell there is currently no way to hint 2
On Sep 27, 9:17 am, Timothy Pratley wrote:
> As far as I can tell there is currently no way to hint 2d array access
> fast
> (def a (make-array Double/TYPE 100 100))
> (time (doseq [i (range 100), j (range 100)] (aget a (int i) (int j
> "Elapsed time: 836.800335 msecs"
> I can't find any comb
It would be kind of nice to have some sort of uniform identifier for
laziness similar to ! for destructive and ? for predicate.
On Sep 18, 5:10 pm, Raoul Duke wrote:
> > Runs (in a nice constant memory) even though yours (which almost
> > appears equivalent) will not!
>
> i am thinking ever more
http://www.haskell.org/haskellwiki/Performance
These are the performance tips I was referring to.
(4. General techniques, laziness, space leaks.)
On Sep 18, 5:03 pm, Jonathan Smith wrote:
> Hi!
>
> This is happening because you have integers saved to a global
> variable.
>
&
Hi!
This is happening because you have integers saved to a global
variable.
(iterate inc 1) creates an infinite lazy seq.
Def-fing it to a global says 'Hey, i might want this later!' to
Clojure.
This means that as you take numbers from integers;
they get saved in memory rather than being garba
I find loop recur kind of hard to follow sometimes
I was browsing through this pdf the other day:
http://www.cs.umbc.edu/331/resources/papers/Evolution-of-Lisp.pdf
And I found the tail recursive definition of common lisp/scheme style
do.
Thoroughly intrigued, I implemented it:
(defmacro cl-
Woah formatting! :-)
This is just a formatting cleanup...
Mostly I pressed ctrl+alt+q in emacs.
I also removed some commas and made things more uniform in a couple
places
---
(defn create-graph [nodes distances]
{:nodes nodes :distances distances})
(defn processed [k i j D P]
(le
Are we sure that it is the aset-* operation that is causing a slowdown
and not the fact that the aset-* operations are not being inlined,
whereas the regular aset operation is?
If so, the aset-* ops might be faster, and just in need of a small
update!
A lot of the time when something is slower t
Just out of curiosity, is there any technical reason that you decided
to use signals instead of passing closures?
(Modularity; Efficiency; more idiomatic to Java?)
On Sep 6, 5:29 am, rb wrote:
> On Sep 4, 8:30 pm, Jonathan Smith wrote:
>
> > Hi Ralph,
>
> > First off, ni
Hi Ralph,
First off, nice post! We need more of these types of tutorials on GUI
in clojure, they're very useful.
On make-login-widget you can probably do a doto when you do this part:
> (.addWidget layout (WLabel. "Login:") 0 0 )
> (.addWidget layout login-field 0 1 )
> (.addWidget layout (WLab
Ooh, or maybe not. I just reread and line-seq and read-lines should
implement pretty much the same thing. (In the demo code it isn't clear
to me where you are using line-seq.)
Are you holding on to the head of the sequence somewhere?
On Aug 31, 12:52 pm, Jonathan Smith
wrote:
>
Look at clojure-contrib/duck_streams.clj
(specifically the read-lines function)
I think it should be sufficiently lazy to do the job that you are
looking for. (although I don't have any 100mb txt files to test with
handy right now...)
On Aug 31, 10:44 am, wangzx wrote:
> I just want to learn c
On Aug 29, 3:48 pm, ronen wrote:
> In a lot of cases its seems that macros are used even when a function
> can do the same task,
> Macros seems to be less readable than their functional counterparts &
> more complex to write (to me at least).
>
> Its clear that there are special cases in which
its not impossible, it just isn't terribly useful.
On Aug 26, 6:04 pm, Laurent PETIT wrote:
> "they didn't know it was impossible so they did it" :)
>
> 2009/8/26 Stuart Sierra
>
>
>
> > On Aug 24, 11:23 pm, wangzx wrote:
> > > I think clojure may mix both the parenthese and python-like indent
I would have worried that if dim and max were close you'd get to the
last number and keep calling #(rand-int) and never hit the last
number.
how does distinct work that it keeps that situation from occuring?
On Aug 25, 12:26 pm, Christophe Grand wrote:
> no, distinct uses a hash-set (nearly-con
umber-list [max dim]
(take dim (shuffle-java (range 0 max
user> (random-number-list 100 20)
(38 70 73 57 10 81 32 99 92 19 77 39 27 24 47 17 86 8 58 76)
On Aug 25, 1:30 pm, Jonathan Smith wrote:
> Why not make a list of numbers from 0 to max, randomly shuffle it,
> and do a ta
Why not make a list of numbers from 0 to max, randomly shuffle it,
and do a take on the resulting sequence until you have enough numbers.
On Aug 25, 10:16 am, sebastien wrote:
> What is the most efficient way to generate list of unique random
> numbers? The function must look something like this
On Aug 25, 11:28 am, B Smith-Mannschott wrote:
> On Tue, Aug 25, 2009 at 16:24, Licenser wrote:
>
> > Hi everyone,
> > I wonder what is the reason clojure uses XML standard wise and not
> > JSON. In the past I've found that JSON is much cleaner to read, and
> > much easier to represent data str
On Aug 14, 11:46 am, Brian Hurt wrote:
> On Thu, Aug 13, 2009 at 4:59 PM, Daniel Lyons wrote:
>
>
>
>
>
> > On Aug 13, 2009, at 2:30 PM, Brian Hurt wrote:
>
> > I'm just wondering what people's response would be to allow user-generated
> > reader macros. I'm not sure, but I think the only chang
On Aug 14, 3:43 pm, Fogus wrote:
> Wanna play golf?
ok...
Not efficient or elegant, but certainly weird...
(defn filter-collecting [p c & seqs]
(let [fun #(if (apply p %1)
(conj! %2 (apply c %1))
%2)]
(loop [hs (map first seqs)
ts (map rest seqs)
On Aug 11, 2:43 pm, fft1976 wrote:
> On Aug 11, 4:50 am, Jonathan Smith wrote:
>
> > I don't think you have to put *everything* in the let, just your
> > constants. (so days per year and solar mass, the bodies themselves).
>
> How will they "escape"
so note that Clojure has the added wrinkle of namespace
qualification.
On Aug 11, 1:31 am, Jonathan Smith wrote:
> On Aug 10, 3:20 pm, Dragan Djuric wrote:
>
> > For example:
>
> > (defmacro creator [param]
> > `(defmacro created [p] `(the code...)) ;; note the nested
On Aug 11, 4:42 am, fft1976 wrote:
> On Aug 10, 11:42 pm, Jonathan Smith
> wrote:
>
> > The way your code is setup, you will spend a lot of time in funcall
> > overhead just because you used a lot of functions instead of doing the
> > calculation in bigger
On Aug 10, 11:08 pm, fft1976 wrote:
> On Aug 10, 2:19 pm, Jonathan Smith wrote:
>
> > 1.) use something mutable
> > 2.) unroll all the loops (mapping is a loop)
> > 3.) try not to coerce between seq/vec/hash-map too much.
>
> Are you saying this w.r.t. my code or
On Aug 10, 3:20 pm, Dragan Djuric wrote:
> For example:
>
> (defmacro creator [param]
> `(defmacro created [p] `(the code...)) ;; note the nested quote...
> how to resolve that? any examples?
Although I wouldn't cite my own code as a necessarily *good* or easy
to understand example, I'll pimp i
1.) use something mutable
2.) unroll all the loops (mapping is a loop)
3.) try not to coerce between seq/vec/hash-map too much.
in real world, stuff like the shootout is pretty useless, as generally
you'd reach for a better algorithm rather than implementing the
shackled, crippled, naive algorith
I'll second the book recommendation,
have the hacks sitting here on my desk and has been very useful so
far.
I've found that the easiest way for me to do UIs has been to write
helper functions that make the components and stitch them together
then return them inside hashmaps.
Then I write a bunc
On Jul 20, 1:27 am, kyle smith wrote:
> I'm trying to use Stuart Sierra's implementation of cells. I want to
> sum the values of a large number of cells. Rather than linearly
> summing all the values, I would like to create a tree of cells whose
> root contains the sum. I added the function
On Jul 14, 5:12 pm, Stuart Sierra wrote:
> On Jul 14, 3:01 pm, bgray wrote:
>
> > Ok, so *if* this is intended behavior, what have people been doing to
> > bind variables dependant on other bindings? I can't be the first to
> > run into this.
>
> Just nest multiple binding forms:
> (binding [
On Jul 13, 5:51 pm, Morgan Allen
wrote:
> > It's definitely not necessary to implement the bulk of your code in Java to
> > get performance. On the other hand, getting performance out of Clojure can
> > be tricky.
>
> Well, yeah, that's the thing- getting maximal performance out of
> clojure se
Seperate so it can be easily ignored:
Changed in core.clj:
(defn nth
"Returns the value at the index. get returns nil if index out of
bounds, nth throws an exception unless not-found is supplied. nth
also works for strings, Java arrays, regex Matchers and Lists, and,
in O(n) time, for s
On Jul 8, 4:57 pm, Frantisek Sodomka wrote:
> So far it seems that vectors win in Clojure:
>
> (timings 3e5
> (let [v (vector 1 2 3) a (nth v 0) b (nth v 1) c (nth v 2)] (+ a b
> c))
> (let [lst (list 1 2 3) a (nth lst 0) b (nth lst 1) c (nth lst 2)] (+
> a b c)))
>
> =>
> 680.63 ms 83.6%
On Jul 7, 5:10 pm, John Harrop wrote:
> Problem: Passing primitives from an inner loop to an outer loop efficiently.
> Here is what I've found.
>
> The fastest method of result batching, amazingly, is to pass out a list and:
>
> (let [foo (loop ... )
> x (double (first foo))
> r1 (rest foo)
> y
On Jul 6, 6:00 pm, Chouser wrote:
> On Mon, Jul 6, 2009 at 4:18 PM, Meikel Brandmeyer wrote:
> > Hi,
>
> > Am 06.07.2009 um 22:00 schrieb Chouser:
>
> >> Or if you really do need a list:
>
> >> (for [x [1 2 3]] (cons 'some-symbol (list x)))
>
> > o.O
>
> > *cough*(list 'some-symbol x)*cough* ;
On Jun 25, 3:59 pm, Berlin Brown wrote:
> On Jun 25, 3:52 pm, Mike Hinchey wrote:
>
>
>
> > Instead of eval in the doseq, you could use a macro with a do block,
> > something like:
> > user> (defmacro deftags [tags]
> > `(do ~@(map (fn [tag]
> > `(defn ~(symbol (str
54 matches
Mail list logo