> i wasn't really trying to achieve anything useful - just messing
> around and see where i get.
>
> now i'm here:
> (defrecord point [x y z])
> (defn genPoints [n]
> (let [random (new Random)
> randomInt #(.nextInt random)
> randomPoint #(new point (randomInt) (randomInt) (randomInt
On Sep 26, 2:12 pm, Paul Richards wrote:
> On Sep 26, 2:12 pm, Paul Richards wrote:
>
> > Hi,
> > How can I efficiently pick a random element from a sorted-set?
>
> I've come up with a bit of a hack, which relies on me not caring about
> non-uniform distributions. If I create a custom comparator
On Monday, September 26, 2011 2:58:59 PM UTC-6, Paul Richards wrote:
>
> This will replace an O(n) call to "nth" with an O(n) call to copy into
> a vector, so still leaving me with O(n).
>
Oops, right :) If you're getting random elements out of the same sorted set
multiple times, then it might
On Sep 26, 6:04 pm, Benny Tsai wrote:
> The reason that (rand-nth (seq (sorted-set 1 2 3))) performs badly on large
> sets is probably because nth is O(n) on sequences. nth is much much faster
> on vectors, so I would suggest trying out (rand-nth (vec (sorted-set 1 2
> 3))) and see if that works
On Sep 26, 6:13 pm, Jeremy Heiler wrote:
> On Mon, Sep 26, 2011 at 9:12 AM, Paul Richards
> wrote:
> > Hi,
> > How can I efficiently pick a random element from a sorted-set?
>
> > If I try rand-nth I get this:
> > user=> (rand-nth (sorted-set 1 2 3))
> > java.lang.UnsupportedOperationException:
On Sep 26, 2:12 pm, Paul Richards wrote:
> Hi,
> How can I efficiently pick a random element from a sorted-set?
>
I've come up with a bit of a hack, which relies on me not caring about
non-uniform distributions. If I create a custom comparator with a
"random" backdoor, I can select random elemen
Are these two related?
https://github.com/jandot/bioclojure
https://github.com/jayunit100/BioClojure
What exactly are you trying to make---a set of libraries or starter-
kit for Incanter on bioinformatics problems?
I've found it much easier to write code towards solving a concrete
probl
I don't this is a bug. ClojureScript requires UTF-8.
David
On Mon, Sep 26, 2011 at 5:03 PM, Volker Schlecht
wrote:
> Got it ... here's what was missing from my index.html:
>
>
>
> If I remove that, browser.repl fails. Can anyone else reproduce /
> confirm this?
>
> --
> You received this messag
This:
randomPoint #(apply new point (repeatedly 3 randomInt))
does not work, but is almost what you want. It doesn't work because new is
a macro, and apply only works with functions as the first arg.
Using the following two lines, first to define a function, then to use it
with apply, seems lik
On Mon, Sep 26, 2011 at 5:33 PM, Dennis Haupt wrote:
> now i'm here:
> (defrecord point [x y z])
> (defn genPoints [n]
> (let [random (new Random)
> randomInt #(.nextInt random)
> randomPoint #(new point (randomInt) (randomInt) (randomInt))]
> (repeatedly n randomPoint)))
>
> is
I suspect your repl was stale, since this doesn't work at all. By an
amusing coincidence, though, it doesn't break, just returns the wrong
answer:
user=> (defmacro infix [e] `(let [[x# f# y#] '~e] (f# x# y#)))
#'user/infix
user=> (infix (5 + 4))
4
That is, the *symbol* +, not the function +, is c
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
i wasn't really trying to achieve anything useful - just messing
around and see where i get.
now i'm here:
(defrecord point [x y z])
(defn genPoints [n]
(let [random (new Random)
randomInt #(.nextInt random)
randomPoint #(new point (
The example given in the wiki uses an in-browser repl. If you want to
work with the "regular" rhino-repl, replace
(require '[cljs.repl.browser :as browser])
with
(require '[cljs.repl.rhino :as rhino])
And you should be all set.
On Sep 26, 4:28 pm, Paul Koerbitz wrote:
> Hi David!
>
> thanks f
Got it ... here's what was missing from my index.html:
If I remove that, browser.repl fails. Can anyone else reproduce /
confirm this?
--
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
oh, that's right
2011/9/26 Alan Malloy
> Noo, then you can't do, for example, (let [x 1] (infix (x + 1))).
>
> On Sep 26, 8:34 am, Bronsa wrote:
> > or simply replace ~e with '~e
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post
ru writes:
Hi Ru,
> Thank you very much, really grand job!
I'm glad to have helped.
> By the way, I was preparing this example for students. So, you've done
> all the work for me! :)
The bill will arrive anytime soon. :-)
Bye,
Tassilo
--
You received this message because you are subscribed
Tassilo!
Thank you very much, really grand job!
By the way, I was preparing this example for students. So, you've done
all the work for me! :)
Best regards,
Ru
On 26 сен, 22:31, Tassilo Horn wrote:
> Hi again,
>
> just for the fun of doing it, here's a recursive version of infix:
>
> --8<-
Hi David!
thanks for the fast reply and this solution.
I haven't gotten it to work yet, but this is more than likely due to me not
really understanding how to put all the moving parts together.
Here is what I did:
Put your code into 'browser-repl'. Now if I execute this on the command line
I ge
Hi David, everyone,
oops, my bad, sending forms to the *inferior-lisp* buffer actually works
with C-c C-e. I just can't type anything in directly but I assume that is
due to my Emacs setup (as a die-hard vim user I am using viper and that
sometimes makes things behave a little weird). Thanks again
Looks really good. However it does not seem to support asynchronous
calls, which was really what we were looking for. We thought
http-agent was a cool idea.
Guess it wouldn't be too much work to use agents to store results of
clj_http though, I will definitely give it a try!
Cheers,
Alf
On Mon
> Most of clojure.contrib.io was moved into Clojure itself, as
> clojure.java.io. There is no future plan for functions from
> clojure.contrib.io which have not already been copied into clojure.java.io.
Guess I should have noticed that :) We certainly had no problems
replacing clojure.contrib.io w
Hi again,
just for the fun of doing it, here's a recursive version of infix:
--8<---cut here---start->8---
(defmacro infix [x]
(if (sequential? x)
`(~(second x) (infix ~(first x)) (infix ~(nth x 2)))
x))
--8<---cut here---end-
On Mon, Sep 26, 2011 at 6:45 AM, Stuart Sierra
wrote:
> Most of clojure.contrib.io was moved into Clojure itself, as
> clojure.java.io.
When I created
http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
I did it based on the modules folder here
https://github.com/clojure/clojure-c
ru writes:
Hi Ru,
> With your help I have found the solution that coincide with Bronsa's
> (my special respect to Bronsa):
>
> user=> (defmacro infix [e] `(let [[x# f# y#] '~e] (f# x# y#)))
> #'user/infix
> user=> (infix (5 + 4))
> 9
Alan already told you that this solution is not really good.
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
i don't have the magic eye to spot the parenthesis-errors yet
Am 25.09.2011 22:15, schrieb Mark Rathwell:
>> (let [rand (new java.util.Random) nextInt (fn [a] (.nextInt
>> rand))] ((map (print) (iterate ((nextInt "dummy") 0)
>
> extra parenthesis
Thanks to all!
With your help I have found the solution that coincide with Bronsa's
(my special respect to Bronsa):
user=> (defmacro infix [e] `(let [[x# f# y#] '~e] (f# x# y#)))
#'user/infix
user=> (infix (5 + 4))
9
But, this solution seems to me awkward and showing that Clojure
compiler does n
Hi Zhi Yang,
The easiest way to make the transition to 1.3 is to start using "new"
contrib libraries first. Most of them are still compatible with Clojure 1.2,
so you can update your libraries first, make sure everything works, then
update to Clojure 1.3.
Regards,
-Stuart Sierrra
clojure.com
On Mon, Sep 26, 2011 at 9:12 AM, Paul Richards wrote:
> Hi,
> How can I efficiently pick a random element from a sorted-set?
>
> If I try rand-nth I get this:
> user=> (rand-nth (sorted-set 1 2 3))
> java.lang.UnsupportedOperationException: nth not supported on this
> type: PersistentTreeSet (NO_S
The reason that (rand-nth (seq (sorted-set 1 2 3))) performs badly on large
sets is probably because nth is O(n) on sequences. nth is much much faster
on vectors, so I would suggest trying out (rand-nth (vec (sorted-set 1 2
3))) and see if that works for your application.
--
You received this
Noo, then you can't do, for example, (let [x 1] (infix (x + 1))).
On Sep 26, 8:34 am, Bronsa wrote:
> or simply replace ~e with '~e
--
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
I looked at it today and have updated the macro.
(same gist: https://gist.github.com/1209498)
Additions:
It detects if a form contains (recur ...), and if it does,
the form isn't wrapped in (try ...).
trace vectors, maps, and sets.
trace (fn* ...) & (new ...)
---
The code feels a bit "thrown t
On Sep 26, 2011, at 8:12 AM, Paul Richards wrote:
> How can I efficiently pick a random element from a sorted-set?
If your sorted set is densely packed (if most possible values do appear in the
set), then you could just pick a random value, see if it's in the set, and
repeat until you find a ma
Oh yeah, I am going it in Mono and in the Windows machine with .Net
thanks for the big release :)
--
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
or simply replace ~e with '~e
--
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 unsubscribe from t
Mark McGranaghan and Lee Hinman's clj-http is a nice HTTP library that's
fully compatible with Clojure 1.3:
https://github.com/dakrone/clj-http
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups
Use macroexpand-1 to expand a call to this macro, and it should be
clear what is going on. The expanded code tries to call 5 as a
function. What you are probably trying to do here is make (5 + 2) a
list, not a function call.
;; (note the unquote splicing of e)
(defmacro infix [e] `(let [[x# f#
2011/9/26 ru
>
> That's exactly means evaluation of argument that's contradict to
> mentioned above documentation!
>
> On 26 сен, 18:18, Tassilo Horn wrote:
> > > Ok, this is working! But, what's the difference?
> >
> > Your code:
> >
> > user=> (defmacro infix [e] `(let [[x# f# y#] ~e] (f# x#
The argument isn't being evaluated during macro expansion, it's being
evaluated when the expanded form is evaluated by the repl:
user=> (macroexpand '(infix (5 + 4)))
(let* [vec__590 (5 + 4) x__574__auto__ (clojure.core/nth vec__590 0
nil) f__575__auto__ (clojure.core/nth vec__590 1 nil) y__576__a
Well, Tassilo.
That's exactly means evaluation of argument that's contradict to
mentioned above documentation!
On 26 сен, 18:18, Tassilo Horn wrote:
> ru writes:
> > user=> (defmacro infix [[x f y]] `(~f ~x ~y))
> > #'user/infix
> > user=> (infix (5 + 4))
> > 9
>
> > Ok, this is working! But, w
Timothy!
Thank you for the explanation. I understand quite well about
performance. I do'nt understand why it evaluates argument (5 + 4)
during expansion in my case?
Ru
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email
One very important difference is that your original version creates
three variables on-the-fly. It then copies the input into these
variables, just to perform a simple addition. This could have a fairly
severe performance penalty in a inner loop. David's version doesn't
suffer from this. The perfor
ru writes:
> user=> (defmacro infix [[x f y]] `(~f ~x ~y))
> #'user/infix
> user=> (infix (5 + 4))
> 9
>
> Ok, this is working! But, what's the difference?
Your code:
user=> (defmacro infix [e] `(let [[x# f# y#] ~e] (f# x# y#)))
The ~e evaluates the given form, which looks like a function bu
user=> (defmacro infix [[x f y]] `(~f ~x ~y))
#'user/infix
user=> (infix (5 + 4))
9
Ok, this is working! But, what's the difference?
--
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 th
Try:
(defmacro infix [[x f y]] `(~f ~x ~y)))
On Mon, Sep 26, 2011 at 9:57 AM, Ruslan Sorokin wrote:
> **
> Hi dear clojurians!
>
> From Clojure documentation (http://clojure.org/evaluation):
>
> ..If the operator of a call is a symbol that names a global var that is a
> macro function, that mac
Hi dear clojurians!
From Clojure documentation (http://clojure.org/evaluation):
..If the operator of a call is a symbol that names a global var that is
a macro function, that macro function is called and is passed the
/unevaluated/ operand forms.
But:
ru@ru-desktop ~/clojure/clojure-1.2.1 $
I've created the following wiki -
https://github.com/clojure/clojurescript/wiki/Emacs-&-inferior-lisp-mode
Let me know if this needs more clarification.
David
On Mon, Sep 26, 2011 at 9:15 AM, Paul Koerbitz wrote:
> Dear Clojurians,
>
> I was toying with Clojurescript and really like using the R
Hi Alf,
Most of clojure.contrib.io was moved into Clojure itself, as
clojure.java.io. There is no future plan for functions from
clojure.contrib.io which have not already been copied into clojure.java.io.
clojure.contrib.http-agent was a weak idea with mediocre execution. (I wrote
it.) It is f
On Sep 24, 2011, at 4:17 PM, alexey.petrushin wrote:
> So, maybe there's an interesting Open Source Project that uses this
> approach? With clean code that can be seen as showcase of such
> techniks, and You can dig in it and see all this in action by
> Yourself? It would be really interesting.
Dear Clojurians,
I was toying with Clojurescript and really like using the Repl as described
here https://github.com/clojure/clojurescript/wiki to try things out.
(thanks for all the great to everyone involved!!)
Has anyone hooked this into Emacs in a Swank-like fashion? I would love to
be able t
Hi,
How can I efficiently pick a random element from a sorted-set?
If I try rand-nth I get this:
user=> (rand-nth (sorted-set 1 2 3))
java.lang.UnsupportedOperationException: nth not supported on this
type: PersistentTreeSet (NO_SOURCE_FILE:0)
I can get this expression to work if I naively apply
Hello Alexey,
Probably, russian is your primary language? Then look here for the
examples of the DSL:
1. http://my-clojure.blogspot.com/search/label/DSL -- a simple
embedded DSL for the application configuration;
2. Here (http://scala.by/meetups/2011/09/10/4.html) you may get the
slides of my pre
While the statement that creating any syntax is true for LISP, so for
Clojure its not because of missing reader macro ("The read table is
currently not accessible to user programs." from http://clojure.org/reader).
Nevertheless I found homoiconicity very useful. I turned my XML
document (with my i
On Mon, Sep 26, 2011 at 1:35 AM, Alexey Petrushin <
alexey.petrus...@gmail.com> wrote:
> 1. No compilation step, quick live prototyping in browser.
>
Already possible, and IMO better experience than pretty much anything else
out there - Browser REPL
> 2. Pure browser environment, no need to ins
53 matches
Mail list logo