Re: let-while

2014-03-05 Thread Dan Cross
On Saturday, October 17, 2009 11:42:28 PM UTC-4, mbrodersen wrote:

> It would be great to have while-let in contrib. Then I don't have to
> maintain let-while myself :-)


I'm reviving this ancient thread because of core.async.  This seems like
just the thing for the common pattern of looping over data received from a
channel until the channel is closed.

Consider the following snippet of Go code that illustrates a common idiom:

func printints(c chan int) {
for v := range c {
fmt.Println(v)
}
fmt.Println("Channel closed!")
}

(Note: often this would be called in a go routine by e.g., a closure that
adds and removes from a wait group or something similar, but I omit that
here for brevity.)

In particular, notice how the 'range' operator interacts with both the
channel and the 'for' construct to loop over the values received on the
channel until the channel is closed.  I'd like to do something similar in
Clojure, but I don't believe that we have an exact analogue; the closest
I've been able to come up with are the two:

(loop []
  (when-let [v (https://www.versioneye.com/clojure/while-let:while-let/0.1.0 (which
ultimately leads to...)
https://github.com/markmandel/while-let/blob/master/src/while_let/core.clj

I don't like that nearly as much as Christophe's version, but it is worth
noting that the author specifically mentions core.async as well, thus
implying that there is wider demand for this sort of thing.  Is it worth
asking that this be added to e.g. the core library?  Or even to core.async?

Thanks,

- Dan C.

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: let-while

2014-03-05 Thread Dan Cross
(And for context, here is Christophe's 'while-let' from 2009):

(defmacro while-let

 "Makes it easy to continue processing an expression as long as it is true"
 [binding & forms]
  `(loop []
 (when-let ~binding
   ~@forms
   (recur



On Wed, Mar 5, 2014 at 5:09 AM, Dan Cross  wrote:

> On Saturday, October 17, 2009 11:42:28 PM UTC-4, mbrodersen wrote:
>
>> It would be great to have while-let in contrib. Then I don't have to
>> maintain let-while myself :-)
>
>
> I'm reviving this ancient thread because of core.async.  This seems like
> just the thing for the common pattern of looping over data received from a
> channel until the channel is closed.
>
> Consider the following snippet of Go code that illustrates a common idiom:
>
> func printints(c chan int) {
> for v := range c {
> fmt.Println(v)
> }
> fmt.Println("Channel closed!")
> }
>
> (Note: often this would be called in a go routine by e.g., a closure that
> adds and removes from a wait group or something similar, but I omit that
> here for brevity.)
>
> In particular, notice how the 'range' operator interacts with both the
> channel and the 'for' construct to loop over the values received on the
> channel until the channel is closed.  I'd like to do something similar in
> Clojure, but I don't believe that we have an exact analogue; the closest
> I've been able to come up with are the two:
>
> (loop []
>   (when-let [v ( (println v)
> (recur)))
>
> and
>
> (while
>   (when-let [d ( (println d)
> d))
>
> These work, but neither strikes me as particularly elegant (in particular,
> the use of 'while' here is ugly).  Speaking of 'while, I also see this in
> some places such as the
>
> (while true (let [v (!< c)] (...)))
>
> However, that won't exit when the channel closes.  Indeed, the loop will
> just set 'v' to 'nil' forever after the channel closes (or at least as long
> as 'true' is 'true').
>
> What I really want is a loop that iterates (or recurses) while something
> is true, like the 'while-let' that was discussed in this thread.  That
> seems to capture the semantics of exactly what I want to do when looping
> over the items placed onto a channel.  In particular:
>
> - It captures the semantics of doing something *while* a binding is true;
> exactly what we want when binding something from a  channel get operation.
> - It encapsulates the side-effect in the binding form.
> - It's simpler and more elegant than the alternatives.
>
> Indeed, the 'loop' above is really the body of the 'while-let' macro that
> Christophe Grand posted back in 2009.
>
> Unfortunately, it doesn't seem to have made it into one of the core
> libraries.  Did it ever make it into contrib?  I don't see it in the "Where
> Did Clojure.Contrib Go" list.  The only references to it that I see are to
> an apparent reimplementation:
>
> https://www.versioneye.com/clojure/while-let:while-let/0.1.0 (which
> ultimately leads to...)
> https://github.com/markmandel/while-let/blob/master/src/while_let/core.clj
>
> I don't like that nearly as much as Christophe's version, but it is worth
> noting that the author specifically mentions core.async as well, thus
> implying that there is wider demand for this sort of thing.  Is it worth
> asking that this be added to e.g. the core library?  Or even to core.async?
>
> Thanks,
>
> - Dan C.
>
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: A faster clojure startup

2014-03-05 Thread Max Gonzih
This is brilliant amount of work! Looking forward to play with new patch on 
my ARM devices.

On Friday, February 28, 2014 6:16:44 PM UTC+3, Gal Dolber wrote:
>
> Here're some notes on the lean compiler I've been working on for 
> clojure-objc
>
> http://galdolber.tumblr.com/post/78110050703/reduce-startup
>
> Feedback's welcome
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to replace code inside a macro

2014-03-05 Thread Konrad Hinsen

--On 4 Mar 2014 23:07:27 -0800 milinda  wrote:


I wanted macro to work like following.


( (let [x 10] (+ x (defpop


This should generate function like


(defn execute [tu3455] (let [x 10] (+ x tu3455)))


Try this:

 (defmacro  [body]
   `(macrolet [(~'defpop [] 'tu#)] (defn execute [tu#] ~body)))

In action:

 user=> (macroexpand-1 '( (let [x 10] (+ x (defpop)
 (clojure.tools.macro/macrolet [(defpop [] (quote tu__818__auto__))] 
(clojure.core/defn user/execute [tu__818__auto__] (let [x 10] (+ x 
(defpop)


 user=> (macroexpand '( (let [x 10] (+ x (defpop)
 (do (def user/execute (fn* ([tu__818__auto__] (let* [x 10] (+ x 
tu__818__auto__))



Konrad.

--
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups "Clojure" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: core.async pub/sub

2014-03-05 Thread Scott Johnson
not sure when then added this but it looks like 
pub
 and sub  are 
in the async lib now. 

any differences between what they have now and what you need?

looking for some example code, but could not find any so i tried 
this and it seems to work:

(def t-fn
(fn 
[ele]
"all"))
(def pub-chan (chan))
(def a-pub (pub pub-chan t-fn))
(def sub-one (chan))
(def sub-two (chan))
(defn p-s-test
[]
(sub a-pub "all" sub-one)
(sub a-pub "all" sub-two)
(go (while true
(let [v (! pub-chan "shine")
(! pub-chan "on")
(! pub-chan "you crazy")
(! pub-chan "diamond")))


-Scott

On Thursday, July 11, 2013 2:15:28 AM UTC-7, Thomas Heller wrote:
>
> Hey,
>
> the lab stuff looks very interesting, I however couldn't quite figure out 
> how to "unsubscribe" one channel from the broadcast since I cannot exchange 
> the "topic" for every subscriber when one subscriber decides to leave. Its 
> also a lot lower level than I'm currently comfortable with since I haven't 
> checked out any of the core.async internals yet.
>
> However I wrote my own little pubsub utilities which (almost) only use the 
> public API.
>
> (def my-topic (pubsub/topic 100))
>  
> (pubsub/subscribe-go
>  [subscription my-topic (sliding-buffer 100)]
>  (loop []
>(when-let [ev (  (prn [:sub-got ev])
>  (recur
>  
> ;; without go
> (let [sub (pubsub/subscribe my-topic (sliding-buffer 100))]
>   (prn [:msg (   (close! sub))
>
>
> Complete code at: https://gist.github.com/thheller/5973825
>
> subscribe-go is a convenience macro which allows to subscribe to multiple 
> topics and is a normal go block, so same rules apply and you may take! from 
> any other channel as well. When the block ends the subscription is 
> automatically removed, otherwise a subscription is removed by closing it.
>
> Could be optimized but it seems to work fine for me.
>
> Will follow the lab.clj when I'm ready to get dirty with the internals. ;) 
>
> Cheers,
> /thomas
>
> On Wednesday, July 10, 2013 12:27:59 PM UTC+2, Alex Miller wrote:
>>
>> There is a broadcast fn in the lab namespace (
>> https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/lab.clj)
>>  
>> that does this and I believe David Nolen has created a different variant in 
>> some of his stuff. The lab one is experimental and would welcome feedback 
>> on it.
>>
>> Alex
>>
>> On Tuesday, July 9, 2013 6:46:21 PM UTC-5, Thomas Heller wrote:
>>>
>>> Hey,
>>>
>>> I'm doing some core.async tests and want to create a basic pub/sub 
>>> model. Messages are >! on one channel and >! to many others.
>>>
>>> (deftest ^:wip async-test2
>>>  
>>>   (let [subscribers (atom [])
>>> events (chan 100)]
>>>  
>>> (go (loop []
>>>   (when-let [ev (>> (doseq [c @subscribers]
>>>   (alt!
>>>[[c ev]] :sent
>>>:default nil ;; could "force" unsubscribe c?
>>>))
>>> (recur
>>>  
>>> (let [s1 (chan 1)
>>>   s2 (chan 100)
>>> r1 (atom [])
>>>   r2 (atom [])]
>>> (swap! subscribers conj s1 s2)
>>> ;; simulated slow reader
>>>   (go (loop []
>>> (when-let [ev (>>   (swap! r1 conj ev)
>>>   (>>   (recur 
>>> ;; good reader
>>>   (go (loop []
>>> (when-let [ev (>>   (swap! r2 conj ev)
>>>   (recur
>>> (>>  (when (< i 100)
>>>(>! events i)
>>>(recur (inc i))
>>>  
>>>   (close! events)
>>> (Thread/sleep 25)
>>> (pprint @r1)
>>>   (pprint @r2))
>>> ))
>>>
>>>
>>> In this example the s1 subscriber will loose almost all messages since 
>>> he cannot keep up (and buffer is too small). I choose to alt!/:default to 
>>> drop messages, since I don't want any subscriber to block others. How do 
>>> you guys deal with slow-readers?
>>>
>>> I don't really have a specific problem but I wonder if there are any 
>>> plans for some built-in pub/sub mechanisms for core.async. Seems like a 
>>> very common pattern.
>>>
>>> Anyways, core.async is nice!
>>>
>>> Cheers,
>>> /thomas
>>>
>>>
>>>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.

Re: paredit+regex question

2014-03-05 Thread Erlis Vidal
Hi all

Thanks for all the replies.

@Magnar: Thanks for the quick key combination I'll add that to my cheat
sheet ;)
@Phillip: Wow! I'm wondering why paredit doesn't fix this issue. Thanks for
the patch!
@Oleh: I will definitively will take a look at this, I'm starting with
paredit and I'm liking it but this regexp bug was really annoying.

Regards,
Erlis


On Tue, Mar 4, 2014 at 8:14 AM, Oleh  wrote:

> Hi Erlis,
>
> There's a full alternative to Paredit that I'm writing:
> https://github.com/abo-abo/lispy.
> Try it out if you haven't yet, it's got some Clojure support, like inline
> function arguments
> and jump-to-defintion (just a binding for cider-jump-to-def, really, but
> it's just one letter: "F").
>
> Here's a Clojure screencast for jump-to-tag functionality (again just one
> letter: "g" or "G"):
> https://vimeo.com/86727658.
>
> The documentation is here: http://abo-abo.github.io/lispy/.
> Lispy is in active development, so if you have ideas or issues,
> raise them here: https://github.com/abo-abo/lispy/issues?state=open.
>
> Oleh
>
>
> On Monday, March 3, 2014 10:09:47 PM UTC+1, Erlis Vidal wrote:
>
>> Hi this is not a clojure question but I'm sure some one on this list can
>> help me.
>>
>> I'm trying to write a regex using paredit and it looks like I cannot
>> write something like this
>>
>> #"mypattern \d"
>>
>> whenever I type the character \ I see the text "Escaping character..." in
>> the minibuffer. It is waiting for another character and then it uses the
>> two characters as a single one, so I cannot delete only one, they are
>> together.
>>
>> I see how this can be useful for strings, but for regex this is not
>> helping.
>>
>> I end up writing my regex like (re-pattern "mypattern \\d") instead of
>> using the short syntax.
>>
>> Any idea how can I write the short syntax using paredit?
>>
>> Thanks,
>> Erlis
>>
>  --
> 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 this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Solving allocation problems; code review and core.logic

2014-03-05 Thread Laurens Van Houtven
Hi!


I've been experimenting solving some real-world problems related to
organizing a sizable (2000-3000 people) programming conference with a
strong open source flavor.

My next problem is a bit more daunting.

This conference has a financial aid program. People who can not afford
to come to the conference are given grants that have to come out of a
budget. The budget is much smaller than the sum of all requested
grants, so it turns into an underspecified optimization problem. In
order to make that issue slightly less bad, there's a score function
so that we can bias in favor of certain people, e.g. speakers.

I'm convinced the optimal solution, even assuming it exists, is
impossible to find. The data is incomplete; it is not necessarily true
that because you assign less than what people have requested that they
won't accept the grant.

I wrote an implementation that plausibly matches the above:

https://github.com/lvh/hood/blob/master/src/hood/core.clj

I'm sure that that code has a lot of flaws. I haven't really played
with it enough yet. Code review on that is very welcome. Any
suggestions for a cleverer allocation algorithm would also be much
appreciated.

That said, I really sent this e-mail because I was wondering to what
extent core.logic could be applied to this problem. The "running your
program in reverse" concept is potentially interesting here; I'm
hoping that we could get answers to questions like "what would an
application have to look like to get X dollars under our budget?"

I seriously don't even know where to start. What would the logic
variables be? It seems that a lot of the example code uses a single
logic variable and then "structures" it in the let body; but I have no
idea what that one variable would even mean.

Perhaps I should just tackle some simpler logic programs first :-)

Thanks in advance for your thoughts and comments!
lvh

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Solving allocation problems; code review and core.logic

2014-03-05 Thread David Nolen
I'm cross posting this to the miniKanren mailing list.

It sounds like core.logic or cKanren could be applied to your problem but
would need more details. I also wouldn't rule out finite domain solvers
like JaCoP.

David


On Wed, Mar 5, 2014 at 9:52 AM, Laurens Van Houtven <_...@lvh.cc> wrote:

> Hi!
>
>
> I've been experimenting solving some real-world problems related to
> organizing a sizable (2000-3000 people) programming conference with a
> strong open source flavor.
>
> My next problem is a bit more daunting.
>
> This conference has a financial aid program. People who can not afford
> to come to the conference are given grants that have to come out of a
> budget. The budget is much smaller than the sum of all requested
> grants, so it turns into an underspecified optimization problem. In
> order to make that issue slightly less bad, there's a score function
> so that we can bias in favor of certain people, e.g. speakers.
>
> I'm convinced the optimal solution, even assuming it exists, is
> impossible to find. The data is incomplete; it is not necessarily true
> that because you assign less than what people have requested that they
> won't accept the grant.
>
> I wrote an implementation that plausibly matches the above:
>
> https://github.com/lvh/hood/blob/master/src/hood/core.clj
>
> I'm sure that that code has a lot of flaws. I haven't really played
> with it enough yet. Code review on that is very welcome. Any
> suggestions for a cleverer allocation algorithm would also be much
> appreciated.
>
> That said, I really sent this e-mail because I was wondering to what
> extent core.logic could be applied to this problem. The "running your
> program in reverse" concept is potentially interesting here; I'm
> hoping that we could get answers to questions like "what would an
> application have to look like to get X dollars under our budget?"
>
> I seriously don't even know where to start. What would the logic
> variables be? It seems that a lot of the example code uses a single
> logic variable and then "structures" it in the let body; but I have no
> idea what that one variable would even mean.
>
> Perhaps I should just tackle some simpler logic programs first :-)
>
> Thanks in advance for your thoughts and comments!
> lvh
>
>  --
> 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 this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: paredit+regex question

2014-03-05 Thread Phillip Lord
Erlis Vidal  writes:
> @Phillip: Wow! I'm wondering why paredit doesn't fix this issue. Thanks for
> the patch!


Because this syntax is specific to clojure and not all lisps!

Hopefully, I'll get around to submitting a patch to paredit at some
point. If not me, I am sure someone will do it!

Phil

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


fn and let are special forms or macros?

2014-03-05 Thread Plínio Balduino
Hi there

Clojure.org says fn and let are special forms, but using the macro
sourceshows that both are macros calling
fn* and let* respectivelly.

So fn and let are "special special forms", or clojure.org is
incorrect/outdated?

If fn and let are really special forms and not macros, could you explain
why?

Thank you

Plínio

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: fn and let are special forms or macros?

2014-03-05 Thread Tassilo Horn
Plínio Balduino  writes:

Hi Plínio,

> Clojure.org says fn and let are special forms, but using the macro
> sourceshows that both are macros calling fn* and let* respectivelly.
>
> So fn and let are "special special forms", or clojure.org is
> incorrect/outdated?

Well, they are correct from a user's point of view.  One never uses the
real special forms fn* and let*.

> If fn and let are really special forms and not macros, could you
> explain why?

fn and let (and also loop) are macros around the real special forms fn*
and let* (and loop*) that add support for destructuring.  For example,

(let [[a b] [1 2]]
  (+ a b))

expands to

(let*
  [vec__8592 [1 2]
   a (clojure.core/nth vec__8592 0 nil)
   b (clojure.core/nth vec__8592 1 nil)]
  (+ a b))

where the destructuring has been transformed to "normal" code already.

Bye,
Tassilo

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN] Clojure 1.6.0-beta2

2014-03-05 Thread Alex Miller
I have not heard of any regressions or other critical issues with beta2. If 
you know of anything, please let me know asap - we plan to release RC1 soon.

Alex


On Thursday, February 27, 2014 4:39:28 PM UTC-6, Alex Miller wrote:
>
> That first line should be 1.6.0-beta2 of course. :) 
>
> On Thursday, February 27, 2014 5:37:15 PM UTC-5, Alex Miller wrote:
>>
>> Clojure 1.6.0-beta1 is now available. 
>>  
>> Try it via 
>> - Download: 
>> http://central.maven.org/maven2/org/clojure/clojure/1.6.0-beta2
>> - Leiningen: [org.clojure/clojure "1.6.0-beta2"]
>>
>> See the full change log here:
>> https://github.com/clojure/clojure/blob/master/changes.md
>>
>> Clojure 1.6.0-beta2 has the following changes from 1.6.0-beta1:
>>
>> - [CLJ-1355] Restore hashCode for Symbol and Keyword (regression from 
>> hashing changes)
>> - [CLJ-1363] Reflective .- should return field if field and method both 
>> exist
>> - [CLJ-1354] Make APersistentVector.SubVector public 
>> - Move loop locals into same clearing context as loop body (makes local 
>> clearing earlier on loop vars in some cases)
>> - [CLJ-1352] Fix regression in running test fixtures introduced in CLJ-866
>>
>> Please give it a try and let us know your feedback!
>> 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 moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Accumulate results without state?

2014-03-05 Thread Dean Laskin
I rewrote it using reduce as Jarrod suggested. It looks good to my newbie 
eyes now, but I'm interested in any other feedback.

(defn failures [file]
  (with-open [rdr (clojure.java.io/reader file)]
(reduce 
  (fn [accu input] 
(if (re-matches #"^[^,]+,[^,]+,FAIL,.*$" input)
  (conj accu (second (string/split input #",")))
   accu)) 
[]
(line-seq rdr


Dean

On Tuesday, March 4, 2014 4:21:47 PM UTC-5, Dean Laskin wrote:
>
> I'm comparing two large files based on specific fields in the files. Is 
> there a functional way of accumulating the results without atoms? (And 
> since I'm a newbie, any other advice is appreciated!)
>
> (let [sun (atom []) fri (atom [])]
>   (with-open [rdr (clojure.java.io/reader "/dev/errors-sunday.csv")]
> (doseq [line (line-seq rdr)]
>   (when (re-matches #"^[^,]+,[^,]+,FAIL,.*$" line)
> (swap! sun conj (nth (string/split line #",") 1)
>   (with-open [rdr (clojure.java.io/reader "/dev/errors-friday.csv")]
> (doseq [line (line-seq rdr)]
>   (when (re-matches #"^[^,]+,[^,]+,FAIL,.*$" line)
> (swap! fri conj (nth (string/split line #",") 1)
>   (println (nth (data/diff (set @fri) (set @sun)) 1))
>   )
>
> Thanks,
> Dean
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN] Clojure 1.6.0-beta2

2014-03-05 Thread Sean Corfield
We've been running our (World Singles) test suite against 1.6.0-master-SNAPSHOT 
for some time as a matter of course and haven't tripped over anything so far 
(that I can recall). The only change in our bugbase due to 1.6.0 was the 
earlier change to disallow keyword literals that start with a digit (which I 
believe was reverted?).

CongoMongo had a test failure (due to the hashing changes?). It was a 
suspicious test that was relying on the sequence ordering of iterating over a 
set so I just fixed the test.

Sean

On Mar 5, 2014, at 8:17 AM, Alex Miller  wrote:
> I have not heard of any regressions or other critical issues with beta2. If 
> you know of anything, please let me know asap - we plan to release RC1 soon.
> 
> Alex
> 
> 
> On Thursday, February 27, 2014 4:39:28 PM UTC-6, Alex Miller wrote:
> That first line should be 1.6.0-beta2 of course. :) 
> 
> On Thursday, February 27, 2014 5:37:15 PM UTC-5, Alex Miller wrote:
> Clojure 1.6.0-beta1 is now available. 
>  
> Try it via 
> - Download: http://central.maven.org/maven2/org/clojure/clojure/1.6.0-beta2
> - Leiningen: [org.clojure/clojure "1.6.0-beta2"]
> 
> See the full change log here:
> https://github.com/clojure/clojure/blob/master/changes.md
> 
> Clojure 1.6.0-beta2 has the following changes from 1.6.0-beta1:
> 
> - [CLJ-1355] Restore hashCode for Symbol and Keyword (regression from hashing 
> changes)
> - [CLJ-1363] Reflective .- should return field if field and method both exist
> - [CLJ-1354] Make APersistentVector.SubVector public 
> - Move loop locals into same clearing context as loop body (makes local 
> clearing earlier on loop vars in some cases)
> - [CLJ-1352] Fix regression in running test fixtures introduced in CLJ-866
> 
> Please give it a try and let us know your feedback!
> Alex 





signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: How to replace code inside a macro

2014-03-05 Thread milinda
Thanks Konrad. Your unquoting trick worked. But I am not exactly sure how 
to reason about these types of situations. Can you please shed some lights 
behind the logic of above unquoting if possible.

Thanks
Milinda

On Wednesday, March 5, 2014 8:33:03 AM UTC-5, Konrad Hinsen wrote:
>
> --On 4 Mar 2014 23:07:27 -0800 milinda > 
> wrote: 
>
> > I wanted macro to work like following. 
> > 
> > 
> > ( (let [x 10] (+ x (defpop 
> > 
> > 
> > This should generate function like 
> > 
> > 
> > (defn execute [tu3455] (let [x 10] (+ x tu3455))) 
>
> Try this: 
>
>   (defmacro  [body] 
> `(macrolet [(~'defpop [] 'tu#)] (defn execute [tu#] ~body))) 
>
> In action: 
>
>   user=> (macroexpand-1 '( (let [x 10] (+ x (defpop) 
>   (clojure.tools.macro/macrolet [(defpop [] (quote tu__818__auto__))] 
> (clojure.core/defn user/execute [tu__818__auto__] (let [x 10] (+ x 
> (defpop) 
>
>   user=> (macroexpand '( (let [x 10] (+ x (defpop) 
>   (do (def user/execute (fn* ([tu__818__auto__] (let* [x 10] (+ x 
> tu__818__auto__)) 
>
>
> Konrad. 
>
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN] Clojure 1.6.0-beta2

2014-03-05 Thread Michael Klishin
2014-03-05 21:47 GMT+04:00 Sean Corfield :

> We've been running our (World Singles) test suite against
> 1.6.0-master-SNAPSHOT for some time as a matter of course and haven't
> tripped over anything so far (that I can recall). The only change in our
> bugbase due to 1.6.0 was the earlier change to disallow keyword literals
> that start with a digit (which I believe was reverted?).
>
> CongoMongo had a test failure (due to the hashing changes?). It was a
> suspicious test that was relying on the sequence ordering of iterating over
> a set so I just fixed the test.
>

All or nearly all ClojureWerkz projects test against 1.6.0-beta2 and
master. Most order dependent
tests fail with 1.6, and sometimes it is annoying (e.g. JSON generation
tests that compare strings).

Nothing that I'd consider a Clojure bug, though.
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[ANN] PigPen 0.2.0

2014-03-05 Thread Matt Bossenbroek
Announcing PigPen 0.2.0!

https://github.com/Netflix/PigPen

PigPen is map-reduce for Clojure, or distributed Clojure. Write idiomatic 
Clojure code and run it on thousands of machines.

New in 0.2.0:
 * Brand new wiki: https://github.com/Netflix/PigPen/wiki
 * Performance improvements!
 * Fold: https://github.com/Netflix/PigPen/wiki/Folding-Data
   - similar to 
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/reducers.clj#L84
 * Better support for closures: 
https://github.com/Netflix/PigPen/wiki/Closures

Come see my talk at clojure/west: 
http://www.clojurewest.org/speakers/matt-bossenbroek

Questions & Complaints: pigpen-supp...@googlegroups.com

PigPen does use Apache Pig, but it uses it as a host language, similar to 
how Clojure uses the JVM. It's not a Clojure wrapper for writing Pig 
scripts.

Enjoy!

-Matt

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: finding value nearest x

2014-03-05 Thread Yehonathan Sharvit
In the sorted-set solution, you forgot to handle the case where all the 
values in the sorted-set are greater than 136...

On Saturday, 25 September 2010 17:55:33 UTC+2, Chouser wrote:
>
> On Sat, Sep 25, 2010 at 10:44 AM, Nicolas Oury 
> > 
> wrote:
> > On Sat, Sep 25, 2010 at 3:40 PM, Jules > 
> wrote:
> >> Maybe this: (min-key #(abs (- % 136)) xs)
> >>
> > Wouldn't that be (apply min-key #(abs (- % 136)) xs)?
>
> Where's your 'abs' function coming from?  This works for me:
>
> (apply min-key #(Math/abs (- % 136)) xs)
>
> Or if you want something slower when building the collection but
> faster when looking it up, you can use a sorted set:
>
> (let [ss (sorted-set 1 2 134 139 4),
>   asc (subseq ss >= 136),
>   desc (rsubseq ss <= 136)]
>   (min-key #(Math/abs (- % 136)) (first asc) (first desc)))
>
> That's O(log n) instead the simpler (apply min-key ...) which is O(n).
>
> --Chouser
> http://joyofclojure.com/
>
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [GSoC]: How to participate

2014-03-05 Thread cej38
Any of these projects would be a welcome addition to the Clojure world, but 
I personally hope that the Linear Algebra project is worked on and that it 
uses NDArray from last year as the starting point.

Congratulations on being picked as a host community again.  I am excited to 
see what comes out of this summer's group of projects.


On Tuesday, February 25, 2014 9:25:34 AM UTC-5, Daniel Solano Gómez wrote:
>
>
> [4]: http://dev.clojure.org/display/community/Project+Ideas 
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Any Previous Work on Javadoc to Docstring Conversion?

2014-03-05 Thread ian.tegebo
I'm interested in converting javadoc to docstrings in cases like 
"amazonica" where clojure code is created by reflecting on java classes. 
 Unless I missed something, the status quo has us referring to the original 
Javadoc via web browser.  One then needs to understand enough of the 
conversion to clojure to know which argument is which and whether the 
original documentation still applies.  Granted, this is usually pretty 
straightforward but it still costs some time.  Also, converting javadoc to 
docstrings would probably be useful for general java interop.

Anyway, before I start hacking I thought I'd ask if anyone knows of 
existing work I didn't find by googling and searching clojars.  My current 
understanding is that the java source would need to be processed by 
`javadoc` using a doclet so that one can more easily work with the data, 
cf. the following for JSON:

https://github.com/dexy/dexy-doclet

You'd probably want to do that once as an early build step and then use the 
data later (leiningen plugin?).  Lastly, I recognize that I'd still want 
arglist metadata for the generated clojure functions, e.g. so Emacs' eldoc 
can show something useful.  There appear to be options for that case:

http://stackoverflow.com/questions/2237803/can-i-obtain-method-parameter-name-using-java-reflection

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Solving allocation problems; code review and core.logic

2014-03-05 Thread Alex Engelberg
I released a library yesterday called Loco, 
which might be what you're looking for. (David mentioned JaCoP, which is 
very similar to the Java library that Loco runs on.) You might also want to 
check out this blog 
post,
 
which gives an example of an optimization problem written in Loco.

I'd be happy to give you some advice about Loco programming if I could 
better understand the data representing your problem that you need to 
express, and what you're trying to optimize.

--Alex

On Wednesday, March 5, 2014 6:52:34 AM UTC-8, Laurens Van Houtven wrote:
>
> Hi!
>
>
> I've been experimenting solving some real-world problems related to
> organizing a sizable (2000-3000 people) programming conference with a
> strong open source flavor.
>
> My next problem is a bit more daunting.
>
> This conference has a financial aid program. People who can not afford
> to come to the conference are given grants that have to come out of a
> budget. The budget is much smaller than the sum of all requested
> grants, so it turns into an underspecified optimization problem. In
> order to make that issue slightly less bad, there's a score function
> so that we can bias in favor of certain people, e.g. speakers.
>
> I'm convinced the optimal solution, even assuming it exists, is
> impossible to find. The data is incomplete; it is not necessarily true
> that because you assign less than what people have requested that they
> won't accept the grant.
>
> I wrote an implementation that plausibly matches the above:
>
> https://github.com/lvh/hood/blob/master/src/hood/core.clj
>
> I'm sure that that code has a lot of flaws. I haven't really played
> with it enough yet. Code review on that is very welcome. Any
> suggestions for a cleverer allocation algorithm would also be much
> appreciated.
>
> That said, I really sent this e-mail because I was wondering to what
> extent core.logic could be applied to this problem. The "running your
> program in reverse" concept is potentially interesting here; I'm
> hoping that we could get answers to questions like "what would an
> application have to look like to get X dollars under our budget?"
>
> I seriously don't even know where to start. What would the logic
> variables be? It seems that a lot of the example code uses a single
> logic variable and then "structures" it in the let body; but I have no
> idea what that one variable would even mean.
>
> Perhaps I should just tackle some simpler logic programs first :-)
>
> Thanks in advance for your thoughts and comments!
> lvh
>
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Clojure performance question

2014-03-05 Thread Jarrod Swart
Thanks for the elaboration, I just wanted to make sure I understood.

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Solving allocation problems; code review and core.logic

2014-03-05 Thread Laurens Van Houtven
Hi David and Alex,


Thanks for your replies! I'm having trouble communicating it, and the
underspecifiedness doesn't help. Perhaps that just means I don't
really understand the problem. Please let me know if any particular
parts are hazy.

What we *really* care about is getting people to the conference that
otherwise wouldn't. If we have to pick between people with a high
score (say, a speaker who is also a student) and someone with a low
score (someone who doesn't really appear to be very serious about
attending let alone contributing), we'd pick the high scoring person.

When I say score, it's one of the functions in the source file I
linked. Think scalar product; it's a weight vector times ((apply comp
fs) person). I'm flexible as to what that score looks like, but it'd
be nice if there are tweakable values that map directly to real-life
concepts; e.g. I can tell that we're valuing open source contributions
twice as heavily as studenthood.

I'm having trouble conveying more details without having to explain it
in terms of one particular model. Since I've done integer programming
and constraint programming before, I'll do that. Please don't
interpret that as a bias against core.logic and its ilk :-)

Since we're optimizing for attendance weighted by score, we're
minimizing the sum of (* -1 score) of all the people not attending,
subject to the sum of scores of all the people that *are* attending
being less than or equal to the budget.

That actually sounds like something that shouldn't be too hard to dump
into a constraint solver. Perhaps I'll play with Loco tomorrow (it's
late here) and compare the results.

David: does the above clarify somewhat? Would sample data help?

Thanks again!
lvh

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


1.6.0-beta2 / sumatra / graal / okra / hsa / gpgpu

2014-03-05 Thread Jules
Guys,

I had to try building and running the Sumatra/Java8 stack - this claims to 
be able to JIT Java8 closures into HSAIL (from memory: Heterogeneous 
Architecture Independent Language), which can then either be run on an 
HSAIL emulator (in this case Okra) or, if you have HSA enabled h/w (which 
is not expensive), compiled by a "finalizer" onto  a target GPGPU on chip 
with your CPU and sharing the same memory model. We are talking about e.g. 
512 cores running at about 25% of the speed of your CPU cores (AMD's 
A10 7850K). Sound like fun ?

I followed the instructions here:

https://wiki.openjdk.java.net/display/Sumatra/Sumatra+JDK+build+instructions

Of course, then I thought I should see whether I could get a simple piece 
of Clojure to run on the emulator.

You will need to read up a bit on Graal to follow this fully - all it does 
is to copy the contents of an input array into an output array - but the 
ramifications of its working are substantial:

(ns seqspert.core
  (:import
   [com.oracle.graal.hsail HSAIL]
   [com.oracle.graal.hotspot HotSpotGraalRuntime]
   [com.oracle.graal.hotspot.hsail HSAILHotSpotBackend]
   [com.amd.okra OkraContext OkraKernel]
   ))

;;--

(set! *warn-on-reflection* true)

;;--

(definterface Kernel (^void invoke [^int i]))

(defn ^String hsa-compile [^Kernel kernel]
  (let [method (.getDeclaredMethod (class kernel) "invoke" (into-array 
^Class [(Integer/TYPE)]))
^HSAILHotSpotBackend backend (.getBackend 
(HotSpotGraalRuntime/runtime) HSAIL)
resolved (.lookupJavaMethod (.getMetaAccess (.getProviders 
backend)) method)]
(.getCodeString (.compileKernel backend resolved false

(defn ^OkraKernel apply-int-kernel [kernel i & args]
  (let [^OkraContext context (OkraContext.)]
(doto (OkraKernel. (doto context (.setVerbose true)) (hsa-compile 
kernel) "&run")
  (.setLaunchAttributes (int i))
  (.dispatchWithArgs (into-array Object (conj args kernel
(.dispose context)))

(let [n 32
  in (int-array (range n))
  out (int-array n)]
  (println "INPUT: " (into [] in))
  (println "BEFORE:" (into [] out))
  (apply-int-kernel
   (reify Kernel (^void invoke [^Kernel self ^int i] (aset out i (aget in 
i
   n)
  (println "AFTER: " (into [] out)))
 
and here is the output:

INPUT:  [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 
25 26 27 28 29 30 31]
BEFORE: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
Fixed Hsail is
==
version 0:95: $full : $large; 
// instance method HotSpotMethod 
kernel &run ( 
align 8 kernarg_u64 %_this
) {
ld_kernarg_u64  $d0, [%_this];
workitemabsid_u32 $s0, 0;
   
@L0:
ld_global_u32 $d1, [$d0 + 16];
cmp_eq_b1_u64 $c0, $d1, 0; // null test 
cbr $c0, @L1;
@L2:
ld_global_u32 $d0, [$d0 + 20];
cmp_eq_b1_u64 $c0, $d0, 0; // null test 
cbr $c0, @L3;
@L4:
mov_b64 $d2, 0x10b08;
cmp_eq_b1_u64 $c0, $d0, 0; // null test 
cbr $c0, @L5;
@L6:
ld_global_u32 $d3, [$d0 + 8];
shl_u64 $d3, $d3, 3;
cmp_eq_b1_s64 $c0, $d3, $d2;
cbr $c0, @L7;
@L8:
mov_b32 $s1, 0;
@L9:
cmp_eq_b1_u64 $c0, $d0, 0; // null test 
cbr $c0, @L14;
@L11:
cmp_ne_b1_s32 $c0, $s1, 1;
cbr $c0, @L32;
@L14:
ld_global_s32 $s1, [$d0 + 12];
cmp_ge_b1_u32 $c0, $s0, $s1;
cbr $c0, @L31;
@L15:
cmp_eq_b1_u64 $c0, $d1, 0; // null test 
cbr $c0, @L16;
@L17:
ld_global_u32 $d3, [$d1 + 8];
shl_u64 $d3, $d3, 3;
cmp_eq_b1_s64 $c0, $d3, $d2;
cbr $c0, @L18;
@L19:
mov_b32 $s1, 0;
@L20:
cmp_eq_b1_u64 $c0, $d1, 0; // null test 
cbr $c0, @L25;
@L22:
cmp_ne_b1_s32 $c0, $s1, 1;
cbr $c0, @L30;
@L25:
ld_global_s32 $s1, [$d1 + 12];
cmp_ge_b1_u32 $c0, $s0, $s1;
cbr $c0, @L29;
@L26:
ld_global_s32 $s1, [$d1 + 12];
cmp_ge_b1_u32 $c0, $s0, $s1;
cbr $c0, @L28;
@L27:
cvt_s64_s32 $d2, $s0;
mul_s64 $d2, $d2, 4;
add_u64 $d0, $d0, $d2;
ld_global_s32 $s1, [$d0 + 16];
cvt_s64_s32 $d0, $s0;
mul_s64 $d0, $d0, 4;
add_u64 $d1, $d1, $d0;
st_global_s32 $s1, [$d1 + 16];
ret;
@L7:
mov_b32 $s1, 1;
brn @L9;
@L18:
mov_b32 $s1, 1;
brn @L20;
@L5:
mov_b32 $s1, 0;
brn @L9;
@L16:
mov_b32 $s1, 0;
brn @L20;
@L1:
mov_b32 $s0, -11;
@L33:
ret;
@L31:
mov_b32 $s0, -27;
brn @L33;
@L32:
mov_b32 $s0, -35;
brn @L33;
@L3:
mov_b32 $s0, -11;
brn @L33;
@L28:
mov_b32 $s0, -27;
brn @L33;
@L30:
mov_b32 $s0, -35;
brn @L33;
@L29:
mov_b32 $s0, -92;
brn @L33;
}; 

spawning Program: hsailasm temp_hsa.hsail -g -o temp_hsa.o
hsailasm succeeded
createProgram succeeded
createKernel succeeded
level 0, grid=32, group=1
pushPointerArg, addr=0
setPointerArg, addr=0xf5529930
AFTER:  [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 
25 26 27 28 29 30 31]

I tried doing a little maths on the value on the way through, but that did 
not work :-(

Too tired to say much more now - but will pick this up tomorrow and play 
some more.

Please let me know if you are interested - I will start checking in code

Re: Solving allocation problems; code review and core.logic

2014-03-05 Thread Jordan Berg
Sounds like you might be able to model it as a knapsack problem with
budgets as weights and scores as values.

For a little intuition into what will happen, consider a greedy
algorithm to solve the knapsack.  Assuming that the individual budgets
are relatively small compared to the total budget the real solution
should be close to the greedy solutiuon, which is sorting all items by
value over weight and taking all the items with the highest ratio
first.

Cheers,

Jordan

On Wed, Mar 5, 2014 at 2:36 PM, Laurens Van Houtven <_...@lvh.cc> wrote:
> Hi David and Alex,
>
>
> Thanks for your replies! I'm having trouble communicating it, and the
> underspecifiedness doesn't help. Perhaps that just means I don't
> really understand the problem. Please let me know if any particular
> parts are hazy.
>
> What we *really* care about is getting people to the conference that
> otherwise wouldn't. If we have to pick between people with a high
> score (say, a speaker who is also a student) and someone with a low
> score (someone who doesn't really appear to be very serious about
> attending let alone contributing), we'd pick the high scoring person.
>
> When I say score, it's one of the functions in the source file I
> linked. Think scalar product; it's a weight vector times ((apply comp
> fs) person). I'm flexible as to what that score looks like, but it'd
> be nice if there are tweakable values that map directly to real-life
> concepts; e.g. I can tell that we're valuing open source contributions
> twice as heavily as studenthood.
>
> I'm having trouble conveying more details without having to explain it
> in terms of one particular model. Since I've done integer programming
> and constraint programming before, I'll do that. Please don't
> interpret that as a bias against core.logic and its ilk :-)
>
> Since we're optimizing for attendance weighted by score, we're
> minimizing the sum of (* -1 score) of all the people not attending,
> subject to the sum of scores of all the people that *are* attending
> being less than or equal to the budget.
>
> That actually sounds like something that shouldn't be too hard to dump
> into a constraint solver. Perhaps I'll play with Loco tomorrow (it's
> late here) and compare the results.
>
> David: does the above clarify somewhat? Would sample data help?
>
> Thanks again!
> lvh
>
> --
> 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 this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Solving allocation problems; code review and core.logic

2014-03-05 Thread Mark Engelberg
The potential problem with modeling it as a knapsack problem is that it
assumes that grant-giving is an all-or-nothing affair.

Another reasonable way to model it is to assume that if I'm given, say $80
out of $100 requested, then I have an 80% chance of going.  With such a
model, let's say I have a score of 5 and a grant request of $100.  Then, if
I'm granted $100, I contribute 5 points of goodness to the overall value
I'm optimizing.  So $1 allocated to me contributes 0.05 points of expected
goodness to the overall value.

Here's a gist, illustrating how to do this in Loco:
https://gist.github.com/Engelberg/9379157

--Mark



On Wed, Mar 5, 2014 at 3:22 PM, Jordan Berg wrote:

> Sounds like you might be able to model it as a knapsack problem with
> budgets as weights and scores as values.
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Solving allocation problems; code review and core.logic

2014-03-05 Thread Mark Engelberg
Overall, though, I agree with Jordan's point.  You don't really need any
sophisticated constraint solving to solve the problem as you've described
it -- the greedy approach works fine in this context.  Simply sort all the
applicants in descending order by score divided by amount of money
requested, and dole the money out in that order.


On Wed, Mar 5, 2014 at 3:54 PM, Mark Engelberg wrote:

> The potential problem with modeling it as a knapsack problem is that it
> assumes that grant-giving is an all-or-nothing affair.
>
> Another reasonable way to model it is to assume that if I'm given, say $80
> out of $100 requested, then I have an 80% chance of going.  With such a
> model, let's say I have a score of 5 and a grant request of $100.  Then, if
> I'm granted $100, I contribute 5 points of goodness to the overall value
> I'm optimizing.  So $1 allocated to me contributes 0.05 points of expected
> goodness to the overall value.
>
> Here's a gist, illustrating how to do this in Loco:
> https://gist.github.com/Engelberg/9379157
>
> --Mark
>
>
>
>
> On Wed, Mar 5, 2014 at 3:22 PM, Jordan Berg wrote:
>
>> Sounds like you might be able to model it as a knapsack problem with
>> budgets as weights and scores as values.
>>
>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to replace code inside a macro

2014-03-05 Thread curiousGuy
Milinda if you are asking about the ~' that simply allows you to quote a 
symbol without the namespace resolution that a backquote ` provides. If you 
are trying to capture a local lexical value or otherwise do not want the 
full namespace resolved for the symbol, then you must use an ordinary quote 
on the symbol since part of the job of a backquote is to provide the 
namespace resolution.

On Thursday, March 6, 2014 1:37:24 AM UTC+8, milinda wrote:
>
> Thanks Konrad. Your unquoting trick worked. But I am not exactly sure how 
> to reason about these types of situations. Can you please shed some lights 
> behind the logic of above unquoting if possible.
>
> Thanks
> Milinda
>
> On Wednesday, March 5, 2014 8:33:03 AM UTC-5, Konrad Hinsen wrote:
>>
>> --On 4 Mar 2014 23:07:27 -0800 milinda  wrote: 
>>
>> > I wanted macro to work like following. 
>> > 
>> > 
>> > ( (let [x 10] (+ x (defpop 
>> > 
>> > 
>> > This should generate function like 
>> > 
>> > 
>> > (defn execute [tu3455] (let [x 10] (+ x tu3455))) 
>>
>> Try this: 
>>
>>   (defmacro  [body] 
>> `(macrolet [(~'defpop [] 'tu#)] (defn execute [tu#] ~body))) 
>>
>> In action: 
>>
>>   user=> (macroexpand-1 '( (let [x 10] (+ x (defpop) 
>>   (clojure.tools.macro/macrolet [(defpop [] (quote tu__818__auto__))] 
>> (clojure.core/defn user/execute [tu__818__auto__] (let [x 10] (+ x 
>> (defpop) 
>>
>>   user=> (macroexpand '( (let [x 10] (+ x (defpop) 
>>   (do (def user/execute (fn* ([tu__818__auto__] (let* [x 10] (+ x 
>> tu__818__auto__)) 
>>
>>
>> Konrad. 
>>
>>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[ANN] New Caribou Release: Version 0.14.0

2014-03-05 Thread Ryan Spangler
Hello Clojure People,

Happy to announce the release of a new version of Caribou!  
http://let-caribou.in/

There are a lot of improvements in this latest release.  We have tried to 
incorporate all of the feedback we have received since its initial release 
(which has been massive!).  A small selection of the improvements:

* *Heroku support fully integrated.*  This turned out to be a big deal for 
a lot of people, and there were some hoops to jump through before getting a 
database set up.  I am happy to say this has been vastly streamlined and 
improved, as well as fully documenting the process from provision to 
deploy: http://caribou.github.io/caribou/docs/deploying.html (at the bottom 
of that page).

* *Routing streamlined and simplified.  *We had this split into two steps 
before, but it is way simpler now.  Also fixed a couple issues people were 
having with HTTP methods in nested routes.  Polaris is also now fully 
integrated:  https://github.com/caribou/polaris

* *Immutant removed as a direct dependency.*  A lot of people complained 
about having to download all of Immutant even if they weren't using it! 
 This is no longer necessary, as you can now deploy to Immutant with 
options directly in your project.clj without ever making it a dependency of 
your project.

* *Templating engine can be swapped out for anything.*  You can now use 
whatever you want for templating, including Selmer:  
https://github.com/yogthos/Selmer  (yogthos himself contributed this pull 
request!)  Check out the bottom of this page for more details:  
http://caribou.github.io/caribou/docs/templates.html

And many more (check out the docs for a full list of features: 
http://caribou.github.io/caribou/docs/outline.html ).  

As there were a lot of changes (not all of them backwards compatible), we 
made a guide for upgrading Caribou to the latest version if you already 
have an instance running somewhere:

  http://caribou.github.io/caribou/docs/upgrading.html !

Hopefully that will help out for anyone has a Caribou site under 
development (let us know if anything comes up!)

Thanks to everyone who contributed feedback, issues and pull requests, and 
thanks to everyone who is using it to build awesome things.  We are working 
hard to make it as useful as possible, and having real world feedback has 
been invaluable to that cause.  

Lastly, check out the roadmap for the direction we are going:  
http://caribou.github.io/caribou/docs/roadmap.html  (Spoiler:  we got a UX 
person!)

We are open to any and all feedback on this or anything else!  Thanks again.

- Caribou Team

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Clojure on top of ObjC?

2014-03-05 Thread D. Theisen
Hey, Nathan!

Am Montag, 6. Mai 2013 07:15:34 UTC+2 schrieb Nathan Sorenson:
>
>
> On Tuesday, 23 April 2013 13:37:59 UTC-7, Steven Degutis wrote:
>>
>> While this is certainly neat, it doesn't allow Clojure to be used as 
>> an embedded scripting language inside an ObjC app. 
>>
>
> Since the Clojure/West talk I've been busy trying to get clojure-scheme 
> self-hosted. I've been a week or so away from this working for a few weeks 
> now :) But Clojure macros, the analysis pass, and the compiler are all 
> self-hosted. There's a little bit more to do on the reader's interaction 
> with syntax-quote, but once that's done we should have a real Clojure repl 
> running on the iPhone.
>

 Did you find the week of time or was the problem harder than thought?
That would (to my knowledge) be the first self-hosted Clojure-Compiler!

Gogogo! :-)

Dirk 

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Any Previous Work on Javadoc to Docstring Conversion?

2014-03-05 Thread Tobias Kortkamp
I have just uploaded some code I wrote earlier this year, where I 
originally set out to generate some useful docstrings for Java classes and 
methods.
It currently uses javadoc on all Java source files on the classpath and 
creates a map with the extracted information. I never finished it, but
this may still be useful to you :)

Check it out here: 
https://bitbucket.org/tobik/nrepl-javadoc/src/cdbfe0873ef04ee583a39f0538610daf289eff42/src/tobik/nrepl/tools.clj?at=master#cl-343
 


-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to replace code inside a macro

2014-03-05 Thread Leif

Hi, Milinda.  I'll try to explain my reasoning of the situation.  I always 
find it helpful to macroexpand if I'm having trouble:

;; original version
user=> (macroexpand-1 '( boby))
(clojure.tools.macro/macrolet [(defpop [] tu1282)]  ;; <- undef. lookup
  (clojure.core/defn user/execute [tu1282] boby))

;; Konrad's version
user=> (macroexpand-1 '(-kh body))
(clojure.tools.macro/macrolet [(defpop [] (quote tu__1294__auto__))] ;; <-
  (clojure.core/defn user/execute [tu__1294__auto__] body))

So, I think what is happening here is that the 'defpop' macro defined by 
macrolet needs to return a piece of code (like all macros).  Konrad's 
version returns a symbol, so that's fine.

But the original version is trying to look up the piece of code stored in 
the var tu1282 and return it.  But that variable doesn't exist, so you get 
the CompilerException.  Here is a slight modification of your original that 
explicitly does what Konrad did with auto-gensyms:

(defmacro 3 [body]
  (let [x (gensym 'tu)
defpop-decl (list 'defpop [] (list 'quote x))] ;; <- return the 
quoted symbol, no lookup
  `(macrolet [~defpop-decl]
(defn execute [~x] ~body

Hope that helps,
Leif

On Wednesday, March 5, 2014 12:37:24 PM UTC-5, milinda wrote:
>
> Thanks Konrad. Your unquoting trick worked. But I am not exactly sure how 
> to reason about these types of situations. Can you please shed some lights 
> behind the logic of above unquoting if possible.
>
> Thanks
> Milinda
>
> On Wednesday, March 5, 2014 8:33:03 AM UTC-5, Konrad Hinsen wrote:
>>
>> --On 4 Mar 2014 23:07:27 -0800 milinda  wrote: 
>>
>> > I wanted macro to work like following. 
>> > 
>> > 
>> > ( (let [x 10] (+ x (defpop 
>> > 
>> > 
>> > This should generate function like 
>> > 
>> > 
>> > (defn execute [tu3455] (let [x 10] (+ x tu3455))) 
>>
>> Try this: 
>>
>>   (defmacro  [body] 
>> `(macrolet [(~'defpop [] 'tu#)] (defn execute [tu#] ~body))) 
>>
>> In action: 
>>
>>   user=> (macroexpand-1 '( (let [x 10] (+ x (defpop) 
>>   (clojure.tools.macro/macrolet [(defpop [] (quote tu__818__auto__))] 
>> (clojure.core/defn user/execute [tu__818__auto__] (let [x 10] (+ x 
>> (defpop) 
>>
>>   user=> (macroexpand '( (let [x 10] (+ x (defpop) 
>>   (do (def user/execute (fn* ([tu__818__auto__] (let* [x 10] (+ x 
>> tu__818__auto__)) 
>>
>>
>> Konrad. 
>>
>>

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.