Re: Matching core.match's syntactic keywords

2011-12-23 Thread Tassilo Horn
Herwig Hochleitner  writes:

Hi Herwig,

> I want to match vectors of the form [(some expr) :as :label], but  #(match
> [%] [[expr :as (label :when keyword)]] {:expr expr :label label}) throws a
> compiler exception: Unable to resolve symbol expr

Isn't the order value/key in map pattern?

  {expr :expr, label :label}

That said, I've not yet come to play with core.match, but I've seen
David's talk at the NY (?) Clojure User Group, yesterday. ;-)

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


Re: Literate programming

2011-12-23 Thread daly
On Thu, 2011-12-22 at 20:19 -0800, nchurch wrote:
> I'll do everything I can to help.  I have tons of thoughts (as you
> might guess); but I haven't demonstrated myself to be a great coder,
> yet.  I feel like I'm a coder who needs something like literate
> programming to be great, so it's kind of a chicken-and-egg problem.
> I'm already partway there with the existence of Clojure, but although
> it's the most intelligent language I've every come across (and it is
> at least Lisp), it still isn't enough.
> 
> On Dec 22, 11:14 pm, daly  wrote:
> > On Thu, 2011-12-22 at 17:53 -0800, nchurch wrote:
> > > Firstly, there really needs to be something like a Github for literate
> > > programming.
> >
> > What a great idea!
> > I'll see what I can do.
> >
> > Tim Daly
> 
 
I looked into cloning a github into "lithub" but that path won't work.
Github does not publish its source code. Other things like gitorious
are available but the setup is a challenge.

Tim Daly


-- 
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: Literate programming

2011-12-23 Thread daly
>I'll do everything I can to help.  I have tons of thoughts (as you
>might guess); but I haven't demonstrated myself to be a great coder,
>yet.  I feel like I'm a coder who needs something like literate
>programming to be great, so it's kind of a chicken-and-egg problem.
>I'm already partway there with the existence of Clojure, but although
>it's the most intelligent language I've every come across (and it is
>at least Lisp), it still isn't enough.

Do yourself a favor and lose the "great coder" meme. Or get a job
at google and remain blissfully unaware.

One of the best books I've ever read about programming is called
"Practicing: A Musician's Return to Music" where the author talks
about his development as a musician. He would receive compliments
on how great he was at playing the guitar. At one point he replies
"How would you know?". The better he got, the worse he knew he was.

Your opinion of how great you are at programming will follow a
bell curve. You'll start off coming out of college thinking you're
ok, memorize a few algorithms and order theory ("the google disease")
and think you're "great" ("google only hires great coders"). But as
you learn more you'll discover that you have SO much more to learn
and as you work on larger projects you'll discover the musician's
insight. People would rate you "great" but you'll be able to say
"How would you know?". At which point, the better you get, the worse
you'll know you are.

Anybody who rates themselves as "great" is probably on the uphill
side of the learning curve. 

The fact that you're trying to learn Clojure, moving into areas
that are beyond your comfort zone, and trying to learn literate 
programming to improve your game, all points to the fact that you
will likely reach a point where you feel that being labeled "great"
is a sign that the speaker is clueless. Give it 1 hours.

On Thu, 2011-12-22 at 20:59 -0800, nchurch wrote:
> You can see that I am writing here not only about the current good-
> enough implementation, but a \future implementation, should it ever be
> needed.  In fact, I discovered a bug in my code before I ever wrote
> the code; but the question is what to do about the bug! 

You found it. This is the magic hidden in literate programming.
Writing the natural language explanation, either before or during
coding exposes bugs before they get into the code. It exposes
hidden assumptions that will break boundary cases.

It is hard to demonstrate this effect. You have to try to write a
literate program and wait for the aha! moment to occur.

Lisps in general, and Clojure in particular, have the same aha!
moment where you transition from "how could anyone code like this?"
to "how could anyone code any other way?".

Pick some useful task, like a code-walker that will list all of
the called functions in a Clojure s-expression, and try to write
a literate version. Odds are good that you will learn more than
you ever wanted to know about Clojure. And, oh-by-the-way, 
everyone else can read your literate code and learn Clojure too.
How sweet it that?

Tim Daly


-- 
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: Literate programming

2011-12-23 Thread Adam Getchell
On Thu, Dec 22, 2011 at 11:54 AM, daly  wrote:

> On Tue, 2011-12-20 at 00:26 -0800, Adam Getchell wrote:
> > BTW I looked at marginalia+leiningen, which seems to work for my
> > purposes except I'm unclear where to put the .tex files.
>
> I'm not sure what this sentence means. The .tex files ARE the
> literate program. By analogy, you seem to be asking something like
>

Please allow me to elucidate. In the literate programming tool I mentioned,
marginalia, the output is, in fact, raw HTML. A very kind gentlemen
involved with the project pointed me to the source code documentation
wherein I discerned that the LaTeX code was to be embedded directly in the
comments. Unfortunately, at present the moderately complex equations with
which I should like to document have not rendered in a fitting manner so as
to be read or understood clearly.


> "I'm writing a book but I don't know where to put the text".
>

That question, good sir, would seem to depend upon the choice of writing
implement and media. Would not a Victorian gentleman, asked to pen such a
book, eventually display a puzzled comportment were he to be presented a
computer monitor?

Clearly, as a craftsman of computer algebra tools yourself, you must agree
that the selection of implements is of some import, lest you abandon that
enterprise entirely and use Mathematica instead.

> The combination of literate + TDD seems forbidding.
>
> Are you finding it hard to explain why you wrote a test?
>

The difficulties with which I have found myself in relate to some degree to
my extreme inexperience with their methodologies, both theoretical and
practical, as well as some odd discrepancies with the particular set of
tools I have chosen. In another response to a separate missive, a gentlemen
confirmed that there were some strange interactions betwixt midje and
marginalia.

Having received the benefit of your kind reply, I must confess to a
puzzlement which has vexed me ever since I read your missive. It is this:
how should I have read it so as to receive some knowledge or insight with
which I had not formerly possessed in the moments prior? For in truth I
have not been able to discern its helpfulness thereby.

Adam Getchell

-- 
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: Matching core.match's syntactic keywords

2011-12-23 Thread Steve Miner

On Dec 22, 2011, at 10:54 PM, Herwig Hochleitner wrote:

> I want to match vectors of the form [(some expr) :as :label], but  #(match 
> [%] [[expr :as (label :when keyword)]] {:expr expr :label label}) throws a 
> compiler exception: Unable to resolve symbol expr
> 


If you want to match a literal keyword that has a special meaning to match, you 
need to quote it. (It's always safe to quote the keyword literals when in 
doubt.)  Also, I think your :when test should be keyword? (to make sure 
something is a keyword, rather than creating one).  The following works for me:

(match [['(some expr) :as :label]] 
   [[expr ':as (label :when keyword?)]] {:expr expr :label label})

;=> {:expr (some expr), :label :label}


--
Steve Miner
stevemi...@gmail.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

Re: Matching core.match's syntactic keywords

2011-12-23 Thread David Nolen
Been a bit busy will look into this and respond later today.

On Thursday, December 22, 2011, Herwig Hochleitner 
wrote:
> Hi,
> I want to match vectors of the form [(some expr) :as :label], but
 #(match [%] [[expr :as (label :when keyword)]] {:expr expr :label label})
throws a compiler exception: Unable to resolve symbol expr
> How do I do this?
> kind regards
> --
> __
> Herwig Hochleitner
>
> --
> 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: Matching core.match's syntactic keywords

2011-12-23 Thread David Nolen
Ah Steve got to it first. Thanks!

On Friday, December 23, 2011, Steve Miner  wrote:
>
> On Dec 22, 2011, at 10:54 PM, Herwig Hochleitner wrote:
>
> I want to match vectors of the form [(some expr) :as :label], but
 #(match [%] [[expr :as (label :when keyword)]] {:expr expr :label label})
throws a compiler exception: Unable to resolve symbol expr
>
> If you want to match a literal keyword that has a special meaning to
match, you need to quote it. (It's always safe to quote the keyword
literals when in doubt.)  Also, I think your :when test should be keyword?
(to make sure something is a keyword, rather than creating one).  The
following works for me:
> (match [['(some expr) :as :label]]
>[[expr ':as (label :when keyword?)]] {:expr expr :label label})
> ;=> {:expr (some expr), :label :label}
>
> --
> Steve Miner
> stevemi...@gmail.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 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

Question ActionListener conditional

2011-12-23 Thread Antonio Recio
I am trying to add and to remove an object "isoActor" when I click the 
button "isoButton", but I get an error:
Exception in thread "main" java.lang.IllegalArgumentException: Don't know 
how to create ISeq from: clojure.lang.Symbol

The code:
(. isoButton addActionListener
 (proxy [ActionListener] []
   (if (. isoButton isSelected)
 (actionPerformed [e] (AddActor isoActor))
   (actionPerformed [e] (RemoveActor isoActor)

-- 
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: Question ActionListener conditional

2011-12-23 Thread Aaron Cohen
On Fri, Dec 23, 2011 at 1:29 PM, Antonio Recio  wrote:
> I am trying to add and to remove an object "isoActor" when I click the
> button "isoButton", but I get an error:
> Exception in thread "main" java.lang.IllegalArgumentException: Don't know
> how to create ISeq from: clojure.lang.Symbol
>
> The code:
> (. isoButton addActionListener

It's just a stylistic thing, but most people have stopped using the
"." standalone operator and moved to (.addActionListener isoButton)

>      (proxy [ActionListener] []
>        (if (. isoButton isSelected)

You are trying to provide the definition of the "actionPerformed"
method of the ActionListener, but you haven't actually specified that
that is what you are doing.

>          (actionPerformed [e] (AddActor isoActor))
>        (actionPerformed [e] (RemoveActor isoActor)

I think you want something more like the following, but I don't know
what AddActor, RemoveActor and isoActor are supposed to be.

(.addActionListener isoButton
(proxy [ActionListener] []
   (actionPerformed [] (if (.isSelected isoButton) (AddActor
isoActor) (RemoveActor isoActor)

-- 
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: Question ActionListener conditional

2011-12-23 Thread Antonio Recio
When I click 2 times the button isoButton I get an error.
(.addActionListener isoButton
(proxy [ActionListener] []
  (actionPerformed []
(if (.isSelected isoButton)
  (println "Button is selected")
  (println "Button is not selected")

Error:
Exception in thread "AWT-EventQueue-0" clojure.lang.ArityException: Wrong 
number of args (2) passed to: user$eval39$fn

-- 
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: Question ActionListener conditional

2011-12-23 Thread Aaron Cohen
On Fri, Dec 23, 2011 at 3:08 PM, Antonio Recio  wrote:
> When I click 2 times the button isoButton I get an error.
> (.addActionListener isoButton
>                     (proxy [ActionListener] []
>                       (actionPerformed []

Sorry, forgot the parameter here, add an "e". (actionPerformed [e] ...)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


SAT with core.logic

2011-12-23 Thread Peteris
Hi,

I wrote a simple SAT solver macro on top of core.logic today (code at
http://peteriserins.com/2011/12/23/sat-in-clojure-core-logic.html). Is
it possible to write a similar SAT solver that would accept expression
arguments at runtime (say, a SAT function, but not necessarily).

Regards
--
Peteris Erins

-- 
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: New home for ClojureCLR

2011-12-23 Thread Timothy Pratley
Nice! Good move :)
Great to see the .NET support continuing and strengthening.



On Tue, Dec 20, 2011 at 1:49 PM, dmiller  wrote:
> ClojureCLR has a new home!
>
> Code repo:  https://github.com/clojure/clojure-clr
> JIRA: http://dev.clojure.org/jira/browse/CLJCLR
>
> Old binary distributions for versions 1.1 and 1.2 will continue to be
> available at the old repo (https://github.com/richhickey/clojure-clr)
> for the time being.
>
> The new repo already is several commits ahead and there's new wiki
> content on CLR interop.   Switch today!
>
> The JIRA site can be used to open issues.  I will clone the workflow
> from the CLJ project ... umm,  later.
>
> My thanks to the Clojure/core for the accommodations, and specifically
> to Stuart Sierra for pushing and Chris Redinger for the heavy lifting.
>
> -David Miller
>
> --
> 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: SAT with core.logic

2011-12-23 Thread David Nolen
On Fri, Dec 23, 2011 at 4:10 PM, Peteris  wrote:

> Hi,
>
> I wrote a simple SAT solver macro on top of core.logic today (code at
> http://peteriserins.com/2011/12/23/sat-in-clojure-core-logic.html). Is
> it possible to write a similar SAT solver that would accept expression
> arguments at runtime (say, a SAT function, but not necessarily).
>
> Regards
> --
> Peteris Erins
>

You could change sat to take the unevaluated expression and the symbols
that represent the variables. Do you have some examples illustrating the
kinds of things you would like to do?

David

-- 
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: SAT with core.logic

2011-12-23 Thread Peteris
That's exactly what I wanted to do. Say, be able to write

(sat '[p q] '(and p q))

and I tried working out a function that does this. I've seen examples
of functions on logic variables, but in this case
how could we create fresh logic variables out of these symbols? That
seems like something we would need to be
able to feed into the macro at compile-time.

On Dec 23, 11:29 pm, David Nolen  wrote:
> On Fri, Dec 23, 2011 at 4:10 PM, Peteris  wrote:
> > Hi,
>
> > I wrote a simple SAT solver macro on top of core.logic today (code at
> >http://peteriserins.com/2011/12/23/sat-in-clojure-core-logic.html). Is
> > it possible to write a similar SAT solver that would accept expression
> > arguments at runtime (say, a SAT function, but not necessarily).
>
> > Regards
> > --
> > Peteris Erins
>
> You could change sat to take the unevaluated expression and the symbols
> that represent the variables. Do you have some examples illustrating the
> kinds of things you would like to do?
>
> David

-- 
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: SAT with core.logic

2011-12-23 Thread David Nolen
Do something like this not work for you?

(defn foo [p q]
  (sat [p q] (and p q)))

David

On Fri, Dec 23, 2011 at 5:00 PM, Peteris  wrote:

> That's exactly what I wanted to do. Say, be able to write
>
> (sat '[p q] '(and p q))
>
> and I tried working out a function that does this. I've seen examples
> of functions on logic variables, but in this case
> how could we create fresh logic variables out of these symbols? That
> seems like something we would need to be
> able to feed into the macro at compile-time.
>
> On Dec 23, 11:29 pm, David Nolen  wrote:
> > On Fri, Dec 23, 2011 at 4:10 PM, Peteris 
> wrote:
> > > Hi,
> >
> > > I wrote a simple SAT solver macro on top of core.logic today (code at
> > >http://peteriserins.com/2011/12/23/sat-in-clojure-core-logic.html). Is
> > > it possible to write a similar SAT solver that would accept expression
> > > arguments at runtime (say, a SAT function, but not necessarily).
> >
> > > Regards
> > > --
> > > Peteris Erins
> >
> > You could change sat to take the unevaluated expression and the symbols
> > that represent the variables. Do you have some examples illustrating the
> > kinds of things you would like to do?
> >
> > David
>
> --
> 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: SAT with core.logic

2011-12-23 Thread Peteris
I don't understand, the value of foo should be independent of the
values of its arguments, right?

To motivate the application better, I want to be able to do symbolic
computing on the boolean expression prior to passing it into sat, so I
don't know ahead of time the number of symbols in the expression, nor
the exact symbols used, nor the boolean expression itself.

On Dec 24, 12:15 am, David Nolen  wrote:
> Do something like this not work for you?
>
> (defn foo [p q]
>   (sat [p q] (and p q)))
>
> David
>
>
>
>
>
>
>
> On Fri, Dec 23, 2011 at 5:00 PM, Peteris  wrote:
> > That's exactly what I wanted to do. Say, be able to write
>
> > (sat '[p q] '(and p q))
>
> > and I tried working out a function that does this. I've seen examples
> > of functions on logic variables, but in this case
> > how could we create fresh logic variables out of these symbols? That
> > seems like something we would need to be
> > able to feed into the macro at compile-time.
>
> > On Dec 23, 11:29 pm, David Nolen  wrote:
> > > On Fri, Dec 23, 2011 at 4:10 PM, Peteris 
> > wrote:
> > > > Hi,
>
> > > > I wrote a simple SAT solver macro on top of core.logic today (code at
> > > >http://peteriserins.com/2011/12/23/sat-in-clojure-core-logic.html). Is
> > > > it possible to write a similar SAT solver that would accept expression
> > > > arguments at runtime (say, a SAT function, but not necessarily).
>
> > > > Regards
> > > > --
> > > > Peteris Erins
>
> > > You could change sat to take the unevaluated expression and the symbols
> > > that represent the variables. Do you have some examples illustrating the
> > > kinds of things you would like to do?
>
> > > David
>
> > --
> > 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: SAT with core.logic

2011-12-23 Thread David Nolen
As your solver is based on rewriting I think you will need to use eval to
get the behavior you want.

Another approach might be http://www.soi.city.ac.uk/~jacob/solver/. However
that would require a couple of interesting changes to core.logic (which I'd
be more than happy to include if someone implemented them).

David

On Fri, Dec 23, 2011 at 5:39 PM, Peteris  wrote:

> I don't understand, the value of foo should be independent of the
> values of its arguments, right?
>
> To motivate the application better, I want to be able to do symbolic
> computing on the boolean expression prior to passing it into sat, so I
> don't know ahead of time the number of symbols in the expression, nor
> the exact symbols used, nor the boolean expression itself.
>
> On Dec 24, 12:15 am, David Nolen  wrote:
> > Do something like this not work for you?
> >
> > (defn foo [p q]
> >   (sat [p q] (and p q)))
> >
> > David
> >
> >
> >
> >
> >
> >
> >
> > On Fri, Dec 23, 2011 at 5:00 PM, Peteris 
> wrote:
> > > That's exactly what I wanted to do. Say, be able to write
> >
> > > (sat '[p q] '(and p q))
> >
> > > and I tried working out a function that does this. I've seen examples
> > > of functions on logic variables, but in this case
> > > how could we create fresh logic variables out of these symbols? That
> > > seems like something we would need to be
> > > able to feed into the macro at compile-time.
> >
> > > On Dec 23, 11:29 pm, David Nolen  wrote:
> > > > On Fri, Dec 23, 2011 at 4:10 PM, Peteris 
> > > wrote:
> > > > > Hi,
> >
> > > > > I wrote a simple SAT solver macro on top of core.logic today (code
> at
> > > > >http://peteriserins.com/2011/12/23/sat-in-clojure-core-logic.html).
> Is
> > > > > it possible to write a similar SAT solver that would accept
> expression
> > > > > arguments at runtime (say, a SAT function, but not necessarily).
> >
> > > > > Regards
> > > > > --
> > > > > Peteris Erins
> >
> > > > You could change sat to take the unevaluated expression and the
> symbols
> > > > that represent the variables. Do you have some examples illustrating
> the
> > > > kinds of things you would like to do?
> >
> > > > David
> >
> > > --
> > > 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: SAT with core.logic

2011-12-23 Thread Peteris
Oops, I was not aware eval could evaluate macros, thanks for pointing
that out. Indeed, I can just wrap:

(defn sate! [vars expr]
  (eval `(sat ~vars ~expr)))

Thanks for the link too, looks interesting.

On Dec 24, 12:48 am, David Nolen  wrote:
> As your solver is based on rewriting I think you will need to use eval to
> get the behavior you want.
>
> Another approach might behttp://www.soi.city.ac.uk/~jacob/solver/. However
> that would require a couple of interesting changes to core.logic (which I'd
> be more than happy to include if someone implemented them).
>
> David
>
>
>
>
>
>
>
> On Fri, Dec 23, 2011 at 5:39 PM, Peteris  wrote:
> > I don't understand, the value of foo should be independent of the
> > values of its arguments, right?
>
> > To motivate the application better, I want to be able to do symbolic
> > computing on the boolean expression prior to passing it into sat, so I
> > don't know ahead of time the number of symbols in the expression, nor
> > the exact symbols used, nor the boolean expression itself.
>
> > On Dec 24, 12:15 am, David Nolen  wrote:
> > > Do something like this not work for you?
>
> > > (defn foo [p q]
> > >   (sat [p q] (and p q)))
>
> > > David
>
> > > On Fri, Dec 23, 2011 at 5:00 PM, Peteris 
> > wrote:
> > > > That's exactly what I wanted to do. Say, be able to write
>
> > > > (sat '[p q] '(and p q))
>
> > > > and I tried working out a function that does this. I've seen examples
> > > > of functions on logic variables, but in this case
> > > > how could we create fresh logic variables out of these symbols? That
> > > > seems like something we would need to be
> > > > able to feed into the macro at compile-time.
>
> > > > On Dec 23, 11:29 pm, David Nolen  wrote:
> > > > > On Fri, Dec 23, 2011 at 4:10 PM, Peteris 
> > > > wrote:
> > > > > > Hi,
>
> > > > > > I wrote a simple SAT solver macro on top of core.logic today (code
> > at
> > > > > >http://peteriserins.com/2011/12/23/sat-in-clojure-core-logic.html).
> > Is
> > > > > > it possible to write a similar SAT solver that would accept
> > expression
> > > > > > arguments at runtime (say, a SAT function, but not necessarily).
>
> > > > > > Regards
> > > > > > --
> > > > > > Peteris Erins
>
> > > > > You could change sat to take the unevaluated expression and the
> > symbols
> > > > > that represent the variables. Do you have some examples illustrating
> > the
> > > > > kinds of things you would like to do?
>
> > > > > David
>
> > > > --
> > > > 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


LurePet - Digital Art Project Written in Clojure - Beauty Contest For Virtual Life (shamelessly advertising)

2011-12-23 Thread Sergey Didenko
Hi, finally I can show you some quite complex project that I made in Clojure.

The Idea:

Every lurepet (big picture) that you see on the site has some "genes"
and is drawn according to them.

After the best lurepets are selected they can be bred to make children
looking like their parents. This is going to be repeated to create
more and more beautiful lurepets.

And of course the reason to vote is to save the future humanity that
is attacked by evil robots which has the only flaw - insane obsession
with lurepets :)

Implementation:

The drawing logic which is 99% of all the logic, is written in
Clojure. I'm very glad that I chose it, because I can not imagine
beeing so productive in developing and maintaining (!) complex domain
logic in a more verbose language like Java.

The web part currently is a set of static files: html, js and images.
Cloudflare is used to CDN the static except the index.html. I hope
that will help if there is a massive spike in traffic. The votes are
processed from nginx logs in offline mode.

If you like the project - please upvote this thread on Hacker News -
http://news.ycombinator.com/item?id=3387597

-- 
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: LurePet - Digital Art Project Written in Clojure - Beauty Contest For Virtual Life (shamelessly advertising)

2011-12-23 Thread Joseph Jones
Do you have a link to the running project?

On Dec 23, 2011, at 3:23 PM, Sergey Didenko wrote:

> Hi, finally I can show you some quite complex project that I made in Clojure.
> 
> The Idea:
> 
> Every lurepet (big picture) that you see on the site has some "genes"
> and is drawn according to them.
> 
> After the best lurepets are selected they can be bred to make children
> looking like their parents. This is going to be repeated to create
> more and more beautiful lurepets.
> 
> And of course the reason to vote is to save the future humanity that
> is attacked by evil robots which has the only flaw - insane obsession
> with lurepets :)
> 
> Implementation:
> 
> The drawing logic which is 99% of all the logic, is written in
> Clojure. I'm very glad that I chose it, because I can not imagine
> beeing so productive in developing and maintaining (!) complex domain
> logic in a more verbose language like Java.
> 
> The web part currently is a set of static files: html, js and images.
> Cloudflare is used to CDN the static except the index.html. I hope
> that will help if there is a massive spike in traffic. The votes are
> processed from nginx logs in offline mode.
> 
> If you like the project - please upvote this thread on Hacker News -
> http://news.ycombinator.com/item?id=3387597
> 
> -- 
> 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: LurePet - Digital Art Project Written in Clojure - Beauty Contest For Virtual Life (shamelessly advertising)

2011-12-23 Thread Sergey Didenko
Yes, its http://lurepet.com

> Do you have a link to the running project?

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


Should read-string support \x.. escaped characters?

2011-12-23 Thread Dave Sann
When sending data as strings from clojurescript to clojure there will be 
issues if the source data contains certain unicode characters. (I think in 
range 128-255 - extended latin characters mostly).

This is because the goog string conversion used by pr-str encodes these 
characters as \x.. not \u00..

read-string will throw an exception if it encounters these characters.

Should read-string support these character escapes?



by way of work around, I am using:

(require '[clojure.string :as s])

(defn unescape [string]
  (s/replace 
string #"\\x(..)" 
(fn [m] (str (char (Integer/parseInt (second m) 16))

(defn my-read-string [s]
  (read-string (unescape s)))

Causes : https://github.com/ibdknox/pinot/issues/16

Cheers

Dave

-- 
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: Clojurescript and google closure library versions?

2011-12-23 Thread Dave Sann
thx, I have done the same.

If anyone uses pinot, I also created an updated goog.jar with the third 
party-libs. (so that dom/query works)

you can fetch it here: https://github.com/davesann/clojurescript-goog-jar

(I documented how here 
: https://groups.google.com/d/msg/clj-noir/x5x9vcI-T4E/hDFevNRRj9YJ
I am unsure of how correct this method is - but it works for my current 
needs)

D



-- 
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: [ANN] okasaki-clojure

2011-12-23 Thread David Nolen
On Fri, Dec 23, 2011 at 3:45 AM, JuanManuel Gimeno Illa
wrote:

> Hi all,
>
>- first I watched Daniel Spiewak's talk Extreme Cleverness: Functional
>Data Structures in 
> Scala,
>I got the idea of implementing some of them in Clojure
>- then I bought okasaki's book, but all the examples were in ML
>- then I watched David Nolen's talk The Mapping 
> Dilemma,
>and I though clojure.match could be very useful
>
> and the result (mainly a proof of concept) is:
>
>- https://github.com/jmgimeno/okasaki-clojure
>
> that allows the translation of some of the implementations in ML into
> Clojure.
>
> For instance, unbalanced binary trees can be implemented as:
>
>
> (defdatatype
> ::UnbalancedBST
> Empty ; empty tree
> (Node a x b)) ; tree with root x, left subtree a and right subtree b
> (defun insert [x t]
> [x Empty]
> (Node Empty x Empty)
> [x ([Node a y b] :as s)]
> (cond
> (< x y) (Node (insert x a) y b)
> (< y x) (Node a y (insert x b))
> :else   s))
>
> (defun member [x t]
> [_ Empty]
> false
> [x [Node a y b]]
> (cond
> (< x y) (recur x a)
> (< y x) (recur x b)
> :else   true))
>
> Enjoy!
>
> Juan Manuel
>
>
Very, very cool. Is this just sugar for map pattern matching? I'd like to
fully support types/records as they provide significant performance
benefits. Probably won't happen in the near, near future - unless of course
somebody wants to take a stab at it :)

David

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

Literate Programming

2011-12-23 Thread daly
Good Sir and Fellow Traveler, 

On Fri, 2011-12-23 at 03:33 -0800, Adam Getchell wrote:
> Having received the benefit of your kind reply, I must confess to a
> puzzlement which has vexed me ever since I read your missive. It is
> this: how should I have read it so as to receive some knowledge or
> insight with which I had not formerly possessed in the moments prior?
> For in truth I have not been able to discern its helpfulness thereby.

Methinks thou hast conflated the spirit of literate programming, 
intended as a communication medium between fellow traveling souls
on this dark road with the substance of the task involving the
choice of conveyance and walking stick. Replying to the former
'twas I, whilest thou was't addressing the latter. 

We did pass by in our respective darkness. 
Forgive me for lacking light to guide your chosen path.
I mistook your destination for mine own, a grievous fault,
one to which I am ever prone.



> Clearly, as a craftsman of computer algebra tools yourself, you 
> must agree that the selection of implements is of some import,
> lest you abandon that enterprise entirely and use Mathematica 
> instead.

Truly I do quake at the co-opting possible should the fair winds
drift the conversation from the soul of the art to the choice and
heft of tooling. Like the goodly Saint Alexander [1] we need to 
seek the order which contains life. What doth make a program live,
or the building alive, is not to be found in the tooling but in
ourselves. We must eschew the pernicious present practice lest
we find our creation among the dead and dying on Sourceforge.

I have chosen minimal tools for my algebra opus. Latex for
smithing and tangle for forging. I find no need for any other
save the, as yet unrealized, potential of graphing tools.

'Tis not the tools but my poor craftsmanship that constrains 
the quality of the work.




>> The combination of literate + TDD seems forbidding
>  Are you finding it hard to explain why you wrote a test?

In this platonic exchange is made apparent my confusion. The
dross of failures that skins the molten and fluid gold of your
smelting needs but a few words. "Lo, this might arise at the
boundary of my creation." That the dross needeth explaining
to the Smithy new to your endeavor, yet still it certainly
can be conveyed in flowing natural language.

Sharing the tale of the journey, the wonders of the vision, and
the pleasures of final offering depends not on the choice of pen 
but on the craftmanship of language. That the gentle reader
delight in your creation and sing its praises, see the vision,
and dedication lifeblood to its continuance is all. That we might 
achieve such essential Quality [2] with Clojure is the dream.


Sir Tim Daly, Elder of the Internet


[1] Alexander, Christopher 
"The Nature of Order: The Phenomenon of Life"
2002 ISBN 0-9726529-1-4

[2] Persig, Robert
"Zen and the Art of Motorcycle Maintenance: An Inquiry into Values"
1974 ISBN 0-553-27747-2


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


(:require [clojure.contrib.sql :as sql]))

2011-12-23 Thread jayvandal
Where is this file to be found??
   (:require [clojure.contrib.sql :as sql]))
I see it listed in the jar but??
I have  the clojure.contrib-11.2.0.jar located in my classpath
c:\opt\jars, as well as the clojure.jar

Am I the only one who has trouble with these files??

-- 
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: (:require [clojure.contrib.sql :as sql]))

2011-12-23 Thread Sean Corfield
The monolithic contrib (1.2.0) has been deprecated. Updated versions
of many of the modules are available individually:

http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

However, if you have the JAR on your classpath, that namespace should
be available.

It would help people help you if you provided more detail:
* How are you running your Clojure code?
* What _exact_ error message (and partial stack trace) are you seeing?

Here's an example workflow that shows you can access
clojure.contrib.sql just fine:

sean@sean-netbook:~/clojure$ lein new jay
cd Created new project in: /home/sean/clojure/jay
Look over project.clj and start coding in jay/core.clj
sean@sean-netbook:~/clojure$ cd jay/
sean@sean-netbook:~/clojure/jay$ vi project.clj
sean@sean-netbook:~/clojure/jay$ cat project.clj
(defproject jay "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.2.1"]
 [org.clojure/clojure-contrib "1.2.0"]])
sean@sean-netbook:~/clojure/jay$ lein deps
Copying 2 files to /home/sean/clojure/jay/lib
sean@sean-netbook:~/clojure/jay$ lein repl
REPL started; server listening on localhost port 13024
user=> (ns jay.test (:require [clojure.contrib.sql :as sql]))
nil
jay.test=> ^D

Sean

On Fri, Dec 23, 2011 at 10:17 PM, jayvandal  wrote:
> Where is this file to be found??
>   (:require [clojure.contrib.sql :as sql]))
> I see it listed in the jar but??
> I have  the clojure.contrib-11.2.0.jar located in my classpath
> c:\opt\jars, as well as the clojure.jar
>
> Am I the only one who has trouble with these files??

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


core.logic

2011-12-23 Thread Sunil S Nandihalli
Hi,
 I would like to create a predicate which would accept two keys k1,k2 and
two maps m1 m2 .. and unify the following
m1[k1] = k2 and m2[k2] = k1 .. I have spent some time on it.. but been
unable to figure out how to do this. I would like this to be as efficient
as possible. I would appreciate any suggestion any of you may have..
Thanks,
Sunil.

-- 
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: core.logic

2011-12-23 Thread Ambrose Bonnaire-Sergeant
I'm not sure if I fully understand the requirements, but here's my
interpretation. https://gist.github.com/1516721

Hopefully you can clarify the intent if I'm off.

Ambrose

On Sat, Dec 24, 2011 at 3:39 PM, Sunil S Nandihalli <
sunil.nandiha...@gmail.com> wrote:

> Hi,
>  I would like to create a predicate which would accept two keys k1,k2 and
> two maps m1 m2 .. and unify the following
> m1[k1] = k2 and m2[k2] = k1 .. I have spent some time on it.. but been
> unable to figure out how to do this. I would like this to be as efficient
> as possible. I would appreciate any suggestion any of you may have..
> Thanks,
> Sunil.
>
> --
> 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: core.logic

2011-12-23 Thread Ambrose Bonnaire-Sergeant
Or is this more what you're after? https://gist.github.com/1516727

Ambrose

On Sat, Dec 24, 2011 at 3:39 PM, Sunil S Nandihalli <
sunil.nandiha...@gmail.com> wrote:

> Hi,
>  I would like to create a predicate which would accept two keys k1,k2 and
> two maps m1 m2 .. and unify the following
> m1[k1] = k2 and m2[k2] = k1 .. I have spent some time on it.. but been
> unable to figure out how to do this. I would like this to be as efficient
> as possible. I would appreciate any suggestion any of you may have..
> Thanks,
> Sunil.
>
> --
> 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: [ANN] okasaki-clojure

2011-12-23 Thread JuanManuel Gimeno Illa


>
> Very, very cool. Is this just sugar for map pattern matching?
>

I use only vector matching. When I define a datatype, for instance:

(defdatatype ::Type Constant (Expr x y))

I create symbols Constant, with value ::Constant and Expr with value (fn [x 
y] [::Expr x y]). That way I can use the symbols as functions and constants 
in the action part and, via translation of the patterns, in the pattern 
rows.

I'd like to fully support types/records as they provide significant 
> performance benefits. Probably won't happen in the near, near future - 
> unless of course somebody wants to take a stab at it :)
>

I considered the idea to define, inspired with your example with dates, a 
class for each type, but I preferred to try first a simpler implementation 
using vectors. 

Juan Manuel 

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