Re: Can't build clojure cloned from github - 2 tests failed - when running from cygwin

2011-11-23 Thread Michael Jaaka
Here is a diff of fix http://pastebin.com/KE6U3Pqb

On Nov 23, 12:13 am, Michael Jaaka michael.ja...@googlemail.com
wrote:
 Well, it is easy to break tests on any system. All you need to do is to put
 space into file name path.
 For example in clojure https://github.com/clojure/clojure / 
 testhttps://github.com/clojure/clojure/tree/master/test/
 clojure https://github.com/clojure/clojure/tree/master/test/clojure /
 test_clojurehttps://github.com/clojure/clojure/tree/master/test/clojure/test_clojure/
 javahttps://github.com/clojure/clojure/tree/master/test/clojure/test_cloj.../
  io.clj
 Change

 (defn temp-file
   [prefix suffix]
   (doto (File/createTempFile prefix suffix)
     (.deleteOnExit)))

 to

 (defn temp-file
   [prefix suffix]
   (doto (File/createTempFile (str a b c prefix) suffix)
     (.deleteOnExit)))

 The solution is to use java.net.URLDecoder/decode everywhere where .getPath 
 is called in java/io.clj

 and change protocol for URI like below

 (extend-protocol Coercions

   URI
   (as-url [u] (URL. (java.net.URLDecoder/decode (.toString u
   (as-file [u] (as-file (as-url u

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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 in Emacs?

2011-11-23 Thread ck
Andrew:

Make sure you have

(require 'ob-clojure)

in your controlling emacs file (mine is username.el).

-ck

On Nov 23, 12:00 pm, Andrew ache...@gmail.com wrote:
 Here's my attempt at following the steps 
 athttp://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html. 
 *The
 result is org-babel-execute-src-block: No org-babel-execute function for
 clojure *

    1. The recommendation was to follow Connecting with SLIME from
    https://github.com/technomancy/swank-clojurewhich involves M-x
    slime-connect, so I looked for that in
    http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html...
    It has a section called Server/Set up Leiningen project.clj file which
    says add a dev-dependency in my project.clj file for leiningen/lein-swank.
    So I picked [leiningen/lein-swank 1.2.0-SNAPSHOT]
    2. lein deps
    3. lein swank
    4. It said I should add swank-clojure as a dev-dependency too. So I
    picked [swank-clojure 1.4.0-SNAPSHOT]
    5. lein deps
    6. lein swank
    7. M-x slime-connect ... connected
    8. open tmp.org file and place cursor within a block of code and do C-c
    C-c
    9. Evaluate this block of code on your system? y

 org-babel-execute-src-block: No org-babel-execute function for clojure!

 What am I missing? I have the following:

   clojure-mode      1.11.4      installed
   org               2022    installed
   slime             20100404.1  installed
   slime-repl        20100404    installed

 ... and lein plugin swank-clojure (1.3.3 I think)

-- 
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 in Emacs?

2011-11-23 Thread Andrew
Thanks! Next step: org-babel-execute:clojure:Cannot open load file: 
swank-clojure ...

-- 
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: use namespace locally in a function

2011-11-23 Thread Nils Bertschinger
Clojure is a Lisp, so it should be possible to extend it yourself ...
What about something like this?

(defmacro locally-using
  Allows to use symbols from other namespace in the local scope
of the macro body.
Syntax: (locally-using [symbol*] :from namespace
  body)
  [symbols from ns-name  body]
  (assert (= from :from) Wrong syntax ... delimiter :from missing or
misplaced!)
  (let [local-vars (map (fn [sym] (symbol (str ns-name) (str sym)))
symbols)]
`(do (require '~ns-name)
 (symbol-macrolet [~@(interleave symbols local-vars)]
  ~@body

which then let's you write:
(locally-using [split] :from clojure.string (split Hello world #
))

The above macro could probably be made smarter to only require the lib
if it not already loaded and also unload when it is done in this
case. But since you have to load the lib anyways to use it and
qualified names do not clutter your current namespace, the above
version seems to be good enough.

Cheers,

Nils

On Nov 23, 4:40 am, Igor TN igor...@gmail.com wrote:
 Yes, I meant local context. In principle, this could help to avoid
 namespacing conflicts in certain cases. But not a big deal, just
 wondering if the language supports that. Apparently not. Cool with me.
 Thanks everybody!

 On Nov 22, 6:59 pm, Alex Baranosky alexander.barano...@gmail.com
 wrote:

  Looks like he'd like to make a namespace available *only* in a local
  context, which some languages support, like Scala, for one.  I never have a
  need for that, really.

-- 
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: deprecating butlast?

2011-11-23 Thread Nils Bertschinger
Hi,

you're right that drop-last is more general than butlast. So why does
butlast exist at all?
I would say, that it is there for a very good reasons. It solves a
common problem, namely to drop the last element of a sequence and
reads better in this case than the equivalent idiom using drop-last.
Thus, it is a perfect example for a useful abstraction and capturing
common abstractions should be the main reason for defining functions
(macros) in the first place. Obviously, any function (macro) could
always be replaced by its definition, so it has to justify its
existence by being reusable and improving readability. This also
applies if it only captures a very special use case as long as it is
common enough. I would say that butlast is well justified according to
these criteria.

Best,

Nils

On Nov 22, 12:54 pm, Daniel Janus nath...@gmail.com wrote:
 Hi,

 Why keep both butlast and drop-last in clojure.core? The latter has the
 advantage that it's lazy and can drop off more than one element from the
 end of a seq. In contrast, I can't think of any advantage of butlast,
 except that it seems to be slightly (ca 20%) faster than (doall (drop-last
 x)). Wrapping drop-last in a doall should not be normally necessary, though.

 Should butlast be deprecated?

 Thanks,
 Daniel

-- 
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] Incorporating a database as a source of facts

2011-11-23 Thread Mark
I'd like to incorporate a relational database as a source of facts into the 
core.logic fact system.  Several years ago, I worked with a Java backwards 
reasoning system called Mandarax (http://mandarax.sourceforge.net/) which 
defined an interface between the logic engine and a fact store.  The 
various implementations would take the constraints supplied by the engine, 
translate them to datastore-specific query and return a set of facts that 
matched (see org.mandarax.kernel.KnowledgeOwner and ClauseSet).  I'd really 
like something like that for core.logic.

I can't figure out where to plug into.  If someone can point me to the 
particular protocol(s) to implement, I think I can map the constraints into 
SQL,

-- 
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] Incorporating a database as a source of facts

2011-11-23 Thread David Nolen
Sounds interesting. I can't offer much guidance on how to build such a
system but I'm certainly interested in improvements to core.logic's
interface to make implementing such things simpler.

What exactly do you expect core.logic to do in this case?

David

On Wed, Nov 23, 2011 at 5:52 PM, Mark markaddle...@gmail.com wrote:

 I'd like to incorporate a relational database as a source of facts into
 the core.logic fact system.  Several years ago, I worked with a Java
 backwards reasoning system called Mandarax (
 http://mandarax.sourceforge.net/) which defined an interface between the
 logic engine and a fact store.  The various implementations would take the
 constraints supplied by the engine, translate them to datastore-specific
 query and return a set of facts that matched (see
 org.mandarax.kernel.KnowledgeOwner and ClauseSet).  I'd really like
 something like that for core.logic.

 I can't figure out where to plug into.  If someone can point me to the
 particular protocol(s) to implement, I think I can map the constraints into
 SQL,

 --
 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] Incorporating a database as a source of facts

2011-11-23 Thread Mark
Let's take a specific example:  Suppose I have a Person table with id, name 
and gender columns.  Then, I have a Parent-Child table that contains two id 
columns,  both of which are foreign keys back into the Person table.  I'd 
could use the logic system to define a set of rules about family 
relationships.  I could express a query in logic terms which would then be 
translated into a series of SQL calls to obtain the results (forget any 
optimization concerns for the moment).

Conceptually, this is really no different than what can be done using the 
facts function today.  The difference is that my facts are stored in a 
database rather than in memory.

-- 
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] Incorporating a database as a source of facts

2011-11-23 Thread Mark
It occurs to me I may not have fully answered your question.  I'd like 
core.logic to supply a set on constraints which my code would convert into 
a SELECT statement and then return a seq of something (vectors? maps? 
facts?) that the engine would then use to reason, potentially driving 
additional queries.

I'm not familiar with core.logic internals but I suspect that the 
constrains could be expressed as a vector of relation names and maps.  
Something like [Parent-Child {:parent Mark :child nil}].  My SQL 
implementation would translate that into SELECT name FROM Parent, 
Parent-Child WHERE Parent-Child.id=Parent.id AND Parent.name='Mark'.  


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

Clojure 1.3.0 and reduce order of evaluation

2011-11-23 Thread James Reeves
Hi folks,

I've just noticed that the evaluation order for reduce differs slight
between Clojure 1.2.1 and 1.3.0.

If you have a lazy seq xs, (b c d ...) and an expression (reduce f a
xs), then the initial evaluation order in 1.2.1 is what you'd expect:

a, b, (f a b)

But in 1.3.0, it's slightly different:

a, b, c, (f a b)

For reasons that I can't quite work out, reduce in 1.3.0 evaluates the
first two items of a seq before evaluating the first accumulator (f a
b), even when reduce is supplied with an initial value.

Technically I shouldn't have code that relies on the evaluation order
of lazy seqs, but I just thought I'd post this just in case anyone ran
into a similar problem. I'm now rearranging my code so that any
side-effects are pulled out of the Java iterator before I turn it into
a seq.

- James

-- 
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] Incorporating a database as a source of facts

2011-11-23 Thread David Nolen
Seems possible but I can't say much more than that. core.logic operates on
tuples, so you could extract the resultset form the DB and pass them along
to core.logic to constrain further without much difficulty.

David

On Wed, Nov 23, 2011 at 6:24 PM, Mark markaddle...@gmail.com wrote:

 It occurs to me I may not have fully answered your question.  I'd like
 core.logic to supply a set on constraints which my code would convert into
 a SELECT statement and then return a seq of something (vectors? maps?
 facts?) that the engine would then use to reason, potentially driving
 additional queries.

 I'm not familiar with core.logic internals but I suspect that the
 constrains could be expressed as a vector of relation names and maps.
 Something like [Parent-Child {:parent Mark :child nil}].  My SQL
 implementation would translate that into SELECT name FROM Parent,
 Parent-Child WHERE Parent-Child.id=Parent.id AND Parent.name='Mark'.


  --
 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] Incorporating a database as a source of facts

2011-11-23 Thread Mark
Cool!  I'll keep an eye out for the update.  

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: Clojure 1.3.0 and reduce order of evaluation

2011-11-23 Thread Kevin Downey
On Wed, Nov 23, 2011 at 3:33 PM, James Reeves jree...@weavejester.com wrote:
 Hi folks,

 I've just noticed that the evaluation order for reduce differs slight
 between Clojure 1.2.1 and 1.3.0.

 If you have a lazy seq xs, (b c d ...) and an expression (reduce f a
 xs), then the initial evaluation order in 1.2.1 is what you'd expect:

 a, b, (f a b)

 But in 1.3.0, it's slightly different:

 a, b, c, (f a b)

 For reasons that I can't quite work out, reduce in 1.3.0 evaluates the
 first two items of a seq before evaluating the first accumulator (f a
 b), even when reduce is supplied with an initial value.

 Technically I shouldn't have code that relies on the evaluation order
 of lazy seqs, but I just thought I'd post this just in case anyone ran
 into a similar problem. I'm now rearranging my code so that any
 side-effects are pulled out of the Java iterator before I turn it into
 a seq.

 - James

the change to the internal reduce protocol required moving the seq
argument to the first argument position, so in the recur you have to
do something like

(recur (next the-seq) (f accum (first the-seq)))

so natural the call to next happens first

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



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

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


Lookup on a symbol?

2011-11-23 Thread Sean Corfield
@lloyda2 posted on Twitter: (reduce 'and '(false true)) = true ...Huh?

I must admit, it looked odd to me... but I realized (after some REPL
experimentation) this seems to be equivalent to ('some-symbol
:some-key :some-default) and that attempts (and fails) to somehow
lookup :some-key in 'some-symbol and thus returns the default
supplied, :some-default - or, in the OP's case ('and false true) which
yields true.

Can someone provide a bit more insight into why clojure.lang.Symbol
behaves like a collection and what, if any elements does it have? It
just seems like weird behavior and I can't imagine what use case this
addresses...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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: Lookup on a symbol?

2011-11-23 Thread Alan Malloy
Other way round. It behaves like a keyword, looking itself up in a
map:
('x '{x 1 y 2}) yields 2. You see the same behavior with (reduce :and
[5 10]), yielding 10.

On Nov 23, 9:32 pm, Sean Corfield seancorfi...@gmail.com wrote:
 @lloyda2 posted on Twitter: (reduce 'and '(false true)) = true ...Huh?

 I must admit, it looked odd to me... but I realized (after some REPL
 experimentation) this seems to be equivalent to ('some-symbol
 :some-key :some-default) and that attempts (and fails) to somehow
 lookup :some-key in 'some-symbol and thus returns the default
 supplied, :some-default - or, in the OP's case ('and false true) which
 yields true.

 Can someone provide a bit more insight into why clojure.lang.Symbol
 behaves like a collection and what, if any elements does it have? It
 just seems like weird behavior and I can't imagine what use case this
 addresses...
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View --http://corfield.org/
 World Singles, LLC. --http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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: use namespace locally in a function

2011-11-23 Thread Igor TN
Nils, thanks for the insight! I am relatively new to Lisps and your
comment is worth analyzing.

- Igor

On Nov 23, 5:27 pm, Nils Bertschinger
nils.bertschin...@googlemail.com wrote:
 Clojure is a Lisp, so it should be possible to extend it yourself ...
 What about something like this?

 (defmacro locally-using
   Allows to use symbols from other namespace in the local scope
 of the macro body.
 Syntax: (locally-using [symbol*] :from namespace
           body)
   [symbols from ns-name  body]
   (assert (= from :from) Wrong syntax ... delimiter :from missing or
 misplaced!)
   (let [local-vars (map (fn [sym] (symbol (str ns-name) (str sym)))
 symbols)]
     `(do (require '~ns-name)
          (symbol-macrolet [~@(interleave symbols local-vars)]
                           ~@body

 which then let's you write:
 (locally-using [split] :from clojure.string (split Hello world #
 ))

 The above macro could probably be made smarter to only require the lib
 if it not already loaded and also unload when it is done in this
 case. But since you have to load the lib anyways to use it and
 qualified names do not clutter your current namespace, the above
 version seems to be good enough.

 Cheers,

     Nils

 On Nov 23, 4:40 am, Igor TN igor...@gmail.com wrote:







  Yes, I meant local context. In principle, this could help to avoid
  namespacing conflicts in certain cases. But not a big deal, just
  wondering if the language supports that. Apparently not. Cool with me.
  Thanks everybody!

  On Nov 22, 6:59 pm, Alex Baranosky alexander.barano...@gmail.com
  wrote:

   Looks like he'd like to make a namespace available *only* in a local
   context, which some languages support, like Scala, for one.  I never have 
   a
   need for that, really.

-- 
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: Lookup on a symbol?

2011-11-23 Thread Sean Corfield
On Wed, Nov 23, 2011 at 9:48 PM, Alan Malloy a...@malloys.org wrote:
 Other way round. It behaves like a keyword, looking itself up in a
 map:
 ('x '{x 1 y 2}) yields 2. You see the same behavior with (reduce :and
 [5 10]), yielding 10.

Ah... I didn't realize that the lookup could be done without an
exception on non-collections!

(:a 1 2) yields 2 which surprises me a bit... I'd expect an error
because 1 is not a collection that :a can look itself up in.

Learn something new every day! :)
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

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