On Mar 10, 8:04 pm, stu wrote:
> On Mar 11, 8:35 am, Alan wrote:
> > > Suppose I need mathematical 2D vector functions:
>
> > > (ns geometry.vector)
>
> > > (defstruct vector :x :y)
>
> > > (defn +
> > > "Add vectors v and w, yielding a vector"
> > > [ v w ]
> > > (...))
>
Hmm, I should have thought of that.
New Clojure:
(ns hello.test
(import org.jbox2d.common.Vec2)
(:gen-class))
(defn -main [& args]
(dotimes [q 5]
(let [#^Vec2 a (Vec2. 1 2)
#^Vec2 b (Vec2. 3 4)]
(time (loop [x (int 0)]
(when (< x (int 1e9))
1. The Clojure wrapper put the last two calls inside the if, unlike
Matcher#replaceFirst(), thus the nil.
public String replaceFirst(String replacement) {
if (replacement == null)
throw new NullPointerException("replacement");
StringBuffer sb = new StringBuffer();
reset();
On Thu, Mar 10, 2011 at 10:39 PM, Jarl Haggerty wrote:
> I've been benchmarking java and clojure programs and wanted to make
> sure I was doing this right. I made two fairly similar programs that
> manipulated Vec2 objects from the JBox2D library. At first clojure
> was performing pretty poorly,
On Thu, Mar 10, 2011 at 10:39 PM, Jarl Haggerty wrote:
> I've been benchmarking java and clojure programs and wanted to make
> sure I was doing this right. I made two fairly similar programs that
> manipulated Vec2 objects from the JBox2D library. At first clojure
> was performing pretty poorly,
On Mar 11, 8:35 am, Alan wrote:
> > Suppose I need mathematical 2D vector functions:
>
> > (ns geometry.vector)
>
> > (defstruct vector :x :y)
>
> > (defn +
> > "Add vectors v and w, yielding a vector"
> > [ v w ]
> > (...))
>
> > Which leads to the core "vector" function
Try typehinting the a and b in the let.
--
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 from new members are moderated - please be patient with your
first post.
To unsubscr
I should readjust my 5x statement, it's more like 2.25x.
On Mar 10, 8:39 pm, Jarl Haggerty wrote:
> I've been benchmarking java and clojure programs and wanted to make
> sure I was doing this right. I made two fairly similar programs that
> manipulated Vec2 objects from the JBox2D library. At f
I've been benchmarking java and clojure programs and wanted to make
sure I was doing this right. I made two fairly similar programs that
manipulated Vec2 objects from the JBox2D library. At first clojure
was performing pretty poorly, then I tried compiling my clojure
script, and then replacing th
Hi,
I have two questions about clojure.string/replace-first.
1.
Is this expected behavior of replace-first?
(require '[clojure.string :as str])
(str/replace-first "abc def" #"ghi" (fn [a] (str a a)))
=> nil
I don't think so, because string / string argument version returns
original string when m
Functions can only be compared by identity, not value, eg (not=
(constantly 1) (constantly 1)). When you attach metadata to a
function, you cause it to no longer be = to other non-meta instances
of that function, so memoize can no longer use previous values.
user=> (def mp (memoize println))
#'use
Adding metadata to an object produces a new object, rather than
altering the existing object. Every time you increment the counter for
a function in p it becomes different, and the memoize treats it as
new. That is, p-apply-memoized takes parameters p and v. Your
post-walk over p replacing function
Hi all,
I'm struggeling with some really strange problem. I have a function
`p-apply', which can be used find all reachable vertices in a graph
matching a regular expression modeled as nested vector of functions, to
which the results are chained through. Here's an example call:
(p-apply v1 [p
Dynamic binding is more useful when your function expect the *var* to
change during the program. And sometimes you can't pass arguments
through, like in (run-tests). How about a simple API with this usage:
(set-opt :development) ; this is what you want
...
(get-opt :show-sql) ; need this flag
Thi
Hi,
here something different. But also using the ugly butlast and last.
user=> (defn enmap [& args] (assoc-in {} (butlast args) (last args)))
#'user/enmap
user=> (enmap 1 2 3 4 {5 6 7 8})
{1 {2 {3 {4 {5 6, 7 8}
Sincerely
Meikel
--
You received this message because you are subscribed to the
thanks ken for the answer.
more(?) functional using closures:
(defn get-config [environment]
(let [env (condp = environment
:development
{ :whoami "development"}
:test
{ :whoami "test"}
:production
{ :whoami "production"}
(throw (IllegalArgumentException.
On Mar 10, 12:48 pm, stu wrote:
> Hi,
>
> This is a newb question so apologies in advance if I haven't read
> enough Clojure code yet to see the answer.
>
> Suppose I need mathematical 2D vector functions:
>
> (ns geometry.vector)
>
> (defstruct vector :x :y)
>
> (defn +
> "Add vectors v a
Real nice and short. Doing [& args] avoids the vector:
user=> (enmap 1 2 3 4 {5 6 7 8})
{1 {2 {3 {4 {5 6, 7 8}
On Mar 10, 10:38 am, Takahiro wrote:
> more concise:
>
> (defn enmap [args]
> (reduce #(hash-map %2 %1) (reverse args)))
>
> 2011/3/11 Takahiro :
>
>
>
> > Interesting. Here is my
Hi,
This is a newb question so apologies in advance if I haven't read
enough Clojure code yet to see the answer.
Suppose I need mathematical 2D vector functions:
(ns geometry.vector)
(defstruct vector :x :y)
(defn +
"Add vectors v and w, yielding a vector"
[ v w ]
(...
On Thu, Mar 10, 2011 at 9:51 AM, faenvie wrote:
> references to *opts* are scattered all over my clojure-code
> so that many of the functions are impure. this seems like
> a smell to me and there are probably cleaner ways to propagate
> config-params (keep functions pure) ... what are they ?
Ther
On Mar 10, 7:48 pm, Damien Lepage wrote:
> Sorry for the dumb questions, I'll try no to be too noisy on this list.
>
I found this thread useful. Please keep asking questions.
Saul
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group
> Thanks a lot for your help, there's an awesome community here.
>
> Sorry for the dumb questions, I'll try no to be too noisy on this list.
>
> BTW, shouldn't it be better to create a separate mailing list for beginners?
> Well, we would still need some experienced clojurers to answer the question
Ah, thanks. I think the pulling-apart of last and butlast was a
remnant of my trying to do this with foldl instead of foldr :P.
On Mar 10, 10:38 am, Takahiro wrote:
> more concise:
>
> (defn enmap [args]
> (reduce #(hash-map %2 %1) (reverse args)))
>
> 2011/3/11 Takahiro :
>
>
>
>
>
>
>
> > Int
On Thu, Mar 10, 2011 at 11:55 AM, Vagif Verdi wrote:
> Jim, i assume you are familiar with haskell (monads -> haskell :))
>
> So my question is, can you describe the difference in working with
> monads in dynamic language (clojure) with working with monads in
> haskell.
> From my own experience i
Thanks a lot for your help, there's an awesome community here.
Sorry for the dumb questions, I'll try no to be too noisy on this list.
BTW, shouldn't it be better to create a separate mailing list for beginners?
Well, we would still need some experienced clojurers to answer the questions
though .
Hi Alex,
great to hear that there are more clojurians going pycon :). I'm
currently attending the pycon tutorial sessions and I'm staying until
sunday the 13th. Just let me know when you're here and where to meet.
Are the more clojurians wanting to join?
Cheers,
Erik
On Mar 10, 2:26 pm, Alex Ro
more concise:
(defn enmap [args]
(reduce #(hash-map %2 %1) (reverse args)))
2011/3/11 Takahiro :
> Interesting. Here is my attempt.
>
> (defn enmap [args]
> (let [[fs & res] (reverse args)]
> (reduce (fn [v k] (hash-map k v)) fs res)))
>
>> (enmap [1 2 3 4 {5 6 7 8}])
> => {1 {2 {3 {4 {5 6,
I've now pushed v0.0.1 of Rummage to github and maven central. This is my
massive refactoring / rewrite of Rich's original SDB client implementation:
https://github.com/cemerick/rummage
It addresses all of the issues I note in the quoted google doc, and hopefully
pushes things forward some w.r
Interesting. Here is my attempt.
(defn enmap [args]
(let [[fs & res] (reverse args)]
(reduce (fn [v k] (hash-map k v)) fs res)))
> (enmap [1 2 3 4 {5 6 7 8}])
=> {1 {2 {3 {4 {5 6, 7 8}
>(let [[tail more] ((juxt last (comp reverse butlast)) [1 2 3 4 {5 6 7 8}])]
> (reduce #(hash-map %2
> - Is there a way to make this function less complicated? without
> recursion maybe?
Looks like you're covered on this one.
> - Is there something simpler than (concat even-more (list (hash-map k
> v)) to append an element at the end of a sequence?
Clojure is opinionated in this sen
On Thu, Mar 10, 2011 at 12:46 PM, Damien Lepage wrote:
> Hi
>
> (apply enmap arg (concat even-more (list (hash-map k v
> Is there something simpler than (concat even-more (list (hash-map k v)) to
> append an element at the end of a sequence?
To answer your second question, I think
On Mar 10, 10:05 am, Aaron Cohen wrote:
> On Thu, Mar 10, 2011 at 12:46 PM, Damien Lepage
> wrote:
> > Hi
>
> > I wrote a function to transform a variable number of arguments into embedded
> > maps.
> > Here is what it does:
> >> (enmap 1 2)
> > {1 2}
> >> (enmap 1 2 3)
> > {1 {2 3}}
> >> (enmap
On Mar 10, 12:46 pm, Damien Lepage wrote:
> Hi
>
> I wrote a function to transform a variable number of arguments into embedded
> maps.
> Here is what it does:
>
> > (enmap 1 2)
> {1 2}
> > (enmap 1 2 3)
> {1 {2 3}}
> > (enmap 1 2 3 4)
> {1 {2 {3 4}}}
> > (enmap 1 2 3 4 {5 6 7 8})
>
> {1 {2 {3 {4
On Thu, Mar 10, 2011 at 12:46 PM, Damien Lepage wrote:
> Hi
>
> I wrote a function to transform a variable number of arguments into embedded
> maps.
> Here is what it does:
>> (enmap 1 2)
> {1 2}
>> (enmap 1 2 3)
> {1 {2 3}}
>> (enmap 1 2 3 4)
> {1 {2 {3 4}}}
>> (enmap 1 2 3 4 {5 6 7 8})
> {1 {2 {
(let [[tail more] ((juxt last (comp reverse butlast)) [1 2 3 4 {5 6 7
8}])]
(reduce #(hash-map %2 %1) tail more))
{1 {2 {3 {4 {5 6, 7 8}
On Mar 10, 9:46 am, Damien Lepage wrote:
> Hi
>
> I wrote a function to transform a variable number of arguments into embedded
> maps.
> Here is what it
Hi
I wrote a function to transform a variable number of arguments into embedded
maps.
Here is what it does:
> (enmap 1 2)
{1 2}
> (enmap 1 2 3)
{1 {2 3}}
> (enmap 1 2 3 4)
{1 {2 {3 4}}}
> (enmap 1 2 3 4 {5 6 7 8})
{1 {2 {3 {4 {5 6, 7 8}
Here is my implementation:
(defn enmap [arg & args]
Jim, i assume you are familiar with haskell (monads -> haskell :))
So my question is, can you describe the difference in working with
monads in dynamic language (clojure) with working with monads in
haskell.
>From my own experience i would say that without a firm help from
typing system i would st
That was basically my question, protocols are designed for this but
ILookup isn't a protocol. Is it possible to make ILookup into a
protocol? I haven't looked at the java code much at all, but I might
take a stab at creating a patch it that seems possible.
Converting java.util.Properties into a
I'd be interested as well; sounds awesome :)
Thanks for your offer,
~Adam~
--
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 from new members are moderated - please be patie
I'd love to assit too (I like the fact that it'd be interactive). Just
to let you know I'm on GMT (for when you schedule things).
Cheers,
U
--
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
Hey guys,
I'm pretty new to Clojure and loving it. I'm going to be at Pycon (the
Python conference in Atlanta) this weekend. Any other clojurers going
to be there? Want to meet and chat about our two favorite languages?
Alex
--
You received this message because you are subscribed to the Google
Anyone else in the north Dallas area using/interested in Clojure? I'd
love to get together.
Alex
--
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 from new members are modera
Jim, I would love to assist, I think it's a great initiative
Cheers.
Federico
On Thu, Mar 10, 2011 at 10:50 AM, jim wrote:
> Definitely free. :)
>
> I feel like there are already a ton of resources for reading/watching
> to learn monads, and yet people still have trouble getting over the
> hum
hi clojure-users,
i have a question regarding the setup and propagation
of config-params.
to configure a clojure-based web-app, i use a global var
*opts* that is setup like this:
(defn get-opts
[environment]
(condp = environment
:development
{ :webapp-context "/mywebapp"
:w
I wrote this macro a little while ago because I need that same
construct:
https://gist.github.com/701051
On Mar 9, 7:12 am, Sean Allen wrote:
> Yesterday I was writing a bit of code that needs to wait for an
> external event to happen but if it doesn't happen with X amount of
> time,
> to timeo
Definitely free. :)
I feel like there are already a ton of resources for reading/watching
to learn monads, and yet people still have trouble getting over the
hump. So my thought was that this would be different because there
would be chance for interaction. So I probably wouldn't record it.
The t
Out of curiosity, why did you go with Neo4j rather than using jiraph?
(https://github.com/ninjudd/jiraph) I used neo4j in the past, and if
I remember right my main annoyance was that edges had to be traversed
based on the type of the edge instance object, which felt annoying
from a language like c
In Overtone we have the same situation, where we return a promise
representing a server response and sometimes we want to timeout if the
response never arrives. This is what we use:
(defn await-promise!
([prom] (await-promise prom REPLY-TIMEOUT))
([prom timeout]
(.get (future @prom) time
Hello,
In two separate instances, the contributor agreement forms sent by the
Bangalore Clojure group and another one sent by me (from Bangalore)
have come back unclaimed. Is there something I am missing? The
following address was used in both cases:
Rich Hickey
P.O. Box 316
Pleasantville, NY 105
49 matches
Mail list logo