Re: Translating from Prolog to core.logic

2012-07-28 Thread JvJ
Alright, that makes sense.  I suppose that since facts are represented 
under the hood as relations, anyways, that this might work.  Thanks.

On Saturday, 28 July 2012 21:52:46 UTC-4, David Nolen wrote:
>
> On Sat, Jul 28, 2012 at 8:53 PM, JvJ  wrote: 
> > I'm having trouble translating some Prolog code to core.logic. 
> > 
> > In particular, I'd like to do something like this: 
> > 
> >> 2 ?- assert(a(b)). 
> >> true. 
> >> 3 ?- assert(a(a(b))). 
> >> true. 
> >> 4 ?- a(X). 
> >> X = b ; 
> >> X = a(b). 
> >> 5 ?- a(a(X)). 
> >> X = b. 
>
> While there is no direct translation as far as I can see, something 
> like the following accomplishes pretty much the same thing: 
>
> (defne foo [x] 
>   ([[:a :b]]) 
>   ([[:a [:a :b]]])) 
>
> (run* [q] 
>   (foo [:a q])) 
> ;; => (:b [:a :b]) 
>

-- 
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

Re: community interest in machine learning (?)

2012-07-28 Thread Lee Spector

Thanks Cameron,

I've tried again and indeed it does work now. Thanks so much,

 -Lee


On Jul 26, 2012, at 6:52 PM, cameron wrote:

> Hi Lee,
>apologies for the missing dependencies, it's been a while since I worked 
> on the project and I had local copies of jscheme in .m2. The documentation 
> has been fixed and I've updated the dependencies.
> 
> I've run the samples a built a fresh checkout  on a clean machine so I think 
> you should be ok now though I did have to delete ~/.m2 in one case.
> 
> Let me know if you have any problems.
> 
> Cheers,
>Cameron.

--
Lee Spector, Professor of Computer Science
Cognitive Science, Hampshire College
893 West Street, Amherst, MA 01002-3359
lspec...@hampshire.edu, http://hampshire.edu/lspector/
Phone: 413-559-5352, Fax: 413-559-5438

-- 
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


Re: Why is EMPTY.withMeta(meta()) used instead of just EMPTY in clojure.lang.*?

2012-07-28 Thread Timothy Baldridge
On Sat, Jul 28, 2012 at 7:47 AM, Per Mildner
wrote:

> Looking at the persistent types  in clojure.lang.* (PersistentVector.java
> et al.) I see several occurrences of the idiom EMPTY.withMeta(meta()) where
> EMPTY is a constant (static final) denoting an empty collection of the
> appropriate type.
>
> What I can not understand, given that these types are all persistent, is
> why the EMPTY constant is, in effect, copied at most places where it is
> used. Why not use the same EMPTY instance instead, i.e.
> replace EMPTY.withMeta(meta()) with just EMPTY. Unless I miss something
> this could not hurt and would save some time and space.
>
>
In this context, the empty() method does not mean "get an empty of this
type", instead it means "empty this collection". So if we want to return a
new collection that looks the same, except it is empty, then we need to
pull in the metadata from the old collection.

Example:

=> (meta (empty (with-meta [1 2 3] {:foo true})))
{:foo true}


Timothy

-- 
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

Re: Translating from Prolog to core.logic

2012-07-28 Thread David Nolen
On Sat, Jul 28, 2012 at 8:53 PM, JvJ  wrote:
> I'm having trouble translating some Prolog code to core.logic.
>
> In particular, I'd like to do something like this:
>
>> 2 ?- assert(a(b)).
>> true.
>> 3 ?- assert(a(a(b))).
>> true.
>> 4 ?- a(X).
>> X = b ;
>> X = a(b).
>> 5 ?- a(a(X)).
>> X = b.

While there is no direct translation as far as I can see, something
like the following accomplishes pretty much the same thing:

(defne foo [x]
  ([[:a :b]])
  ([[:a [:a :b]]]))

(run* [q]
  (foo [:a q]))
;; => (:b [:a :b])

-- 
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


Why is EMPTY.withMeta(meta()) used instead of just EMPTY in clojure.lang.*?

2012-07-28 Thread Per Mildner
Looking at the persistent types  in clojure.lang.* (PersistentVector.java 
et al.) I see several occurrences of the idiom EMPTY.withMeta(meta()) where 
EMPTY is a constant (static final) denoting an empty collection of the 
appropriate type.

What I can not understand, given that these types are all persistent, is 
why the EMPTY constant is, in effect, copied at most places where it is 
used. Why not use the same EMPTY instance instead, i.e. 
replace EMPTY.withMeta(meta()) with just EMPTY. Unless I miss something 
this could not hurt and would save some time and space.

Regards,

-- 
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

JDBC Timezone Issue

2012-07-28 Thread Jestine Paul
Hi,

I have raised a JIRA issue (JDBC-35) regarding the timezones returned from 
the ResultSet getter method.
http://dev.clojure.org/jira/browse/JDBC-35

I have also attached a patch to this issue.
http://dev.clojure.org/jira/secure/attachment/11394/resultset-timezone.diff

Please review my patch and let me know if there is any better solution to 
this problem.

Thanks,
Jestine Paul

-- 
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

Re: Experiences developing a crowdfunding site for open source projects in Clojure (from a Python background)

2012-07-28 Thread Samrat Man Singh
I can't access your site. Also, I wanted to ask whether you used Noir or 
used a lower-level option(Compojure,etc)? 

On Friday, July 27, 2012 1:44:46 AM UTC+5:45, Aaron Lebo wrote:
>
> Hello!
>
> Sometime around 2 and a half months ago, I started to work on a new 
> project using Clojure. I've been using Python heavily for about 6 six years 
> working for a small direct mail company and before that started programming 
> with Ruby on Rails. This new project was something out of left field, so I 
> had different options on what technology to use. I ended up choosing 
> Clojure, and my work on the site has been my first real experience using a 
> lisp, Clojure, and the JVM. I'd like to share my experiences and how that 
> has differed with my previous Python work.
>
> Before that, I'd like to make a little plug for my site. It is called 
> kodefund  (www.kodefund.com). The basic idea is 
> to take the familiar Kickstarter model but to really focus on applying that 
> to open source development. I feel that previous crowdfunding efforts have 
> shown that there is an interest by developers to fund projects that they 
> are enthusiastic about. When this works, everyone wins: the developer 
> working on the project can devote their full time and effort on the actual 
> project and still make a living and others get the benefits of the open 
> source software. I feel like it is preferable over selling licenses to 
> proprietary software or other efforts.
>
> So, every project on kodefund is required to be open source. This 
> differentiates it from other crowdfunding sites, and helps to apply a 
> filter: you know what you are getting when you go there instead of seeing 
> dozens of projects for unrelated stuff. 
>
> One other difference is that you can also start a project which is more or 
> less a "reverse" Kickstarter. This allows you to take an idea for a project 
> or issue you want fixed, raise funding, and find someone who will actually 
> implement the project. Other users get to submit "applications" and you 
> choose from them to find the most capable candidate. Once you chose an 
> application, that person takes over the project.
>
> Finally, one other push I want to make is to open up proprietary software. 
> Maybe your company has written some software in-house, but there's no real 
> incentive to release it. What if you could crowdfund the software, get paid 
> to release it, and the open source community as a whole could benefit from 
> that? 
>
> I feel like crowdfunding and open source software are an ideal fit.
>
> I'm getting off track here. I'll shift to my actual experiences using 
> Clojure. I was more than a little nervous about using the JVM. It always 
> seemed like some huge, scary thing, and digging into Java libraries was not 
> something I wanted to do. Something which resolved this was leiningen. I 
> feel like it is absolutely brilliant, and it really makes adding libraries 
> to your project a non-issue. Things have slowly changed in Python, but it 
> used to be that downloading dependencies was a global process and you ended 
> up with a site-packages that was full of dozens of old libraries that you 
> used for other projects. Being able to specify in my project.clj file 
> exactly which libraries I need and those getting downloaded automatically 
> is a really nice feature that I will look for similar functionality in 
> other languages from now on.
>
> I was also pleasantly surprised by the library availability. The vast 
> majority of things that I needed such as oauth2 support and such already 
> have decent Clojure wrappers. When I did drop down into Java, I found that 
> to be painless. The JVM really does have a wide swath of functionality 
> already available. Some of the things that I ended up using were email 
> libraries, date formatting libraries, and an rss feed generator. There 
> never was a point where I felt like I was going to have to just roll things 
> by hand. Most of the hard work has been done.
>
> Considering the language itself, one of the first things I noticed (or 
> didn't) was the parentheses. I don't remember when, but they simply are a 
> non-issue after a short amount of time. One slight thing I did have a 
> problem with was that inserting a parenthesis at the wrong place could 
> completely alter the flow of code and it was not immediately obvious. This 
> is not an issue when you are closing off a line or two of expressions, but 
> when you are halfway down the page, insert a paren and everything breaks, 
> it could get frustrating. This is probably resolved through better editor 
> usage. I unfortunately could never get emacs with clojure-mode and goodies 
> working properly on my Windows machine, so I ended up using the 
> counterclockwise Eclipse plugin. It was not a horrible experience but 
> things such as auto-indenting a large block of code was something I never 
> figured out.
>
> Continuing on the surface, so

Re: Clojure Sticker

2012-07-28 Thread Benjamin Kircher
On Sat, Jul 28, 2012 at 2:05 PM, Rich Hickey  wrote:
> You can now get official Clojure stickers here:
>
> http://clojure.org/swag
>
> I'll be adding T-shirts etc soon.
>
> Rich
>
> On Jul 19, 2012, at 3:13 PM, charlie wrote:
>
>> Yeah any sort of  vector image should work for us
>>
>> On Wed, Jul 18, 2012 at 7:59 PM, Alex Kurilin  wrote:
>> +1. A temporary workaround would be getting a .svg that you could turn into 
>> stickers yourself, if that's ok with Rich. We did something similar with the 
>> vim logo on Reddit.
>>
>>
>> --
>> 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 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 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

Awesome.

-- 
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


Translating from Prolog to core.logic

2012-07-28 Thread JvJ
I'm having trouble translating some Prolog code to core.logic.

In particular, I'd like to do something like this:

2 ?- assert(a(b)).
> true.
> 3 ?- assert(a(a(b))).
> true.
> 4 ?- a(X).
> X = b ;
> X = a(b).
> 5 ?- a(a(X)).
> X = b.


However, the core.logic equivalent doesn't seem to work:

user> (fact a 1)
> nil
> user> (fact a (a 1))
> nil
> user> (run* [q]
> (a q))
> (1 # user$eval4021$fn__4022$fn__4023@9c7dc5>)
> user> (run* [q]
> (a (a q)))
> ()


Does anyone know how to represent those kinds of relations?

Thanks. 

-- 
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

Re: community interest in machine learning (?)

2012-07-28 Thread Ben Mabey

On 7/28/12 4:52 PM, Timothy Washington wrote:

Hey Jim,

Encog does look very interesting. Right now, I'm trying (and failing) 
to implement the sigmoid function. I'm using wikipedia's reference 
, and trying to 
use Incanter's (incanter/exp) function, but Incanter's function 
doesn't seem to work:


user> user> (incanter/exp -3254604.9658621363)
0.0
user> user> (incanter/exp 3254604.9658621363)
Infinity



Try this...

(use 'incanter.core)
=> (defn sigmoid [z]
  (div 1 (plus 1 (exp (minus z)
=> (sigmoid 0)
0.5
=> (sigmoid 7)
0.9990889488055994
=> (sigmoid 112)
1.0
=> (sigmoid -112)
2.285693676718672E-49


If you want the library to be fast you will want to be using primitives 
or use the underlying colt API.. for learning purposes you don't really 
need to worry about that though.


HTH,
Ben

--
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

Re: community interest in machine learning (?)

2012-07-28 Thread Timothy Washington
Hey Jim,

Encog does look very interesting. Right now, I'm trying (and failing) to
implement the sigmoid function. I'm using wikipedia's
reference,
and trying to use Incanter's (incanter/exp) function, but Incanter's
function doesn't seem to work:

user> user> (incanter/exp -3254604.9658621363)
0.0
user> user> (incanter/exp 3254604.9658621363)
Infinity


I took a peek at encog's java sigmoid
implementation,
and while my calculus is correct, they are using their own exponential
function. *i)* Is there another Incanter function I should be using?
*ii)*Maybe the number going into (incanter/exp) has to be within a
certain
range? I'm getting that *3254604.9658621363* number as a linear combination
of these inputs (i took the long value of time and randomized the weights).
*iii)* Is there a different way to sum these value? Is this where input
data massaging comes in?

  ({:key :time, :value #, :weight
0.22072475374809264}
   {:key :bid, :value 1.3239, :weight 0.5831561982324751}
   {:key :ask, :value 1.32379, :weight 0.9364679759677283}
   {:key :bvolume, :value 300.0, :weight 0.5956072849191396}
   {:key :avolume, :value 225.0, :weight 0.07837823837657176}),


There's a few other issues I'm still trying to understand. I outlined them
in this 
quant.stackexchangepost.
But primarily:

   - Algorithmically, I don't understand how to achieve both bid and ask
   predictions with each tick? the i) linear combiner and ii) activation
   functions, coupled with the bias, act to produce 1 value
   - In Back Propagation, is it just the weights that are adjusted, or the
   biases as well?


There are other things like how to decide the number of neurons in the
hidden layer. But once I get a very simplistic code example working, I'll
feel more confidence in understanding the mechanics of this neural network
works. And I'd start using your clojure-encog library as it's probably much
more complete than anything I could build. Any insights or examples you
could provide would be great.


Cheers

Tim Washington
Interruptsoftware.ca
416.843.9060



On Sat, Jul 28, 2012 at 8:51 AM, Dimitrios Jim Piliouras <
jimpil1...@gmail.com> wrote:

> If you're doing anything related with neural nets I think clojure-encog is
> indeed the place to start... I've wrapped most of the original java encog
> v3 so far and I am actively using it for my own projects...I'd be very
> happy to hear your feedback if you decide to use it after all...The truth
> is I've not provided a wiki  but I have provided an examples.clj where I've
> ported some of the most famous encog examples using my wrapper...hope you
> find it useful! any help you need along the way don't hesitate to ask!
> predicting financial series has been done in the past by heaton-research
> but unfortunately I've not ported that example! maybe it is time to do so
> as soon as I return from holidays...
>
> take care... :)
>
> Jim
>
> On Fri, Jul 27, 2012 at 10:03 PM, Timothy Washington 
> wrote:
>
>> I'm working on a Neural Network application to tech myself machine
>> learning and AI.
>>
>>- https://github.com/twashing/nn
>>
>> There's nothing there right now. But I'm keenly interested in the field,
>> and getting a working project, predicting financial time series. I'm keen
>> to check out clojure-encog ,
>> and any other AI library. I just want to make sure I understand the
>> mechanics of the algorithms that are being used.
>>
>>

-- 
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

Re: auxiliary methods like :before and :after for multimethods?

2012-07-28 Thread Chas Emerick
On Jul 28, 2012, at 4:36 PM, Vinzent wrote:

> 
> robert.hooke works fine with multimethods: 
> 
> user=> (defmulti foo class) 
> nil 
> user=> (defmethod foo :default [x] (str x)) 
> # 
> user=> (require '[robert.hooke :refer (add-hook)]) 
> nil 
> user=> (add-hook #'foo (fn [f & [x]] (str "K: " (f x 
> (#) 
> user=> (foo 42) 
> "K: 42" 
> 
> foo is a plain function now.

Oh, right, good point.  I've generally used hooks to modify others' 
multimethods, and so I suppose I've been lucky to always apply the hook after 
all methods had been registered.

- Chas

-- 
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

Re: auxiliary methods like :before and :after for multimethods?

2012-07-28 Thread Vinzent


> robert.hooke works fine with multimethods: 
>
> user=> (defmulti foo class) 
> nil 
> user=> (defmethod foo :default [x] (str x)) 
> # 
> user=> (require '[robert.hooke :refer (add-hook)]) 
> nil 
> user=> (add-hook #'foo (fn [f & [x]] (str "K: " (f x 
> (#) 
> user=> (foo 42) 
> "K: 42" 
>

foo is a plain function now.

-- 
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

Re: Experiences developing a crowdfunding site for open source projects in Clojure (from a Python background)

2012-07-28 Thread Takahiro Hozumi
Hi Aaron,
Thank you for the interesting post.
I guess we all here have quite similar experience as code size shrink.

> I found myself digging around in github repos to actual read code instead 
of documentation a lot more than I ever did with Python.
Agreed. In fact, for emacs/swank-clojure users this is one key-stroke(M-.) 
task.

Cheers,
Takahiro.

On Friday, July 27, 2012 4:59:46 AM UTC+9, Aaron Lebo wrote:
>
> Hello!
>
> Sometime around 2 and a half months ago, I started to work on a new 
> project using Clojure. I've been using Python heavily for about 6 six years 
> working for a small direct mail company and before that started programming 
> with Ruby on Rails. This new project was something out of left field, so I 
> had different options on what technology to use. I ended up choosing 
> Clojure, and my work on the site has been my first real experience using a 
> lisp, Clojure, and the JVM. I'd like to share my experiences and how that 
> has differed with my previous Python work.
>
> Before that, I'd like to make a little plug for my site. It is called 
> kodefund  (www.kodefund.com). The basic idea is 
> to take the familiar Kickstarter model but to really focus on applying that 
> to open source development. I feel that previous crowdfunding efforts have 
> shown that there is an interest by developers to fund projects that they 
> are enthusiastic about. When this works, everyone wins: the developer 
> working on the project can devote their full time and effort on the actual 
> project and still make a living and others get the benefits of the open 
> source software. I feel like it is preferable over selling licenses to 
> proprietary software or other efforts.
>
> So, every project on kodefund is required to be open source. This 
> differentiates it from other crowdfunding sites, and helps to apply a 
> filter: you know what you are getting when you go there instead of seeing 
> dozens of projects for unrelated stuff. 
>
> One other difference is that you can also start a project which is more or 
> less a "reverse" Kickstarter. This allows you to take an idea for a project 
> or issue you want fixed, raise funding, and find someone who will actually 
> implement the project. Other users get to submit "applications" and you 
> choose from them to find the most capable candidate. Once you chose an 
> application, that person takes over the project.
>
> Finally, one other push I want to make is to open up proprietary software. 
> Maybe your company has written some software in-house, but there's no real 
> incentive to release it. What if you could crowdfund the software, get paid 
> to release it, and the open source community as a whole could benefit from 
> that? 
>
> I feel like crowdfunding and open source software are an ideal fit.
>
> I'm getting off track here. I'll shift to my actual experiences using 
> Clojure. I was more than a little nervous about using the JVM. It always 
> seemed like some huge, scary thing, and digging into Java libraries was not 
> something I wanted to do. Something which resolved this was leiningen. I 
> feel like it is absolutely brilliant, and it really makes adding libraries 
> to your project a non-issue. Things have slowly changed in Python, but it 
> used to be that downloading dependencies was a global process and you ended 
> up with a site-packages that was full of dozens of old libraries that you 
> used for other projects. Being able to specify in my project.clj file 
> exactly which libraries I need and those getting downloaded automatically 
> is a really nice feature that I will look for similar functionality in 
> other languages from now on.
>
> I was also pleasantly surprised by the library availability. The vast 
> majority of things that I needed such as oauth2 support and such already 
> have decent Clojure wrappers. When I did drop down into Java, I found that 
> to be painless. The JVM really does have a wide swath of functionality 
> already available. Some of the things that I ended up using were email 
> libraries, date formatting libraries, and an rss feed generator. There 
> never was a point where I felt like I was going to have to just roll things 
> by hand. Most of the hard work has been done.
>
> Considering the language itself, one of the first things I noticed (or 
> didn't) was the parentheses. I don't remember when, but they simply are a 
> non-issue after a short amount of time. One slight thing I did have a 
> problem with was that inserting a parenthesis at the wrong place could 
> completely alter the flow of code and it was not immediately obvious. This 
> is not an issue when you are closing off a line or two of expressions, but 
> when you are halfway down the page, insert a paren and everything breaks, 
> it could get frustrating. This is probably resolved through better editor 
> usage. I unfortunately could never get emacs with clojure-mode and goodies 
> working properly on my Windows

Re: auxiliary methods like :before and :after for multimethods?

2012-07-28 Thread Chas Emerick
On Jul 28, 2012, at 7:02 AM, Ben Smith-Mannschott wrote:

> On Fri, Jul 27, 2012 at 9:06 PM, Vinzent  wrote:
>> robert-hooke actualy doesn't work with multimethods afaik. You can try my
>> new library (https://github.com/dnaumov/hooks), but it's alpha (no docs yet,
>> sorry).
> 
> (defmulti foo* (fn [args] ...) ...)
> (defmethod foo* :x [args]...)
> (defmethod foo* :y [args] ...)
> 
> (defn foo [args]
>  (foo* args))
> 
> Only foo calls foo*. Everyone else calls foo. Apply hooks to foo.
> 
> http://en.wikipedia.org/wiki/Fundamental_theorem_of_software_engineering
> 
> ;-)
> 
> // Ben

robert.hooke works fine with multimethods:

user=> (defmulti foo class)
nil
user=> (defmethod foo :default [x] (str x))
#
user=> (require '[robert.hooke :refer (add-hook)])
nil
user=> (add-hook #'foo (fn [f & [x]] (str "K: " (f x
(#)
user=> (foo 42)
"K: 42"

More interesting still would be the ability to add hooks to particular methods. 
 `defmethod` doesn't define a new var, so that's not generally possible, but 
you can work around it by defining functions and tying them to multimethods in 
separate operations:

user=> (defmulti twice class)
#'user/twice
user=> (defn twice-n [n] (* n n))
#'user/twice-n
user=> (defn twice-s [s] (str s s))
#'user/twice-s
user=> (.addMethod twice Number #'twice-n)
#
user=> (.addMethod twice String #'twice-s)
#
user=> (twice 5)
25
user=> (twice "hi")
"hihi"
user=> (add-hook #'twice-n (fn [f & [n]] (f (dec n 
(#)
user=> (twice 5)
16

These sorts of situations makes me want for an add-method to go along with 
remove-method and get-method, just to avoid the .addMethod interop form.

- Chas

-- 
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


Re: community interest in machine learning (?)

2012-07-28 Thread Dimitrios Jim Piliouras
If you're doing anything related with neural nets I think clojure-encog is
indeed the place to start... I've wrapped most of the original java encog
v3 so far and I am actively using it for my own projects...I'd be very
happy to hear your feedback if you decide to use it after all...The truth
is I've not provided a wiki  but I have provided an examples.clj where I've
ported some of the most famous encog examples using my wrapper...hope you
find it useful! any help you need along the way don't hesitate to ask!
predicting financial series has been done in the past by heaton-research
but unfortunately I've not ported that example! maybe it is time to do so
as soon as I return from holidays...

take care... :)

Jim

On Fri, Jul 27, 2012 at 10:03 PM, Timothy Washington wrote:

> I'm working on a Neural Network application to tech myself machine
> learning and AI.
>
>- https://github.com/twashing/nn
>
> There's nothing there right now. But I'm keenly interested in the field,
> and getting a working project, predicting financial time series. I'm keen
> to check out clojure-encog , and
> any other AI library. I just want to make sure I understand the mechanics
> of the algorithms that are being used.
>
>
> Very exciting
>
> Tim Washington
> Interruptsoftware.ca
> 416.843.9060
>
>
>
> On Sun, Jul 15, 2012 at 1:10 PM, Joshua Bowles wrote:
>
>> New to Clojure (but not Lisp).
>>
>> Does anyone have a good sense of the interest in machine learning in
>> Clojure community?
>> I've seen in the last few threads some interesting posts and libraries
>> related to machine learning, and there is plenty of stuff one can get from
>> Java (mahout, weka, clj-ml [
>> http://antoniogarrote.github.com/clj-ml/index.html]), but I'm curious to
>> know if anyone here has a sense of the overall community interest.
>>
>> It's nice to see interesting libraries that support needed tasks for
>> machine learning (I'm all for links to libraries), but what I'm really
>> trying to get is* a sense of the overall interest the community has in
>> machine learning*. For example, Python community overall has a lot of
>> interest in scientific computing and machine learning. Compare this to
>> Ruby... not that you couldn't provide good libraries in Ruby (for example
>> the SciRuby project), but the Ruby community overall does not seem to have
>> much interest in these kinds of academic pursuits.
>>
>  --
> 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 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

Re: Transitioning an App from Java to Clojure (Notes of a Talk)

2012-07-28 Thread Timothy Washington
Very interesting. Thanks for the insight.


Tim Washington
Interruptsoftware.ca
416.843.9060



On Sat, Jul 28, 2012 at 6:40 AM, nicolas.o...@gmail.com <
nicolas.o...@gmail.com> wrote:

> > There is indeed an infinite number of functions, or relationships between
> > natural numbers. I don't think that means that that any one of those
> > relationships is not computable because it is within the range of
> infinite
> > functions. The countable parts of a program can still accept an infinite
> > amount of input, like Turing's machine. So the best I can say is that all
> > functions (relationships between natural numbers) can be computable, but
> > humans may or may not have figured out a way to represent all natural
> > numbers.
>
> Some of these functions/relations are known to be not computable. For
> example a function taking
> the "source code" of a program (in any Turing-complete language) and
> returning 1 if the
> program stops or 0 if it runs forever. (the halting problem
> http://en.wikipedia.org/wiki/Halting_problem )
>
> This functions is mathematically perfectly well defined, but it can be
> proved it can not be computed.
> (No Turing machine can compute this function. It is important to
> understand it is not a complexity
> problem. It does not mean such a program would be too slow to be
> useful. It really means such a program
> can not exist.)
>
> --
> 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 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

Re: Clojure Sticker

2012-07-28 Thread Rich Hickey
You can now get official Clojure stickers here:

http://clojure.org/swag

I'll be adding T-shirts etc soon.

Rich

On Jul 19, 2012, at 3:13 PM, charlie wrote:

> Yeah any sort of  vector image should work for us
> 
> On Wed, Jul 18, 2012 at 7:59 PM, Alex Kurilin  wrote:
> +1. A temporary workaround would be getting a .svg that you could turn into 
> stickers yourself, if that's ok with Rich. We did something similar with the 
> vim logo on Reddit.
> 
> 
> -- 
> 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 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 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


Re: Looking for help with a deadlock issue

2012-07-28 Thread John Szakmeister
On Fri, Jul 27, 2012 at 12:02 PM, Kyle R. Burton  wrote:
> I encountered a deadlock on one of our production systems (one out of
> 3) last night.  Looking at a thread dump of the JVM, there are several
> (over 200) threads that are all waiting on a
> java.util.concurrent.locks.ReentrantLock from Keyword.intern.
>
> I've put up the thread dump and information about the os and jvm versions 
> here:
>
>   https://github.com/relaynetwork/20120727-deadlock-issue
>
> The part of our application that deadlocked is a web service that uses
> Compjure and Jetty.  Other parts of the application did not deadlock
> (we have AMQP consumers that were still processing successfully).
>
> I have since restarted the service and it is processing again.  I'm
> not sure what to look at next, can anyone suggest a next step for
> determining the cause?

I think you're hitting a bug in Java.  Specifically, this one:
   http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6822370

It looks like there are 237 threads attempting to call
java.util.concurrent.ConcurrentHashMap$Segment.put, which makes the
lock awfully contentious.  But the problem is that they all decided to
park themselves.  That's a sure sign that the view of memory is
inconsistent across the processors.  Looking at the evaluation of the
bug, that seems to be exactly the problem.  It was supposedly fixed in
1.6.0_19, but there seem to be reports that it's still present in _20
and _21.

It's not all bad news though.  It seems like a workaround is to use
"-XX:+UseMembar".

-John

-- 
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


Re: auxiliary methods like :before and :after for multimethods?

2012-07-28 Thread Ben Smith-Mannschott
On Fri, Jul 27, 2012 at 9:06 PM, Vinzent  wrote:
> robert-hooke actualy doesn't work with multimethods afaik. You can try my
> new library (https://github.com/dnaumov/hooks), but it's alpha (no docs yet,
> sorry).

(defmulti foo* (fn [args] ...) ...)
(defmethod foo* :x [args]...)
(defmethod foo* :y [args] ...)

(defn foo [args]
  (foo* args))

Only foo calls foo*. Everyone else calls foo. Apply hooks to foo.

http://en.wikipedia.org/wiki/Fundamental_theorem_of_software_engineering

;-)

// Ben

> Any suggestions about API is 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


Re: Transitioning an App from Java to Clojure (Notes of a Talk)

2012-07-28 Thread nicolas.o...@gmail.com
> There is indeed an infinite number of functions, or relationships between
> natural numbers. I don't think that means that that any one of those
> relationships is not computable because it is within the range of infinite
> functions. The countable parts of a program can still accept an infinite
> amount of input, like Turing's machine. So the best I can say is that all
> functions (relationships between natural numbers) can be computable, but
> humans may or may not have figured out a way to represent all natural
> numbers.

Some of these functions/relations are known to be not computable. For
example a function taking
the "source code" of a program (in any Turing-complete language) and
returning 1 if the
program stops or 0 if it runs forever. (the halting problem
http://en.wikipedia.org/wiki/Halting_problem )

This functions is mathematically perfectly well defined, but it can be
proved it can not be computed.
(No Turing machine can compute this function. It is important to
understand it is not a complexity
problem. It does not mean such a program would be too slow to be
useful. It really means such a program
can not exist.)

-- 
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


Re: Problems extending sequences

2012-07-28 Thread Vinzent
nth is used by the clojure printer (see print-method). Try the following 
code: (do (ConsCell. 1 nil) :ok)

It looks like you have to implement Sequential in order to get nth working 
on your datasctructure.

суббота, 28 июля 2012 г., 10:33:48 UTC+6 пользователь JvJ написал:
>
> I'm trying to create a new ISeq type, just to try to get the hang of 
> extending sequences.  It's not working, though.  As far as I can tell, I've 
> implemented all necessary methods.  However, I still get an error when 
> attempting to create an instance of the type.
>
> When I enter the following in the REPL:
> (ConsCell. 1 nil)
>
> The repl complains about the nth function not being supported.  However, 
> I'm not sure how to go about implementing it.  Any ideas?
>
> (deftype ConsCell [car cdr]
>   clojure.lang.ISeq
>   (first
> [this] (-> this .car))
>   (next
> [this] (-> this .cdr))
>   (more
> [this] (-> this .cdr))
>   (cons
> [this obj] (ConsCell. obj this))
>   (seq
> [this] this)
>   (equiv
> [this other] false)
>   (count
> [this]
> (if (nil? (-> this .cdr))
>   1
>   (inc (.count cdr
>
>;; Can't implement nth here, since it's not a member of the interface
>   ;(nth
> ;[this n]
> ;(if (zero? n)
>   ;(-> this .car)
>   ;(.nth cdr (dec n
>   )
>

-- 
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

Re: Extending protocol for maps

2012-07-28 Thread Vinzent
You can implement the clojure.lang.IPersistentMap interface if you want to 
create your own map type.

суббота, 28 июля 2012 г., 8:09:05 UTC+6 пользователь JvJ написал:
>
> Is there a way to extend whatever protocol is used by Clojure maps (struct 
> maps, array maps, hash maps, etc.)?

-- 
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

Re: auxiliary methods like :before and :after for multimethods?

2012-07-28 Thread Vinzent
Can you elaborate more about how the system should behave?

Also, I don't think it's correct to say that "you own the target function" 
here, since hook applies to the whole defmulti, not to some concrete 
defmethod, so I don't see any difference between hooks for functions and 
multimethods in this case.

суббота, 28 июля 2012 г., 9:37:57 UTC+6 пользователь George Oliver написал:
>
>
>
> On Friday, July 27, 2012 12:06:33 PM UTC-7, Vinzent wrote:
>>
>> robert-hooke actualy doesn't work with multimethods afaik. You can try my 
>> new library (https://github.com/dnaumov/hooks), but it's alpha (no docs 
>> yet, sorry).
>
>
> Yes, from the robert-hooke readme, "Adding hooks to a defmulti is 
> discouraged as it will make it impossible to add further methods. Hooks are 
> meant to extend functions you don't control; if you own the target function 
> there are obviously better ways to change its behaviour.". 
>
> What got me thinking about :before and :after was the question of how to 
> add a lightweight rules system to an application. Do you think hooks are 
> appropriate here?
>

-- 
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