Re: Coding while running the program

2013-03-23 Thread Rob Lachlan
Ring offers functionality for automatic reloading if you happen to be 
developing a  web app.  

See here:
https://github.com/mmcgrana/ring/wiki/Interactive-Development

On Saturday, March 23, 2013 7:22:14 AM UTC-7, Oskar Kvist wrote:
>
> Hi!
>
> I saw this video http://www.youtube.com/watch?v=BES9EKK4Aw4 of Notch 
> coding on Minecraft while the game was running, and of course seeing the 
> changes in the running program. He used some kind of debug mode in his IDE 
> (I don't really know which IDE). I want to make a game, and I want to to 
> also be able to code while the program is running. I know this sort of 
> thing is common in Lisps, so even without that IDE's debug mode it should 
> be possible. Is there anything in particular that I need to do or look out 
> for in order to make it work? Are there some JVM settings I should use? 
> Does anyone know how that debug mode works? I kind of understand how it can 
> be done with a plain repl, but I don't wanna miss out on anything that 
> would make it easier. Any kind of insight is very appreciated.
>

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




Re: [ANN] Clojure Cup 2013

2013-04-28 Thread Rob Lachlan
That looks like so much fun; can't wait!

On Sunday, April 28, 2013 2:59:23 AM UTC-7, Tero Parviainen wrote:
>
> I've started putting together Clojure Cup, a global programming 
> competition for Clojure and ClojureScript programmers. The idea is to have 
> a 48-hour hackathon, similar to Rails Rumble and Node.js Knockout. Those 
> events have been great fun, and I'm hoping we can put together something 
> similar for all the Clojure programmers out there.
>
> The dates have been set to September 28-29, and there's a teaser site up 
> at http://clojurecup.com
>
> I've been talking to some community members about joining as expert 
> judges, and I'm happy to say some great people have already agreed to 
> participate.
> Right now I'm starting to talk to potential sponsors for the competition. 
> If you know some companies who might be interested in sponsoring (things 
> like prizes, free online services for the contestants...), please get in 
> touch.
>
> Any ideas, comments or questions are more than welcome!
>

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




Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-11 Thread Rob Lachlan
Doesn't anyone use "not-empty"?

http://clojuredocs.org/clojure_core/clojure.core/not-empty


On Saturday, May 11, 2013 1:36:57 AM UTC-7, Nico Balestra wrote:
>
> I'm not sure this question has been asked already, but I really want to 
> know the "principle" behind (not (empty? coll)) not being idiomatic.
>
> I find it much more readable than (seq coll) and I don't understand why 
> (empty?) exists if it's not idiomatic. But my real doubt is:
>
> What's the "idiom" in (seq coll)?
>
> Thanks and sorry if the question sounds a bit pedantic :)
>
> Nico
>
> *"It is better to have 100 functions operate on one data structure than 
> to have 10 functions operate on 10 data structures" - A.J. Perlis*
>  

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




Re: Graph API

2013-06-17 Thread Rob Lachlan
Loom was indeed working on this, and it's a very nice library.  One thing 
that I particularly liked about Justin's design, was the ability to run a 
graph algorithm without worrying about conforming to a particular graph 
representation.  See for example the bread first search function, here:

https://github.com/jkk/loom/blob/master/src/loom/alg_generic.clj#L110

All the bfs function requires is a neighbors function and and a start 
vertex.  Simple and easy to use.

Justin had said that he won't be actively developing loom for the 
forseeable future; I was hoping to develop it further, but I only got as 
far as implementing a max flow algorithm before the rest of my life got in 
the way of my plans.  I know that Aysylu was doing a fair amount of work on 
loom, so I'd guess that her repo is the most advanced one.

Stephen:
I think the set of protocols above is good, better than Loom's in fact; 
notably, the decision to make direct-predecessors optional is the correct 
one, and a lot of graph libraries get that wrong.  

If you want to compare how loom did it:
https://github.com/jkk/loom/blob/master/src/loom/graph.clj





On Monday, June 17, 2013 1:14:34 PM UTC-7, dgrnbrg wrote:
>
> I think that there's already a project working on this called Loom. The 
> furthest-developed fork is here: https://github.com/aysylu/loom which 
> appears to have protocols for graphs, bindings to Titanium (the 
> Clojurewerkz graph DB library), visualization support, and implementations 
> of several algorithms.
>
> Maybe there's a way to incorporate these projects?
>
> On Monday, June 17, 2013 3:38:45 PM UTC-4, Stephen Kockentiedt wrote:
>>
>> Hello,
>>
>> I want to create a graph API similar to what core.matrix is for matrices. 
>> I have created some protocols which every graph implementation has to 
>> satisfy and a prototype implementation. Now I want your feedback on these 
>> protocols. Which functions do you want to see which aren't there? Which 
>> functions should be changed? Are there problems with the general design? 
>> Have you any other feedback?
>>
>> Here are the protocol definitions:
>>
>> (defprotocol PGraph
>>   "Minimal functionality of a graph."
>>   (directed? [g]
>> "Returns true if the graph is directed and false if the
>>  graph is undirected. If it is undirected, all functions
>>  taking two nodes must be commutative with regard to
>>  these nodes.")
>>   (nodes [g]
>> "Returns a set or sequence of all nodes of the graph. May
>>  not contain duplicates.")
>>   (has-edge? [g n1 n2]
>> "Returns true if the graph g has an edge from node n1
>>  to node n2.")
>>   (direct-successors [g n]
>> "Returns a set or sequence of all nodes n2 for which
>>  (has-edge? g n n2) returns true. May not contain
>>  duplicates."))
>>
>> (defprotocol PPredecessorGraph
>>   "Optional functionality of a graph which can give a
>>list of all direct predecessors of a node."
>>   (direct-predecessors [g n]
>> "Returns a set or sequence of all nodes n2 for which
>>  (has-edge? g n2 n) returns true. May not contain
>>  duplicates."))
>>
>> (defprotocol PEditableGraph
>>   "Minimal functionality of an editable graph."
>>   (mutable? [g]
>> "Returns true if the graph is mutated in place.
>>  If true is returned, the other functions change
>>  the graph passed as the first argument and return
>>  the same graph object. If false is returned, the
>>  functions return a new graph and the old graph is
>>  unchaged.")
>>   (add-node [g n]
>> "Adds the node n to the graph g. If it already
>>  contained n, the graph will not be changed.")
>>   (remove-node [g n]
>> "Removes the node n from the graph g. If it did
>>  not contain n, the graph will not be changed.")
>>   (add-edge [g n1 n2]
>> "Adds an edge from node n1 to node n2 to the graph g.
>>  If one or both of the nodes is not present it will
>>  be added to the graph. If the edge was already present,
>>  the graph will not be changed.")
>>   (remove-edge [g n1 n2]
>> "Removes the edge from node n1 to the node n2 from
>>  the graph g. If it did not contain the edge, the graph
>>  will not be changed."))
>>
>> (defprotocol PWeightedGraph
>>   "Functionality of a graph whose edges can be weighted."
>>   (edge-weight [g n1 n2]
>> "Returns the weight of the edge from node n1 to
>>  node n2."))
>>
>> (defprotocol PEditableWeightedGraph
>>   "Functionality of a weighted graph whose weights can be
>>changed."
>>   (update-edge-weight [g n1 n2 f]
>> "Updates the weight of the edge from node n1 to node n2,
>>  where f is a function taking the old value and returning
>>  the new one. If the graph did not contain the edge, it
>>  will be created."))
>>
>> (defprotocol PNodeDataGraph
>>   "Functionality of a graph which stores data with its
>>nodes."
>>   (node-data [g n]
>> "Returns the data of the node n."))
>>
>> (defprotocol PEdita

Re: Order of keys within a map?

2009-09-01 Thread Rob Lachlan

As, Patrick Sullivan, said, the built-in sorted-map guarantees that
the keys will be in order.  I'm probably missing something here, but
wouldn't that fit the bill?

http://clojure.org/api#sorted-map

Rob Lachlan

On Aug 27, 12:35 pm, Howard Lewis Ship  wrote:
> Is the order of keys in a map predictable?  I have some tests I'm
> concerned about, where the keys and values in a map are converted to a
> string (ultimately, a URL, as query parameters) and the order will
> affect the output string.
>
> I could sort the keys, but then I'm changing my code to support the
> test in a somewhat non-trivial way.
>
> Literally: when iterating over the key/value pairs, the order seems to
> be the order in which the key/values are defined in the map. Is this
> true?
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!

--~--~-~--~~~---~--~~
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.matrix" proposal

2013-01-05 Thread Rob Lachlan
I really like this idea -- I think there's a need for a dedicated matrix 
computation library in clojure.  I really like the idea of having matrix 
operations implemented in clojure (I think that you have this in 
persistent_vector.clj) but also being able to call on java libraries.


On Saturday, January 5, 2013 2:00:23 AM UTC-8, Mikera wrote:
>
> Hello all,
>
> I've been experimenting with a common API / abstraction for matrix and 
> vector maths in Clojure:
>
>   https://github.com/mikera/matrix-api
>
> The idea is:
>  - Provide a clear, consistent API for matrix and vector operations
>  - Support multiple different underlying implementations (e.g. native code 
> via JBLAS vs pure Java like vectorz-clj)
>  - Provide a base which other libraries that need to consume matrices can 
> build upon (e.g. Incanter)
>  - Offer good performance while still presenting a reasonably flexible 
> high level API
>
> I think this could be very useful for the Clojure community, especially 
> given the interest in big data, simulations, machine learning, 3D graphics 
> etc. If it goes well and there is enough interest, I guess that this could 
> form the basis for a future "core.matrix" library.
>
> Comments / ideas / patches welcome.
>
>   Mike.
>

-- 
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: Has deftype changed?

2010-04-18 Thread Rob Lachlan
For deeftype, has the syntax for field accessors changed too?

I can't get it to work:

user> (deftype someType [b f])
user.someType
user> (def y (new someType 2 3))
#'user/y
user> (:b y)
nil
user> (:f y)
nil

defrecord works as expected, though.


On Apr 17, 6:16 pm, Andrew Stein  wrote:
> (deftype Bar [a b c d e])
> (def b (new Bar 1 2 3 4 5))
>
> There are a few other syntax changes too, defrecord replaces extending
> IPersistenMap, and you need to include 'this' in protocol fun
> implementations ...
>
> http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co...http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co...
>
> On Apr 17, 4:37 pm, Praki  wrote:
>
>
>
>
>
> > I am seeing compilation errors in my code with deftype. I just updated
> > my project dependencies and probably pulled in the latest clojure
> > package. Anyway, the following code from wiki doesn't work anymore.
> > Pointers to any late breaking changes much appreciated!
>
> > TIA
>
> > (deftype Bar [a b c d e])
> > (def b (Bar 1 2 3 4 5))
>
> > Expecting var, but Bar is mapped to class package.Bar
> >   [Thrown class java.lang.Exception]
>
> > Restarts:
> >  0: [ABORT] Return to SLIME's top level.
>
> > Backtrace:
> >   0: clojure.lang.Compiler.lookupVar(Compiler.java:5677)
> >   1: clojure.lang.Compiler.isMacro(Compiler.java:5178)
> >   2: clojure.lang.Compiler.macroexpand1(Compiler.java:5233)
> >   3: clojure.lang.Compiler.analyzeSeq(Compiler.java:5305)
> >   4: clojure.lang.Compiler.analyze(Compiler.java:5140)
> >   5: clojure.lang.Compiler.access$100(Compiler.java:35)
> >   6: clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:417)
> >   7: clojure.lang.Compiler.analyzeSeq(Compiler.java:5319)
> >   8: clojure.lang.Compiler.analyze(Compiler.java:5140)
> >   9: clojure.lang.Compiler.analyze(Compiler.java:5101)
> >  10: clojure.lang.Compiler.eval(Compiler.java:5377)
> >  11:
>
> > --
> > 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 
> > athttp://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 
> athttp://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: Has deftype changed?

2010-04-18 Thread Rob Lachlan
Ah, thank you.

So what are the use cases for defrecord and deftype, now?

Earlier Rich Hickey said we should prefer deftype to defstruct
unconditionally.  Is this role now played by defrecord?  And if so,
will defstruct be deprecated?

And where should deftype be used instead?



On Apr 18, 10:53 am, David Nolen  wrote:
> On Sun, Apr 18, 2010 at 1:49 PM, Rob Lachlan wrote:
>
> > For deeftype, has the syntax for field accessors changed too?
>
> > I can't get it to work:
>
> > user> (deftype someType [b f])
> > user.someType
> > user> (def y (new someType 2 3))
> > #'user/y
> > user> (:b y)
> > nil
> > user> (:f y)
> > nil
>
> > defrecord works as expected, though.
>
> deftype now generates a Java class.
>
> (.b y)
> (.f y)
>
> should work
>
> 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 
> athttp://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


Extremely silly benchmarks, on types, records and maps.

2010-05-12 Thread Rob Lachlan
Is there some reason why accessing the values in a type (from deftype)
should be slower than for a record?  The type seems to be very fast to
instantiate, but slow to access.

(I was just playing around, trying to get a feel for the relative
performance characteristics of types records and maps.  )

user> (defrecord testRec [a b c])
user.testRec
user> (deftype testType [a b c])
user.testType

The results for instantiation were roughly in a pattern that I would
have expected:

user> (time (dotimes [_ 100] (hash-map :a 1 :b 1 :c 1)))
"Elapsed time: 973.872 msecs"
nil
user> (time (dotimes [_ 100] (new testRec 1 1 1)))
"Elapsed time: 46.315 msecs"
nil
user> (time (dotimes [_ 100] (new testType 1 1 1)))
"Elapsed time: 39.562 msecs"
nil

For accessing however, the type seemed inordinately slow:

user> (def myhash {:a 1 :b 2 :c 3})
#'user/myhash
user> (def myRec (new testRec 1 2 3))
#'user/myRec
user> (def myType (new testType 1 2 3))
#'user/myType
user> (time (dotimes [_ 1000] (:a myhash)))
"Elapsed time: 298.436 msecs"
nil
user> (time (dotimes [_ 1000] (:a myRec)))
"Elapsed time: 165.879 msecs"
nil
user> (time (dotimes [_ 1000] (.a myType)))
"Elapsed time: 28100.919 msecs"
nil

I don't pretend that these are at all rigorous benchmarks, but I'm
curious where the apparent overhead comes from in accessing a value in
a type object.

Rob

p.s. For what it's worth, I started the REPL with the -server flag.

-- 
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: Extremely silly benchmarks, on types, records and maps.

2010-05-12 Thread Rob Lachlan
Ah.  That makes sense, thanks very much.

Rob

On May 12, 10:36 pm, Harvey Hirst  wrote:
> It's slow because it has to use reflection to determine the type.
> Use (set! *warn-on-reflection* true) and you'll see the warning.
>
> Try something like this and you'll see significantly faster results:
>
> (let [#^testType t (new testType 1 2 3)]
>   (time (dotimes [_ 1000] (.a t)))
>
> Harvey
> --
> "You're keeping me alive because you don't know DOS?"
> Izzy, Prophecy II
>
> --
> 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 
> athttp://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: new Clojure Compiler...

2010-05-16 Thread Rob Lachlan
> for the persistent data.. well all this "laziness" and dinamic types, and on
> top of that immutability should not perform well in pure clojure

Why?

-- 
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: Mac Emacs users: which version do you prefer (Aquamacs, Carbon Emacs, other?)

2010-06-12 Thread Rob Lachlan
I agree that the cocoa builds are the nicest.  But there is one
problem that I've had with them: I wasn't able to successfully install
swank-clojure through elpa from within that emacs.  Curiously, I was
able to install it through elpa in aquamacs, and then I had no problem
using swank-clojure from within the cocoa (emacsforosx.com) emacs.

I'm at a loss to account for this, and I don't have the emacs-fu to
debug this.

All that aside, yeah the cocoa (emacsforosx.com) builds are very nice,
minimalist and very functional.

On Jun 12, 3:31 pm, Phil Hagelberg  wrote:
> On Sat, Jun 12, 2010 at 5:25 AM, Thomas Kjeldahl Nilsson
>
>  wrote:
> > What are the major differences in the different distributions,
> > particularly for Clojure development?
>
> > I've got everything (Slime, Paredit, Clojure-mode etc) set up in
> > Carbon emacs and it works great, just curious if there are any
> > substantials gains to be had in Aquamacs or other alternative
> > distributions. :)
>
> Carbon Emacs is pretty outdated; it's based on Emacs 22. (c. 2007)
> Aquamacs messes up a lot of the defaults and isn't portable, so most
> elisp library authors can't test on it or help you debug problems
> you're having with it. I recommend the Cocoa build of GNU 
> Emacs:http://emacsformacosx.comhas prebuilt binaries.
>
> -Phil

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


Re: Mac Emacs users: which version do you prefer (Aquamacs, Carbon Emacs, other?)

2010-06-13 Thread Rob Lachlan
Probably, but I'm at a loss to figure out exactly what it might be.  I
cleaned emacs off, along with the .emacs.d directory, reinstalled, and
the problem reappeared. I'm not touching it right now since, as I
mentioned, I managed too bootstrap using aquamacs.


On Jun 13, 12:42 am, Thomas Kjeldahl Nilsson
 wrote:
> Weird - I installed the Cocoa build last night, and got everything set
> up via elpa including swank-clojure. Some local problem?
>
> Regards,
> Thomas Kjeldahl Nilsson
>
>
>
> On Sun, Jun 13, 2010 at 2:02 AM, Rob Lachlan  wrote:
> > I agree that the cocoa builds are the nicest.  But there is one
> > problem that I've had with them: I wasn't able to successfully install
> > swank-clojure through elpa from within that emacs.  Curiously, I was
> > able to install it through elpa in aquamacs, and then I had no problem
> > using swank-clojure from within the cocoa (emacsforosx.com) emacs.
>
> > I'm at a loss to account for this, and I don't have the emacs-fu to
> > debug this.
>
> > All that aside, yeah the cocoa (emacsforosx.com) builds are very nice,
> > minimalist and very functional.
>
> > On Jun 12, 3:31 pm, Phil Hagelberg  wrote:
> >> On Sat, Jun 12, 2010 at 5:25 AM, Thomas Kjeldahl Nilsson
>
> >>  wrote:
> >> > What are the major differences in the different distributions,
> >> > particularly for Clojure development?
>
> >> > I've got everything (Slime, Paredit, Clojure-mode etc) set up in
> >> > Carbon emacs and it works great, just curious if there are any
> >> > substantials gains to be had in Aquamacs or other alternative
> >> > distributions. :)
>
> >> Carbon Emacs is pretty outdated; it's based on Emacs 22. (c. 2007)
> >> Aquamacs messes up a lot of the defaults and isn't portable, so most
> >> elisp library authors can't test on it or help you debug problems
> >> you're having with it. I recommend the Cocoa build of GNU 
> >> Emacs:http://emacsformacosx.comhasprebuilt binaries.
>
> >> -Phil
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To 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


Serious problem with underive (for hierarchies), an attempt to fix, and request for code review.

2010-06-15 Thread Rob Lachlan
I think that the underive function for removing hierarchy
relationships between keywords is broken.  I'll illustrate with an
example and describe what I think the problems are.  I've got some
code for a function which (I hope!) performs underive correctly, and
I'd love it if people had a look.

Consider a hierarchy with child-parent relationships:

:c -> :p1,  :c -> :p2, :p1 -> :a1, :p1 -> :a2, :p2 -> :a2

Which I'll illustrate with the world's worst ascii art:

a1a2
|   /   |
|   /   |
|   /   |
p1p2
|   /
|   /
|  /
c

;  creating this hierarchy:
user> (def h (reduce #(apply derive (cons %1 %2)) (make-hierarchy)
 [[:p1 :a1] [:p1 :a2] [:p2 :a2] [:c :p2] [:c :p1]]))
#'user/h
user> h
{:parents {:c #{:p1 :p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :ancestors {:c
#{:p1 :p2 :a2 :a1}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :descendants {:p1
#{:c}, :p2 #{:c}, :a2 #{:p1 :p2 :c}, :a1 #{:p1 :c}}}



Now the underive:

user> (underive h :c :p1)
{:parent {:c #{:p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :ancestors {:c
#{:p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :descendants {:p1 #{}, :p2
#{:c}, :a2 #{:p1 :p2}, :a1 #{:p1}}}


Problems:

Most seriously, it is incorrect: :c should still show up as a
descendant of
:a2, since :c is a child of :p2, and :p2 a child of :a2.  Note that
the
parent map is correct, so it is the ancestor and descendant maps which
are
inconsistent.

Also, notice that the key for the parent map has changed from :parents
to
:parent, which causes calls to the parents function to return nil.

Also, keys which map to empty sets are left in each of the maps
(parents,
descendants and ancestors), with the result that equality tests could
fail
in some cases in which they would be true.


Potential fix, and request for code review:

I've written an underive-new function which appears to fix these
problems,
at least in the tests that I've done.

http://pastebin.com/eRiz5ihw

My approach is to identify the sets of tags in the hierarchy whose
ancestors
or descendants may be affected, remove their ancestor or descendant
mappings,
then rebuild them.  In a call (underive h child parent), the child and
all
the child's descendants will need to have their ancestor mappings
fixed.
Similarly, the parent and all of the parent's ancestors will need to
have
their descendant mappings rebuilt.

(As an aside, the problem here is that our hierarchy can be a DAG
rather
a tree, because multiple inheritance is allowed.  And therefore, for
any
ancestor/descendant relationship it's comparatively expensive to
determine
whether a particular parent-child edge is essential or not.)

Next, the two sets of interest (child + child's descendants, and
parent +
parent's ancestors) are sorted topologically.  For the child +
child's
descendants, we can now rebuild the ancestor mappings by taking a tag
from
the top of the set, setting its ancestors to the union of tag's
parents and
parents' ancestors, and repeating the process on the next tag in
topologically
sorted order until all tags are consumed.  The parent + parent's
ancestors
can be done in a similar way, except that a children function is
required, and
the tags must be topologically sorted in the reverse direction.


Some remarks:

An alternative approach would be to just recompute the whole ancestor
and
descendant maps for the whole hierarchy.  This would be simpler, but
for
large hierarchies would be unnecessarily expensive.

The topological sort function which I wrote avoids recursion.  If we
wanted
to allow multiple recursion, it could be simplified a bit, but I
wanted to
avoid stack consumption.

Anyway, I'd appreciate any suggestions and criticisms, since this is
the
first clojure code of mine that anyone has looked at.

-- 
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: Serious problem with underive (for hierarchies), an attempt to fix, and request for code review.

2010-06-15 Thread Rob Lachlan
Oh God.  What broken formatting.  Sorry about that.

On Jun 15, 4:24 pm, Rob Lachlan  wrote:
> I think that the underive function for removing hierarchy
> relationships between keywords is broken.  I'll illustrate with an
> example and describe what I think the problems are.  I've got some
> code for a function which (I hope!) performs underive correctly, and
> I'd love it if people had a look.
>
> Consider a hierarchy with child-parent relationships:
>
> :c -> :p1,  :c -> :p2, :p1 -> :a1, :p1 -> :a2, :p2 -> :a2
>
> Which I'll illustrate with the world's worst ascii art:
>
> a1            a2
> |           /   |
> |       /       |
> |   /           |
> p1            p2
> |           /
> |       /
> |  /
> c
>
> ;  creating this hierarchy:
> user> (def h (reduce #(apply derive (cons %1 %2)) (make-hierarchy)
>                      [[:p1 :a1] [:p1 :a2] [:p2 :a2] [:c :p2] [:c :p1]]))
> #'user/h
> user> h
> {:parents {:c #{:p1 :p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :ancestors {:c
> #{:p1 :p2 :a2 :a1}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :descendants {:p1
> #{:c}, :p2 #{:c}, :a2 #{:p1 :p2 :c}, :a1 #{:p1 :c}}}
>
> Now the underive:
>
> user> (underive h :c :p1)
> {:parent {:c #{:p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :ancestors {:c
> #{:p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :descendants {:p1 #{}, :p2
> #{:c}, :a2 #{:p1 :p2}, :a1 #{:p1}}}
>
> Problems:
>
> Most seriously, it is incorrect: :c should still show up as a
> descendant of
> :a2, since :c is a child of :p2, and :p2 a child of :a2.  Note that
> the
> parent map is correct, so it is the ancestor and descendant maps which
> are
> inconsistent.
>
> Also, notice that the key for the parent map has changed from :parents
> to
> :parent, which causes calls to the parents function to return nil.
>
> Also, keys which map to empty sets are left in each of the maps
> (parents,
> descendants and ancestors), with the result that equality tests could
> fail
> in some cases in which they would be true.
>
> Potential fix, and request for code review:
>
> I've written an underive-new function which appears to fix these
> problems,
> at least in the tests that I've done.
>
> http://pastebin.com/eRiz5ihw
>
> My approach is to identify the sets of tags in the hierarchy whose
> ancestors
> or descendants may be affected, remove their ancestor or descendant
> mappings,
> then rebuild them.  In a call (underive h child parent), the child and
> all
> the child's descendants will need to have their ancestor mappings
> fixed.
> Similarly, the parent and all of the parent's ancestors will need to
> have
> their descendant mappings rebuilt.
>
> (As an aside, the problem here is that our hierarchy can be a DAG
> rather
> a tree, because multiple inheritance is allowed.  And therefore, for
> any
> ancestor/descendant relationship it's comparatively expensive to
> determine
> whether a particular parent-child edge is essential or not.)
>
> Next, the two sets of interest (child + child's descendants, and
> parent +
> parent's ancestors) are sorted topologically.  For the child +
> child's
> descendants, we can now rebuild the ancestor mappings by taking a tag
> from
> the top of the set, setting its ancestors to the union of tag's
> parents and
> parents' ancestors, and repeating the process on the next tag in
> topologically
> sorted order until all tags are consumed.  The parent + parent's
> ancestors
> can be done in a similar way, except that a children function is
> required, and
> the tags must be topologically sorted in the reverse direction.
>
> Some remarks:
>
> An alternative approach would be to just recompute the whole ancestor
> and
> descendant maps for the whole hierarchy.  This would be simpler, but
> for
> large hierarchies would be unnecessarily expensive.
>
> The topological sort function which I wrote avoids recursion.  If we
> wanted
> to allow multiple recursion, it could be simplified a bit, but I
> wanted to
> avoid stack consumption.
>
> Anyway, I'd appreciate any suggestions and criticisms, since this is
> the
> first clojure code of mine that anyone has looked at.

-- 
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: Serious problem with underive (for hierarchies), an attempt to fix, and request for code review.

2010-06-15 Thread Rob Lachlan
As an alternative, if we're willing to rebuild the entire hierarchy,
not just the subgraph that's affected by the underivation,
we can just do this:

(defn easy-underive [h child parent]
  (let [oldParents (:parents h)
childsParents (disj (clojure.set/union #{} (child oldParents))
parent)
newParents (if (not-empty childsParents)
 (assoc oldParents child childsParents)
 (dissoc oldParents child))
derivation-seq (flatten (map #(cons (key %) (interpose (key %) (val
%)))
(seq newParents)))]
(reduce #(apply derive (cons %1 %2)) (make-hierarchy)
(partition 2 derivation-seq

It's less efficient, because it tosses out all of the information in
the ancestor and descendant sets.  But it is a good deal simpler -- 10
lines of code instead of 60 or so.  For small hierarchies this would
be fine.  If anyone were to make large
hierarchies which had to be modified efficiently, though, I think
something like in the first message would be required.

On Jun 15, 4:29 pm, Rob Lachlan  wrote:
> Oh God.  What broken formatting.  Sorry about that.
>
> On Jun 15, 4:24 pm, Rob Lachlan  wrote:
>
>
>
> > I think that the underive function for removing hierarchy
> > relationships between keywords is broken.  I'll illustrate with an
> > example and describe what I think the problems are.  I've got some
> > code for a function which (I hope!) performs underive correctly, and
> > I'd love it if people had a look.
>
> > Consider a hierarchy with child-parent relationships:
>
> > :c -> :p1,  :c -> :p2, :p1 -> :a1, :p1 -> :a2, :p2 -> :a2
>
> > Which I'll illustrate with the world's worst ascii art:
>
> > a1            a2
> > |           /   |
> > |       /       |
> > |   /           |
> > p1            p2
> > |           /
> > |       /
> > |  /
> > c
>
> > ;  creating this hierarchy:
> > user> (def h (reduce #(apply derive (cons %1 %2)) (make-hierarchy)
> >                      [[:p1 :a1] [:p1 :a2] [:p2 :a2] [:c :p2] [:c :p1]]))
> > #'user/h
> > user> h
> > {:parents {:c #{:p1 :p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :ancestors {:c
> > #{:p1 :p2 :a2 :a1}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :descendants {:p1
> > #{:c}, :p2 #{:c}, :a2 #{:p1 :p2 :c}, :a1 #{:p1 :c}}}
>
> > Now the underive:
>
> > user> (underive h :c :p1)
> > {:parent {:c #{:p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :ancestors {:c
> > #{:p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :descendants {:p1 #{}, :p2
> > #{:c}, :a2 #{:p1 :p2}, :a1 #{:p1}}}
>
> > Problems:
>
> > Most seriously, it is incorrect: :c should still show up as a
> > descendant of
> > :a2, since :c is a child of :p2, and :p2 a child of :a2.  Note that
> > the
> > parent map is correct, so it is the ancestor and descendant maps which
> > are
> > inconsistent.
>
> > Also, notice that the key for the parent map has changed from :parents
> > to
> > :parent, which causes calls to the parents function to return nil.
>
> > Also, keys which map to empty sets are left in each of the maps
> > (parents,
> > descendants and ancestors), with the result that equality tests could
> > fail
> > in some cases in which they would be true.
>
> > Potential fix, and request for code review:
>
> > I've written an underive-new function which appears to fix these
> > problems,
> > at least in the tests that I've done.
>
> >http://pastebin.com/eRiz5ihw
>
> > My approach is to identify the sets of tags in the hierarchy whose
> > ancestors
> > or descendants may be affected, remove their ancestor or descendant
> > mappings,
> > then rebuild them.  In a call (underive h child parent), the child and
> > all
> > the child's descendants will need to have their ancestor mappings
> > fixed.
> > Similarly, the parent and all of the parent's ancestors will need to
> > have
> > their descendant mappings rebuilt.
>
> > (As an aside, the problem here is that our hierarchy can be a DAG
> > rather
> > a tree, because multiple inheritance is allowed.  And therefore, for
> > any
> > ancestor/descendant relationship it's comparatively expensive to
> > determine
> > whether a particular parent-child edge is essential or not.)
>
> > Next, the two sets of interest (child + child's descendants, and
> > parent +
> > parent's ancestors) are sorted topologically.  For the child +
> > child's
> > descendants, we can now rebuild the ancestor mappings by taking a tag
&g

Re: Serious problem with underive (for hierarchies), an attempt to fix, and request for code review.

2010-06-16 Thread Rob Lachlan
Hi Stuart,

I'll be mailing the agreement later today, and I'll work on a patch
shortly.  I've noticed that the unit tests file for multi-methods,
where tests for derive and underive would be located, is essentially
empty.  So I thought I might put some tests in there for isa, parents,
ancestors, etc. while I'm about it.

I take your point on preferring a simpler version.  I have a feeling
that:

-most people are using the global hierarchy
-most people are using the hierarchy essentially statically

which is a bit of a shame, since the hierarchy system is quite
powerful.  With independent hierarchies, you can confidently juggle
several hierarchy relationships, and dynamically update them.  I think
their uses go beyond multi-methods.

But for hierarchies which are largely static, and which will rarely
underive, a simpler underive in core will be good.  I'll probably put
my complicated version together with some other convenience functions
for hierarchies in a library of my own, in case anyone has a need for
it.

Rob

p.s. Loved the book.


On Jun 16, 7:54 am, Stuart Halloway  wrote:
> Hi Rob,
>
> Thanks for tracking this down. If you will execute a CA [1], I would love to 
> get a patch (with tests) that fixes this. I have created a ticket at [2] to 
> track it.
>
> I would prefer something along the lines of the simpler fix shown below, 
> unless anybody pops up on this thread with a real-world use case for 
> performance-critical underive.
>
> Stu
>
> [1]http://clojure.org/contributing
> [2]https://www.assembla.com/spaces/clojure/tickets/382-fix-underive-for-...
>
>
>
> > As an alternative, if we're willing to rebuild the entire hierarchy,
> > not just the subgraph that's affected by the underivation,
> > we can just do this:
>
> > (defn easy-underive [h child parent]
> >  (let [oldParents (:parents h)
> >    childsParents (disj (clojure.set/union #{} (child oldParents))
> > parent)
> >    newParents (if (not-empty childsParents)
> >                 (assoc oldParents child childsParents)
> >                 (dissoc oldParents child))
> >    derivation-seq (flatten (map #(cons (key %) (interpose (key %) (val
> > %)))
> >                        (seq newParents)))]
> >    (reduce #(apply derive (cons %1 %2)) (make-hierarchy)
> >        (partition 2 derivation-seq
>
> > It's less efficient, because it tosses out all of the information in
> > the ancestor and descendant sets.  But it is a good deal simpler -- 10
> > lines of code instead of 60 or so.  For small hierarchies this would
> > be fine.  If anyone were to make large
> > hierarchies which had to be modified efficiently, though, I think
> > something like in the first message would be required.
>
> > On Jun 15, 4:29 pm, Rob Lachlan  wrote:
> >> Oh God.  What broken formatting.  Sorry about that.
>
> >> On Jun 15, 4:24 pm, Rob Lachlan  wrote:
>
> >>> I think that the underive function for removing hierarchy
> >>> relationships between keywords is broken.  I'll illustrate with an
> >>> example and describe what I think the problems are.  I've got some
> >>> code for a function which (I hope!) performs underive correctly, and
> >>> I'd love it if people had a look.
>
> >>> Consider a hierarchy with child-parent relationships:
>
> >>> :c -> :p1,  :c -> :p2, :p1 -> :a1, :p1 -> :a2, :p2 -> :a2
>
> >>> Which I'll illustrate with the world's worst ascii art:
>
> >>> a1            a2
> >>> |           /   |
> >>> |       /       |
> >>> |   /           |
> >>> p1            p2
> >>> |           /
> >>> |       /
> >>> |  /
> >>> c
>
> >>> ;  creating this hierarchy:
> >>> user> (def h (reduce #(apply derive (cons %1 %2)) (make-hierarchy)
> >>>                      [[:p1 :a1] [:p1 :a2] [:p2 :a2] [:c :p2] [:c :p1]]))
> >>> #'user/h
> >>> user> h
> >>> {:parents {:c #{:p1 :p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :ancestors {:c
> >>> #{:p1 :p2 :a2 :a1}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :descendants {:p1
> >>> #{:c}, :p2 #{:c}, :a2 #{:p1 :p2 :c}, :a1 #{:p1 :c}}}
>
> >>> Now the underive:
>
> >>> user> (underive h :c :p1)
> >>> {:parent {:c #{:p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :ancestors {:c
> >>> #{:p2}, :p2 #{:a2}, :p1 #{:a2 :a1}}, :descendants {:p1 #{}, :p2
> >>> #{:c}, :a2 #{:p1 :p2}, :a1 #{:p1}}}
>
> >>> Problems:
>
> >>> Most seriously, it is incorrect: :

Re: Serious problem with underive (for hierarchies), an attempt to fix, and request for code review.

2010-06-16 Thread Rob Lachlan
I like the reference counting idea, YD.  I don't think that we want to
go that route, though, if underive will be called comparatively rarely
by most people.  But it would be a good way to do it if that
performance were needed.

Rob

On Jun 15, 10:39 pm, YD  wrote:
> Another apporach I think would be modifying the data structure of
> hierarchy itself. The idea is to add a counter to ancestors and
> descendants.
> :ancestors: { :c #{ [:a1 1] [:a2 2] } }
> So, the counter 2 on :a2 means how many paths can you get :c to
> reach :a2. When the counter reaches 0, you can remove it completely.
> Otherwise, decrement it.
>
> This approach requires to change all the functions related to
> hierarchy, and the data structure will be incompatible to the original
> one. But the speed is gonna be fast.

-- 
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: Recommendations on prepping a library for 1.2 release?

2010-06-16 Thread Rob Lachlan
> Do I need any branches? What are the branches? I thought that when a
> branch was stable it would be merged back into master (if I'm using
> the right terms).

The master branch for clojure is the main development branch for 1.2
(someone correct me if I'm wrong).  It's the one I'm using, and I'm
also using 1.2.  There are other branches, like num, if you want
efficient numerical computations.  In all likelihood, master is what
you want.

> When you say master branch, do you mean just core, or does that include 
> contrib?

Core has its master branch, and contrib has its own master branch.

> Speaking of which: Should I still care about contrib? I remember
> hearing that several items had been merged into core...

Probably you should, contrib has tons of other goodness.  See
http://richhickey.github.com/clojure-contrib/ for details.

Rob

-- 
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: Enhanced Primitive Support

2010-06-17 Thread Rob Lachlan
I think the enhanced support for primitives is fantastic.  I'm looking
forward to doing more numerical work in clojure.

Quibble:  Using a multiple-recursive algorithm for calculating
fibonnaci values.

user> (defn fib-2 [n] (if (>= n 1)
  (loop [i 0 f0 0 f1 1]
(if (== i n) f0 (recur (inc i)
   f1
   (+ f0 f1))
#'user/fib-2
user> (time (fib-2 38))
"Elapsed time: 0.12 msecs"
39088169

I understand that it's just for demonstration purposes, but
impressionable people (like me!) might not know better.
(Of course, we can calculate fibonacci values using the closed form
formula, but that's neither here nor there.)

Other than that, looks great.

Rob

On Jun 17, 1:13 pm, Rich Hickey  wrote:
> I've been doing some work to enhance the performance, and unify the
> semantics, of primitives, in three branches. I've started to document
> this work here:
>
> https://www.assembla.com/wiki/show/clojure/Enhanced_Primitive_Support
>
> Feedback welcome,
>
> Rich

-- 
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: Enhanced Primitive Support

2010-06-17 Thread Rob Lachlan
Ah -- well that makes sense then.  Bravo!

Rob

On Jun 17, 2:15 pm, Rich Hickey  wrote:
> On Jun 17, 5:10 pm, Rob Lachlan  wrote:
>
> > I think the enhanced support for primitives is fantastic.  I'm looking
> > forward to doing more numerical work in clojure.
>
> > Quibble:  Using a multiple-recursive algorithm for calculating
> > fibonnaci values.
>
> > user> (defn fib-2 [n] (if (>= n 1)
> >                   (loop [i 0 f0 0 f1 1]
> >                     (if (== i n) f0 (recur (inc i)
> >                                            f1
> >                                            (+ f0 f1))
>
> Naive fib is often used as a benchmark, the point being not to do a
> fast fib, but comparative, 'what is the perf on naive fib'? Not being
> tail-recursive, it tests function calling overhead, and thus here
> demonstrates what we gain by not having to box on args and returns.
>
> Rich

-- 
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: classpath and require

2010-06-18 Thread Rob Lachlan
have you tried starting with:

c:\clojure-contrib\clojure-contrib.jar;c:\clojure\clojure.jar;c:
\projects.clj clojure.main


On Jun 18, 2:00 pm, Mohammad Khan  wrote:
> C:\Projects.clj>java -cp
> c:\clojure-contrib\clojure-contrib.jar;c:\clojure\clojure.jar clojure.main
> Clojure 1.1.0-alpha-SNAPSHOT
> user=> (require 'examples.introduction)
> java.io.FileNotFoundException: Could not locate
> examples/introduction__init.class or examples/introduction.clj on
> classpath:  (NO_SOURCE_FILE:0)
> user=>
>
> C:\Projects.clj>echo %CLASSPATH%
> C:\Projects.clj;C:\clojure;C:\clojure-contrib
> C:\Projects.clj>dir examples\introduction.clj
>  Volume in drive C is xxx
>  Volume Serial Number is -
>  Directory of C:\Projects.clj\examples
>
> 06/18/2010  04:52 PM                40 introduction.clj
>                1 File(s)             40 bytes
>                0 Dir(s)  xx,xxx,xxx bytes free
>
> C:\Projects.clj>

-- 
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: classpath and require

2010-06-18 Thread Rob Lachlan
Whoops, that should read:

java -cp c:\clojure-contrib\clojure-contrib.jar;c:\clojure
\clojure.jar;c:
\projects.clj clojure.main

On Jun 18, 2:51 pm, Rob Lachlan  wrote:
> have you tried starting with:
>
> c:\clojure-contrib\clojure-contrib.jar;c:\clojure\clojure.jar;c:
> \projects.clj clojure.main
>
> On Jun 18, 2:00 pm, Mohammad Khan  wrote:
>
>
>
> > C:\Projects.clj>java -cp
> > c:\clojure-contrib\clojure-contrib.jar;c:\clojure\clojure.jar clojure.main
> > Clojure 1.1.0-alpha-SNAPSHOT
> > user=> (require 'examples.introduction)
> > java.io.FileNotFoundException: Could not locate
> > examples/introduction__init.class or examples/introduction.clj on
> > classpath:  (NO_SOURCE_FILE:0)
> > user=>
>
> > C:\Projects.clj>echo %CLASSPATH%
> > C:\Projects.clj;C:\clojure;C:\clojure-contrib
> > C:\Projects.clj>dir examples\introduction.clj
> >  Volume in drive C is xxx
> >  Volume Serial Number is -
> >  Directory of C:\Projects.clj\examples
>
> > 06/18/2010  04:52 PM                40 introduction.clj
> >                1 File(s)             40 bytes
> >                0 Dir(s)  xx,xxx,xxx bytes free
>
> > C:\Projects.clj>

-- 
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: Possible Clojure Bug

2010-06-18 Thread Rob Lachlan
I think he retracted this post in a separate new thread not long after
posting this.

cheers
Rob

On Jun 18, 2:56 pm, "Heinz N. Gies"  wrote:
> On Jun 18, 2010, at 18:48 , pleone wrote:
>
> > I ran this in a slime REPL on AQUAMACS with clojure 1.1. It appears to
> > be a bug.  Am I mistaken?
>
> > user> (def conj-test-vector ["1" "2" "3" "4"])
> > #'user/conj-test-vector
> > user> conj-test-vector
> > ["1" "2" "3" "4"]
> > user> (conj conj-test-vector "5")
> > ["1" "2" "3" "4" "5"]
> > user> (conj conj-test-vector ["test"])
> > ["1" "2" "3" "4" ["test"]]
> > user> (conj conj-test-vector "6")
> > ["1" "2" "3" "4" "6"]
>
> I'm not sure what would be a bug it all looks pretty sane to me, conj does 
> not change the def'ed object (that is why it does not grow) and conjing 
> another vector of cause adds the vector and not it's elements :)
>
> Regards
> heinz.

-- 
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: classpath and require

2010-06-19 Thread Rob Lachlan
I was wondering whether putting a dot in a directory on the classpath
makes a difference.  On OS X, the answer is no.  Unfortunately, I
don't have a windows machine, so I can't check for certain what the
situation is there.

Another issue: I ignored case-sensitivity in my answer above.  Are
windows paths ever case-sensitive?  (silly question, I know, but I
haven't worked with windows in a while.)  Another question:

If you run:

java -cp "c:\clojure-contrib\clojure-contrib.jar;c:\clojure
\clojure.jar;c:\projects.clj\examples" clojure.main

can you then just do (require 'introduction)

And do try it with quotes around the classpath.  The dot in
projects.clj might be like a space in that it could lead to a parsing
error without quotes.

Good luck
Rob

On Jun 19, 1:58 am, Rasmus Svensson  wrote:
> 2010/6/18 Mohammad Khan 
>
>
>
>
>
> > C:\Projects.clj>java -cp
> > c:\clojure-contrib\clojure-contrib.jar;c:\clojure\clojure.jar clojure.main
> > Clojure 1.1.0-alpha-SNAPSHOT
> > user=> (require 'examples.introduction)
> > java.io.FileNotFoundException: Could not locate
> > examples/introduction__init.class or examples/introduction.clj on
> > classpath:  (NO_SOURCE_FILE:0)
> > user=>
>
> > C:\Projects.clj>echo %CLASSPATH%
> > C:\Projects.clj;C:\clojure;C:\clojure-contrib
> > C:\Projects.clj>dir examples\introduction.clj
> >  Volume in drive C is xxx
> >  Volume Serial Number is -
> >  Directory of C:\Projects.clj\examples
>
> > 06/18/2010  04:52 PM                40 introduction.clj
> >                1 File(s)             40 bytes
> >                0 Dir(s)  xx,xxx,xxx bytes free
>
> > C:\Projects.clj>
>
> Hello!
>
> To me it looks like you have gotten the most things right. As I see you
> understand, you must have clojure, clojure-contrib and the source on the
> class path. However, how these are specified can be a bit tricky. There are
> basically two cases: directories and jar files.
>
> When using jar files, the jar file itself must be in the class path, not the
> directory which contains it. In our case, the entries would be
> c:\clojure\clojure.jar and c:\clojure-contrib\clojure-contrib.jar, just as
> you wrote.
>
> When using folders with clojure source files or ahead-of-time compiled
> classes, the directory that contains the folder that represents the topmost
> component of the namespace. For example, in your case the namespace
> examples.introduction is stored in the file
> C:\Projects.clj\examples\introduction.clj so the directory C:\Projects.clj\
> should be inlcuded in the class path.
>
> When Clojure loads the namespace examples.introduction, it will try to find
> examples\introduction.clj in every directory (or jar file) in the class
> path. The error you got is an indication that no matching file could be
> found.
>
> On windows, the paths are delimited with semicolons, but on most other
> platforms colons are used. That's why most examples will use colons. If the
> paths in the class path contains spaces or other special characters, you
> should enclose the thing in spaces, like this:
>
> java -cp "C:\path one\;C:\path two\" clojure.main
>
> From what I can tell, Rob's example should work. I'm not sure if a trailing
> backslash is required for directories, but you could try with and without it
> to see if it makes any difference. If that doesn't work, try renaming
> projects.clj to something without a dot in it. Also, look carefully for
> typos...
>
> I hope this helps...
>
> // raek

-- 
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: need help understanding two issues

2010-06-19 Thread Rob Lachlan
I'll take a whack at it.


> 1. How come APersistentMap$KeySet doesn't implement IPersistentSet?

Because keys and vals are designed to return (lazy) sequences.  More
important, these two functions return those two sequences in the same
order.  The laziness avoids having to incur the overhead of creating
the set structure, though if you want that you can just call (set
(keys map)) as in your example.


>
> 2. I can't get clojure.set/project to work. All of the following throw
> an exception:
>
> (clojure.set/project (keys {2 "two" 4 "four"}) #{2 3})
> (clojure.set/project (set (keys {2 "two" 4 "four"})) #{2 3})
>

Yeah, I found the doc confusing as well.  Here's an example:

user> (ns user (:use clojure.set))
nil
user> (project [{1 2, 2 4, 3 6}, {1 3, 2 6}] [1])
#{{1 3} {1 2}}

So project seems to take a collection of maps, and "projects", or
restricts them all on to the values specified in the second argument.

Cheers
Rob

-- 
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: Enhanced Primitive Support

2010-06-19 Thread Rob Lachlan
The main example for recur on the special forms page (http://
clojure.org/special_forms#Special%20Forms--(recur%20exprs*)) is:

(def factorial
  (fn [n]
(loop [cnt n acc 1]
   (if (zero? cnt)
acc
  (recur (dec cnt) (* acc cnt))

I may not be be clojure jedi, but I've been learning the language for
a while.  I've never come across the notion that this is a code
smell.  I thought that the loop recur form was perfectly orthodox.

Also, the fact that the form above doesn't compile in the equal branch
does make me a little uneasy.

Rob

On Jun 19, 5:13 pm, David Nolen  wrote:
> On Sat, Jun 19, 2010 at 4:10 PM, Michał Marczyk
>
>  wrote:
> > (defn fact [n]
> >  (loop [n n r 1]
> >    (if (zero? n)
> >      r
> >      (recur (dec n) (* r n)
>
> Huh? That doesn't look like it's going to work at all.
>
> 1) 1 is primitive, we know that, accept it
> 2) we don't know the type of n, what will (* r n) be?
> 3) BOOM!
>
> My suggestion is to stop it with the contrived examples. Start showing some
> real code, real problems in your real programs. Using loop/recur is already
> the beginning of code smell for anything that is not performance sensitive.
>
> (defn fact
>   ([n] (fact n 1))
>   ([n r] (if (zero? n)
>           r
>           (recur (dec n) (* r n)
>
> Sleep soundly.

-- 
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: Enhanced Primitive Support

2010-06-19 Thread Rob Lachlan
Actually, Mike, your two functions work just fine.  (Equal branch).
Mind you I checked that out over two hours ago, so this information
might be out of date.

Rob

On Jun 19, 6:59 pm, Mike Meyer  wrote:
> On Sat, 19 Jun 2010 20:40:13 -0400
>
> David Nolen  wrote:
> > Mark and Mike you fail to address my deeper question.
>
> Maybe because you've failed to ask in your hurry to claim code is
> non-idiomatic or calling our example rhetoric.
>
> > I've been using
> > many different Clojure libraries all day long with the latest equals
> > branch. Guess
> > what?
>
> > No loop/recur bugs.
>
> I wouldn't expect anything else, for two reasons:
>
> 1) Most clojure code doesn't deal with integers - it deals with
>    symbols, strings, and sequences. Hence it won't run into this problem.
> 2) The libraries are generally written by experienced users who will
>    have tweaked them for performance - meaning they've typed hinted
>    them, and thus avoided this problem.
>
> > When you guys start postIng your broken code that has this problem
> > then people can start believing it is an issue for working code.
>
> I guess a perfectly natural expression of a reasonable algorithm that
> works under 1.1 and doesn't on the equal branch isn't "broken" because
> it's the same function we've been using all along. So here's some new
> examples, pulled in sequence from some of my combinatorics code:
>
> (defn count-in [value col]
>    (loop [value value col col res 0]
>       (if (empty? col)
>           res
>           (recur value (rest col) (if (= (first col) value) (inc res) res)
>
> (defn ones-n-zeros [vectors]
>   (loop [vectors vectors m-zeros 0 m-ones 0]
>      (if (empty? vectors)
>          [m-zeros m-ones]
>          (let [data (first vectors)
>                zeros (count-in 0 data)
>                ones (count-in 1 data)]
>             (recur (rest vectors) (if (> zeros ones) (inc m-zeros) m-zeros)
>                                   (if (> ones zeros) (inc m-ones) m-ones))
>
> No, I haven't verified it fails - I've given up trying to check out
> the branch, as hg convert failed, and git (after reinstalling over a
> broken version) keeps complaining about "warning: remote HEAD refers
> to nonexistent ref, unable to checkout." However, my reading of the
> proposal is that the inc's here will cause the same problems as the
> *'s in the perfectly reasonable factorial example.
>
> Now go ahead and claim that that's not very good code, because an
> expert would have type hinted it or written it with map & apply or
> some such, or that there's a contrib library somewhere with a faster
> implementation of count-in in it. That, after all, is your rhetoric.
>
> But that's my point. I want the *obvious* code to work. I'll worry
> about making it fast after I've made it right. If you want a read-only
> language that requires an expert to get working code in a reasonable
> amount of time, you can always write in Perl or C.
>
>         --
> Mike Meyer           http://www.mired.org/consulting.html
> Independent Network/Unix/Perforce consultant, email for more information.
>
> O< ascii ribbon campaign - stop html mail -www.asciiribbon.org

-- 
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: Enhanced Primitive Support

2010-06-19 Thread Rob Lachlan
I don't think my computer has enough memory to test that.  But, you're
right, I might have spoken hastily.

Rob

On Jun 19, 7:26 pm, Aaron Cohen  wrote:
> I actually believe it will throw an overflow exception if col contains
> more than Integer.MAX_VALUE elements. Hard to confirm without getting
> bored though.
>
> -- Aaron
>
>
>
> On Sat, Jun 19, 2010 at 10:19 PM, Rob Lachlan  wrote:
> > Actually, Mike, your two functions work just fine.  (Equal branch).
> > Mind you I checked that out over two hours ago, so this information
> > might be out of date.
>
> > Rob
>
> > On Jun 19, 6:59 pm, Mike Meyer  > 620...@mired.org> wrote:
> >> On Sat, 19 Jun 2010 20:40:13 -0400
>
> >> David Nolen  wrote:
> >> > Mark and Mike you fail to address my deeper question.
>
> >> Maybe because you've failed to ask in your hurry to claim code is
> >> non-idiomatic or calling our example rhetoric.
>
> >> > I've been using
> >> > many different Clojure libraries all day long with the latest equals
> >> > branch. Guess
> >> > what?
>
> >> > No loop/recur bugs.
>
> >> I wouldn't expect anything else, for two reasons:
>
> >> 1) Most clojure code doesn't deal with integers - it deals with
> >>    symbols, strings, and sequences. Hence it won't run into this problem.
> >> 2) The libraries are generally written by experienced users who will
> >>    have tweaked them for performance - meaning they've typed hinted
> >>    them, and thus avoided this problem.
>
> >> > When you guys start postIng your broken code that has this problem
> >> > then people can start believing it is an issue for working code.
>
> >> I guess a perfectly natural expression of a reasonable algorithm that
> >> works under 1.1 and doesn't on the equal branch isn't "broken" because
> >> it's the same function we've been using all along. So here's some new
> >> examples, pulled in sequence from some of my combinatorics code:
>
> >> (defn count-in [value col]
> >>    (loop [value value col col res 0]
> >>       (if (empty? col)
> >>           res
> >>           (recur value (rest col) (if (= (first col) value) (inc res) 
> >> res)
>
> >> (defn ones-n-zeros [vectors]
> >>   (loop [vectors vectors m-zeros 0 m-ones 0]
> >>      (if (empty? vectors)
> >>          [m-zeros m-ones]
> >>          (let [data (first vectors)
> >>                zeros (count-in 0 data)
> >>                ones (count-in 1 data)]
> >>             (recur (rest vectors) (if (> zeros ones) (inc m-zeros) m-zeros)
> >>                                   (if (> ones zeros) (inc m-ones) 
> >> m-ones))
>
> >> No, I haven't verified it fails - I've given up trying to check out
> >> the branch, as hg convert failed, and git (after reinstalling over a
> >> broken version) keeps complaining about "warning: remote HEAD refers
> >> to nonexistent ref, unable to checkout." However, my reading of the
> >> proposal is that the inc's here will cause the same problems as the
> >> *'s in the perfectly reasonable factorial example.
>
> >> Now go ahead and claim that that's not very good code, because an
> >> expert would have type hinted it or written it with map & apply or
> >> some such, or that there's a contrib library somewhere with a faster
> >> implementation of count-in in it. That, after all, is your rhetoric.
>
> >> But that's my point. I want the *obvious* code to work. I'll worry
> >> about making it fast after I've made it right. If you want a read-only
> >> language that requires an expert to get working code in a reasonable
> >> amount of time, you can always write in Perl or C.
>
> >>         >> --
> >> Mike Meyer           http://www.mired.org/consulting.html
> >> Independent Network/Unix/Perforce consultant, email for more information.
>
> >> O< ascii ribbon campaign - stop html mail -www.asciiribbon.org
>
> > --
> > 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: Enhanced Primitive Support

2010-06-19 Thread Rob Lachlan
Because the compiler is upset that it doesn't know what n is.  r is a
long, but n is ???.  The following works:

(defn ^:static fact [^long n]
  (loop [n n r 1]
(if (zero? n)
  r
  (recur (dec n) (* r n)

Or see Dnolen's version above.  But yeah, I wish that it still worked,
because it used to work just fine.

Rob

On Jun 19, 8:22 pm, Mike Meyer  wrote:
> "Rob Lachlan"  wrote:
> >Actually, Mike, your two functions work just fine.  (Equal branch).
> >Mind you I checked that out over two hours ago, so this information
> >might be out of date.
>
> >Rob
>
> >On Jun 19, 6:59 pm, Mike Meyer 
> Ok, why does this work but the fact fail? Or does the fact example still fail 
> on that build?
>
> The fact that this requires explanation is a pretty good argument the fact 
> behavior.
>
> >> (defn count-in [value col]
> >>    (loop [value value col col res 0]
> >>       (if (empty? col)
> >>           res
> >>           (recur value (rest col) (if (= (first col) value) (inc res) 
> >> res)
>
> >> (defn ones-n-zeros [vectors]
> >>   (loop [vectors vectors m-zeros 0 m-ones 0]
> >>      (if (empty? vectors)
> >>          [m-zeros m-ones]
> >>          (let [data (first vectors)
> >>                zeros (count-in 0 data)
> >>                ones (count-in 1 data)]
> >>             (recur (rest vectors) (if (> zeros ones) (inc m-zeros) m-zeros)
> >>                                   (if (> ones zeros) (inc m-ones) 
> >> m-ones))
>
> --
> Sent from my Android phone with K-9 Mail. Please excuse my brevity.

-- 
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: bioinformatics toolkit in clojure: what would that look like?

2010-06-28 Thread Rob Lachlan
The clojure way seems to be to do as much as possible with functions
on raw (immutable) data, rather than building up object systems.  The
sequence is already one of clojure's primary abstractions, and it may
not always *need* to wrapped in something like defrecord.  (Though for
some applications, I'm sure it will.)

Anyway, I'd be interested in contributing, whatever design decisions
are ultimately made.

Rob

On Jun 28, 11:22 am, Nicolas Oury  wrote:
> Hi,
>
> I am using Clojure for bioinformatics, but not the same kind of stuff.
> I am writing a stochastic simulator.
>
> Would love to discuss more about your idea though.
>
> You can have something quite close to what you describe as the OO approach
> with
> protocols and data-types.
> + by using defrecord, you can easily have generic functions.
>
> That would the easier approach, I think.
>
> I will have a look to bio*.
>
> But if you want to start a project, count me in.
>
>
>
> On Sun, Jun 27, 2010 at 11:15 PM, jandot  wrote:
> > Hi all,
>
> > I have been a ruby user for several years and have contributed to the
> > bioruby toolkit for bioinformatics. Lately however I got interested in
> > clojure as it's a functional language and should be very good for
> > working with the huge datasets we have to handle.
>
> > Although there are bioinformatics toolkits for many OO languages
> > (biojava, bioperl, biopython and bioruby), nothing similar exists for
> > clojure yet. And I'd be interested to start building such toolkit
> > while I learn the language. At first for my own use, but maybe
> > later... who knows.
>
> > Being new to functional languages, I wonder how such a toolkit would
> > be best approached. In an OO language you create classes with
> > properties and methods that describe one particular entitiy in the
> > field. For example: you define a DNASequence class with a "name" and
> > "sequence" property, and a method to print it out in an international
> > standard text format, and another method for translating the DNA
> > sequence in that of the resulting protein. Much of the functionality
> > of these toolkits is about retrieving a bit of information,
> > manipulating it and ultimately writing it to screen/file.
>
> > As functional languages are more about verbs than nouns: how could a
> > bioinformatics toolkit be idiomatically set up? Would it still be the
> > Right Way (TM) to create some type of classes, a-la OO?
>
> > For more information on the OO toolkits, seewww.bioperl.org,
> >www.biojava.org,
> > bioruby.org and biopython.org.
>
> > As clojure (especially combined with incanter) seems to be a very good
> > candidate for future work in bioinformatics, I would very much welcome
> > a little discussion on this.
>
> > Many thanks,
> > jan.
>
> > --
> > 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: bioinformatics toolkit in clojure: what would that look like?

2010-06-29 Thread Rob Lachlan
>
> +1 if you make the function not just for vector but for any seqs. That way
> of we need special BioSeqs someday...

Yes, I concur.  I think that the default in-memory data format for
(DNA, RNA, Protein sequences) should be a vector, but that the
functions should take sequences. Mind you in some cases, we might want
to exploit transient vectors for better performance.

Rob

-- 
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: BUG: Clojure hierarchies (affects 1.2-beta1)

2010-07-22 Thread Rob Lachlan
I sent in my CA some weeks ago.  I have a patch ready, with tests, and
now I'm just waiting to be let in to clojure-dev + assembla.  As I
mentioned in the other thread, there are other problems with underive
-- essentially the hierarchy can become inconsistent in cases of
multiple inheritance, over and beyond the incorrect key being used in
the map.

http://groups.google.com/group/clojure/browse_thread/thread/b70f8bf16de2216



On Jul 22, 3:36 am, Stuart Halloway  wrote:
> I closed #406: this is a subset of the issue already covered under #382, 
> which Rob was planning to do a patch for.
>
> Rich, can you check and see if CAs have arrived from Rob Lachlan and Michał 
> Marczyk?
>
> Stu
>
>
>
> > Made a ticket for this here (including the simple diagnosis):
>
> >https://www.assembla.com/spaces/clojure/support/tickets/406-typo-in-u...
>
> > No patch, since my CA wasn't ack'd yet...
>
> > Sincerely,
> > Michał
>
> > --
> > 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: seeking rudimentary defprotocol + deftype help

2009-12-29 Thread Rob Lachlan
I'm also looking for some help on deftype, and rather than start
another thread, I thought I'd toss it in here.  Basically, how do I
type hint for a deftype.  For example, suppose I want a nested type,
something that looks like this:

(deftype A
[#^somePrimitive  someField])

(deftype B
[#^A Avalue])

This brings up an error:

Unknown location:
  error: java.lang.ClassNotFoundException: A

So how would I define a type that includes another type?

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


Status of bounded search on sorted-map?

2009-12-30 Thread Rob Lachlan
About a year and a half ago, there was some discussion about having a
function that would enable some kind of bounded search on a sorted
map:

http://groups.google.com/group/clojure/browse_thread/thread/949cae6c085d3d39/65b4082085c19a60?q=

Does this exist, currently?  I haven't looked at the gory details of
PersistentTreeMap, so I don't know how difficult this would be to do.
Intuitively though, since we have the keys are in a sorted tree, I
thought that it would be possible to have a bounded search in
something like O(log n).

Rob

p.s.  I asked a related question on stackoverflow:

http://stackoverflow.com/questions/1981859/finding-keys-closest-to-a-given-value-for-clojure-sorted-maps

-- 
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: seeking rudimentary defprotocol + deftype help

2009-12-30 Thread Rob Lachlan
Thanks alot guys!

On Dec 30, 1:41 pm, Raoul Duke  wrote:
> p.p.s. i was using -alpha- and changed to -new- (and pulled today) and
> now i get a slightly different error. am i just flubbing the syntax in
> some way i can't see for the trees?!
>
> user=> (defprotocol P (foo [x]))
> P
> user=> (deftype A [] [P] (.foo [x]))
> java.lang.RuntimeException: java.lang.ClassCastException:
> clojure.lang.PersistentVector cannot be cast to clojure.lang.Symbol
> (NO_SOURCE_FILE:0)
>
>
>
> On Tue, Dec 29, 2009 at 12:08 PM, Raoul Duke  wrote:
> > i haven't been able to figure out what i'm doing wrong yet. the error
> > message isn't super helpful :-}
>
> > Clojure 1.1.0-alpha-SNAPSHOT
> > user=> (defprotocol P (foo [x]))
> > P
> > user=> (deftype T [f] [P] (foo [x] x))
> > java.lang.ClassCastException: clojure.lang.Var cannot be cast to
> > java.lang.Class (NO_SOURCE_FILE:2)
>
> > ?! thanks for any help.

-- 
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: Status of bounded search on sorted-map?

2009-12-30 Thread Rob Lachlan
This would work, but would require iterating over the keys, for
something like O(n) performance.  I'm hoping that we can do better,
since the keys are already in an ordered collection.

On Dec 30, 3:04 pm, Sean Devlin  wrote:
> Use a combination of take-while & key
>
> (take-while (comp your-pred key) sorted-map)
>
> You could also use drop while as needed.
>
> I've got a blog post where I use this to solve the knapsack problem:
>
> http://fulldisclojure.blogspot.com/2009/12/uses-for-takedrop-while.html
>
> I've got some other stuff, too.  Send me a note if you need more than
> this.
>
> Sean
>
> On Dec 30, 5:37 pm, Rob Lachlan  wrote:
>
>
>
> > About a year and a half ago, there was some discussion about having a
> > function that would enable some kind of bounded search on a sorted
> > map:
>
> >http://groups.google.com/group/clojure/browse_thread/thread/949cae6c0...
>
> > Does this exist, currently?  I haven't looked at the gory details of
> > PersistentTreeMap, so I don't know how difficult this would be to do.
> > Intuitively though, since we have the keys are in a sorted tree, I
> > thought that it would be possible to have a bounded search in
> > something like O(log n).
>
> > Rob
>
> > p.s.  I asked a related question on stackoverflow:
>
> >http://stackoverflow.com/questions/1981859/finding-keys-closest-to-a-...

-- 
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: Status of bounded search on sorted-map?

2009-12-30 Thread Rob Lachlan
I should have said: since the keys are already in a tree.  If they
were in a linked list, I'd expect to have to iterate over most of the
list.

On Dec 30, 3:10 pm, Rob Lachlan  wrote:
> This would work, but would require iterating over the keys, for
> something like O(n) performance.  I'm hoping that we can do better,
> since the keys are already in an ordered collection.
>
> On Dec 30, 3:04 pm, Sean Devlin  wrote:
>
>
>
> > Use a combination of take-while & key
>
> > (take-while (comp your-pred key) sorted-map)
>
> > You could also use drop while as needed.
>
> > I've got a blog post where I use this to solve the knapsack problem:
>
> >http://fulldisclojure.blogspot.com/2009/12/uses-for-takedrop-while.html
>
> > I've got some other stuff, too.  Send me a note if you need more than
> > this.
>
> > Sean
>
> > On Dec 30, 5:37 pm, Rob Lachlan  wrote:
>
> > > About a year and a half ago, there was some discussion about having a
> > > function that would enable some kind of bounded search on a sorted
> > > map:
>
> > >http://groups.google.com/group/clojure/browse_thread/thread/949cae6c0...
>
> > > Does this exist, currently?  I haven't looked at the gory details of
> > > PersistentTreeMap, so I don't know how difficult this would be to do.
> > > Intuitively though, since we have the keys are in a sorted tree, I
> > > thought that it would be possible to have a bounded search in
> > > something like O(log n).
>
> > > Rob
>
> > > p.s.  I asked a related question on stackoverflow:
>
> > >http://stackoverflow.com/questions/1981859/finding-keys-closest-to-a-...

-- 
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: Status of bounded search on sorted-map?

2009-12-30 Thread Rob Lachlan
Thanks for the pointer.  I had a feeling that java world had something
like this, but I'd much prefer to be able to do this from clojure.
Appreciate the info, though.

On Dec 30, 3:14 pm, Sean Devlin  wrote:
> Do you need persistence?  There's a solution in java.util in Java 6.
>
> On Dec 30, 6:10 pm, Rob Lachlan  wrote:
>
>
>
> > This would work, but would require iterating over the keys, for
> > something like O(n) performance.  I'm hoping that we can do better,
> > since the keys are already in an ordered collection.
>
> > On Dec 30, 3:04 pm, Sean Devlin  wrote:
>
> > > Use a combination of take-while & key
>
> > > (take-while (comp your-pred key) sorted-map)
>
> > > You could also use drop while as needed.
>
> > > I've got a blog post where I use this to solve the knapsack problem:
>
> > >http://fulldisclojure.blogspot.com/2009/12/uses-for-takedrop-while.html
>
> > > I've got some other stuff, too.  Send me a note if you need more than
> > > this.
>
> > > Sean
>
> > > On Dec 30, 5:37 pm, Rob Lachlan  wrote:
>
> > > > About a year and a half ago, there was some discussion about having a
> > > > function that would enable some kind of bounded search on a sorted
> > > > map:
>
> > > >http://groups.google.com/group/clojure/browse_thread/thread/949cae6c0...
>
> > > > Does this exist, currently?  I haven't looked at the gory details of
> > > > PersistentTreeMap, so I don't know how difficult this would be to do.
> > > > Intuitively though, since we have the keys are in a sorted tree, I
> > > > thought that it would be possible to have a bounded search in
> > > > something like O(log n).
>
> > > > Rob
>
> > > > p.s.  I asked a related question on stackoverflow:
>
> > > >http://stackoverflow.com/questions/1981859/finding-keys-closest-to-a-...

-- 
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: Status of bounded search on sorted-map?

2009-12-30 Thread Rob Lachlan
Thanks very much, that makes a lot of sense.  I looked through the
java code for PersistentTreeMap, and indeed those methods are private.

I think that I'll be happy with subseq and rsubseq. Being a noob, it
hadn't occured to me that I could do that.

On Dec 30, 8:04 pm, Timothy Pratley  wrote:
> 2009/12/31 Rob Lachlan :
>
> > About a year and a half ago, there was some discussion about having a
> > function that would enable some kind of bounded search on a sorted
> > Does this exist, currently?  I haven't looked at the gory details of
>
> subseq and rsubseq provide efficient bounded searching.
> I don't see the need for find or seek as that is really just (first (subseq 
> sm))
>
> For your particular problem (find closest) a combination of first
> subseq >= and first rsubseq <= will find you the two best candidates
> on either side, and thus which is closest. However this is slightly
> more work than if you could just do one efficient search and then
> access the key to the other side of the test... which is a different
> proposition all together than bounded search but if it is useful
> sounds easy enough to expose. Currently you can access the tree itself
> (.tree sm) works, but you can't find out what's to the left or right
> because those are private. Do you want to navigate the tree, or would
> a left and right search suffice?
>
> Regards,
> Tim.

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


Having difficulties with compilation in slime, emacs and clojure-project

2010-01-05 Thread Rob Lachlan
I've been trying to compile clojure files from emacs.  The issue I run
into is of my own clj files not being found on the classpath.  (If I'm
trying to compile a standalone file, which references only clojure
core, there's no problem.  It's when I have multiple files, and I'm
trying to include a file of my own with use or require, that I run
into this issue.)

I found the clojure-project function, by Phil Hagelberg, at:

http://www.mail-archive.com/clojure@googlegroups.com/msg18268.html

but when I put it in .emacs, and invoked it, the function seemed to
get stuck.  I'm asked in the mini-buffer for the project root, and I
write it in and press return, but nothing happens.  I just keep
getting carriage returns in the mini-buffer.  Any ideas?

Or are there any other convenient ways for managing class paths for
various clojur projects in emacs?
-- 
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: Having difficulties with compilation in slime, emacs and clojure-project

2010-01-05 Thread Rob Lachlan
I have src and test in the directory I'm passing in.  The problem
however, seems to be
on the emacs end.  In the mini-buffer when I enter in Project root:
 and
press return, the cursor just moves to the next line in the mini-
buffer.  So I think that the
clojure-project function is getting stuck right at that spot.


On Jan 5, 11:01 pm, Konrad Hinsen  wrote:
> On 06.01.2010, at 07:26, Rob Lachlan wrote:
>
> > but when I put it in .emacs, and invoked it, the function seemed to
> > get stuck.  I'm asked in the mini-buffer for the project root, and I
> > write it in and press return, but nothing happens.  I just keep
> > getting carriage returns in the mini-buffer.  Any ideas?
>
> The root directory should be a directory containing subdirectories  
> src, test, and lib (each one is optional, but there needs to be at  
> least one of them). src and test are put directly on the classpath,  
> and all jar files in lib are added as well.
>
> Perhaps you specified as project root directlly the directory  
> containing your source code?
>
> Konrad.
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Having difficulties with compilation in slime, emacs and clojure-project

2010-01-06 Thread Rob Lachlan
Thanks for the help.  I had initially installed slime, clojure-mode
and swank following the instructions at 
http://riddell.us/tutorial/slime_swank/slime_swank.html

I tried simply installing swank-clojure, but that seemed to conflict
with what I already had.  So I removed everything -- slime, clojure-
mode, etc.  and installed swank-clojure using ELPA.

This in turn installed slime, slime-repl, swank-clojure, and clojure-
mode.  But now when I try M-x slime, I get:

Searching for program: no such file or directory, lisp

Clearly, my emacs-fu is not strong enough.  Any ideas?

On Jan 6, 9:32 am, Phil Hagelberg  wrote:
> Rob Lachlan  writes:
> > I have src and test in the directory I'm passing in.  The problem
> > however, seems to be on the emacs end.  In the mini-buffer when I
> > enter in Project root:  and press return, the cursor
> > just moves to the next line in the mini- buffer.  So I think that the
> > clojure-project function is getting stuck right at that spot.
>
> That's a bug that was fixed many months ago; sounds like you need to
> update your version of swank-clojure:
>
> http://github.com/technomancy/swank-clojure
>
> Installation is handled through Emacs' package manager:
>
> http://tromey.com/elpa/install.html
>
> -Phil
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Having difficulties with compilation in slime, emacs and clojure-project

2010-01-07 Thread Rob Lachlan
Thanks Phil and Rob for your help.

I got rid of everything in emacs.d, and tried reinstalling from the
beginning.  For some reason, elpa seems to get stuck halfway through
with this message:

trying to parse HTTP response code in odd buffer: *http tromey.com:80*

But having installed swank-clojure, I get an error:

java.lang.ClassNotFoundException: swank.swank

And I can't find swank-clojure.jar anywhere on my system.  Should I
have built that separately? Anyway, thanks very much for all your
help.

Rob


On Jan 7, 9:05 am, Phil Hagelberg  wrote:
> Rob Lachlan  writes:
> > Thanks for the help.  I had initially installed slime, clojure-mode
> > and swank following the instructions 
> > athttp://riddell.us/tutorial/slime_swank/slime_swank.html
>
> > I tried simply installing swank-clojure, but that seemed to conflict
> > with what I already had.  So I removed everything -- slime, clojure-
> > mode, etc.  and installed swank-clojure using ELPA.
>
> > This in turn installed slime, slime-repl, swank-clojure, and clojure-
> > mode.  But now when I try M-x slime, I get:
>
> > Searching for program: no such file or directory, lisp
>
> Sounds like you didn't quite remove everything from your old
> setup. There must still be some old slime code/configuration lying
> around somewhere.
>
> -Phil
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: SLIME/Swank problem with swank.util.sys/get-pid and RuntimeMXBean

2010-01-09 Thread Rob Lachlan
I've reverted to the setup that you listed, Ramakrishnan.  I spent
quite a few hours trying to figure out how to use ELPA + the forked
slime + the new swank clojure, but failed miserably (despite the kind
assistance of Phil and others on another thread).

I would agree that it would be nice to have the option of installing
packages oneself, since if an automatic package management system is
relied on, and it fails, it can be very difficult to figure out how to
fix things.

On Jan 8, 1:03 am, Ramakrishnan Muthukrishnan 
wrote:
> On Fri, Jan 8, 2010 at 12:57 PM, Richard Newman  wrote:
> >> I don't want to have to use ELPA, or maven, or some other configuration
> >> management thing to get basic tools like an editing environment for the
> >> language up and running. Perhaps I should just bite the bullet and use the
> >> crazy configuration/package management things that the clojure community
> >> seems so enamored of (ELPA, maven, leiningen, etc...), but in the way I'm
> >> used to doing things, nothing more than the source code and a fairly simple
> >> system definition tool (like ASDF) are enough to get things done. It's not
> >> too say that there's room for improvement, but I like it when simple tools
> >> get the job done and I don't need to rely on a bunch of shell scripts, to
> >> have to modify classpaths, restart JVMs, etc... to get the code I want
> >> loaded. Perhaps I'm just ignorant of the proper clojure-y way to do things,
> >> so I'll hop off my soapbox now.
>
> > I think I'm pretty familiar with the Clojure-y way to do things, and I also
> > close the tab when I see "... using Maven".
>
> I am alien to the Java world and haven't still embrased ELPA, lein and
> other tools. Here is my setup which works fine for me:
>
> o. slime
>     git://git.boinkor.net/slime.git
>
> o. swank-clojure
>     git://github.com/jochu/swank-clojure.git
>
> o. clojure-mode
>     git://github.com/jochu/clojure-mode.git
>
> It has worked quite nicely for me until now. I also discovered the
> other branch of swank-clojure, which seem to be what people are using
> more. I see that it does things like downloading jars etc etc. I would
> rather like it to leave them for other tools to do. I have no problem
> installing emacs scripts by hand. If so, I wouldn't be using it
> anyway, so I just don't see why ELPA and the other swank-clojure
> branch is trying to do things that other tools are supposed to do.
>
> --
>   Ramakrishnan
-- 
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: compojure/defservlet

2010-01-19 Thread Rob Lachlan
I can't find it either.  The closest thing seems to be the servlet
macro:

(definline servlet
  "Create a servlet from a sequence of routes. Automatically updates
if
  the routes binding is redefined."
  [routes]
  `(proxy [HttpServlet] []
 (~'service [request# response#]
   (request-handler [~'this request# response#]
 ~routes

from servlet.clj



On Jan 19, 5:19 pm, Jeff Schwab  wrote:
> Hi:
>
> The compojure wikibook claims that compojure provides a defservlet
> function, along with other syntactic conveniences that I seem to be
> missing.  Grepping the git log didn't turn up anything relevant, so I'm
> wondering:  Is compojure supposed to provide defservlet, or should I fix
> the wikibook?
>
> http://en.wikibooks.org/wiki/Compojure/Core_Libraries
-- 
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: Debian packages

2011-05-25 Thread Rob Lachlan
I'm curious about this as well, because of the ICFP programming
contest.
The contest organizers are soliciting requests for Debian packages to
be
installed on the contest environment.  I don't suppose that this is
the
reason that you're asking?

On May 24, 9:41 pm, Phil Hagelberg  wrote:
> It looks like Clojure 1.1.0 and the corresponding version of contrib
> were packaged for Debian. Is the fellow who packaged that still
> around? Are there any plans to package 1.2.1 and contrib 1.2.0?
>
> -Phil

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


Re: Most concise way to determine that a sequence is consecutive integers starting with one?

2011-07-01 Thread Rob Lachlan
Using map-indexed:

(defn f [xs] (every? true? (map-indexed #(= (inc %1) %2) xs)))


On Jul 1, 12:28 pm, ".Bill Smith"  wrote:
> I want a concise function that, given an arbitrary length sequence,
> determines whether the sequence is of consecutive integers starting with
> one.  So:
>
>  (f [1 2 3]) returns true
>
>  (f [1 2 4]) returns false
>
>  (f [0 1 2]) returns false
>
> My first try, which I am not proud of, follows:
>
> (defn f [numbers]
>   (every? (fn [[x y]] (= x y)) (partition 2 (interleave (iterate inc 1)
> numbers
>
> Can someone suggest something better?

-- 
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: Is it possible to make a mirror of clojure.org?

2011-10-12 Thread Rob Lachlan
Many of the links off of the main page are ajax.  I don't think that
wget can scrape that very easily.

On Oct 12, 11:10 am, Tassilo Horn  wrote:
> jingguo  writes:
>
> Hi!
>
> > When programming in Clojure, I use the Reference documentation on
> > clojure.org a lot. But my network condition is horrible. So I want to
> > make a off-line copy. I have tried "wget -x -m -khttp://clojure.org";
> > to make a mirror of clojure.org. But it does not work.
>
> First, I've thought it was due to a restrictive robots.txt on the clojure
> server, so I tried
>
>   wget -e robots=off -x -m -k --wait 1http://clojure.org/
>
> but that also downloads just the index page...
>
> But I guess for programming clojure, you mostly want only the API docs,
> and that can be mirrored perfectly fine with
>
>   wget -xmkhttp://clojure.github.com/clojure/
>
> HTH,
> 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: Is it possible to make a mirror of clojure.org?

2011-10-12 Thread Rob Lachlan
Ignore my last message.  For some reason, you need the --no-cookies
option for wget to recurse on this website.  No idea why.

So I ended up using something like

wget -x -m -k -H -Dclojure.org --no-cookies --html-extension http://clojure.org

You may have to play around a bit to pull down exactly what you want.

On Oct 12, 12:06 pm, Rob Lachlan  wrote:
> Many of the links off of the main page are ajax.  I don't think that
> wget can scrape that very easily.
>
> On Oct 12, 11:10 am, Tassilo Horn  wrote:
>
>
>
>
>
>
>
> > jingguo  writes:
>
> > Hi!
>
> > > When programming in Clojure, I use the Reference documentation on
> > > clojure.org a lot. But my network condition is horrible. So I want to
> > > make a off-line copy. I have tried "wget -x -m -khttp://clojure.org";
> > > to make a mirror of clojure.org. But it does not work.
>
> > First, I've thought it was due to a restrictive robots.txt on the clojure
> > server, so I tried
>
> >   wget -e robots=off -x -m -k --wait 1http://clojure.org/
>
> > but that also downloads just the index page...
>
> > But I guess for programming clojure, you mostly want only the API docs,
> > and that can be mirrored perfectly fine with
>
> >   wget -xmkhttp://clojure.github.com/clojure/
>
> > HTH,
> > 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


Keyword names and namespaces

2010-10-18 Thread Rob Lachlan
There seems to be a discrepancy between what keyword names are
supposed to be allowed, according to the reader documentation, and
which the reader actually allows.  For instance, periods are supposed
to be disallowed in keyword names, and only one forward slash allowed,
but no errors are thrown at something like this:

{:f/o/o.o :bar}

The key :f/o/o.o is interpreted as a keyword with namespace f/o and
name o.o

Using the keyword function, we seem to be able to make keywords out of
any pair arbitrary strings, even including spaces.  This might seem
pathological, but since keywords just evaluate to themselves there
doesn't seem to be great harm in allowing this kind of liberal
behavior.  (Note also that keywords don't create a namespace, so we
don't have to worry about inadmissible namespaces for keywords.)

On the other hand, if this isn't to be allowed, then shouldn't the
keyword function throw an error when inadmissible strings are provided
for namespaces or names?  I should point out that the symbol function
is also similarly permissive, and that seems like it might be more
worrisome.  I would be in favor of keeping the behavior of the keyword
function as is, but possibly making the symbol function a bit
stricter.

Note, I'm using version 1.2.  This all is motivated by a stackoverflow
discussion: 
http://stackoverflow.com/questions/3951761/what-are-the-allowed-characters-in-a-clojure-keyword/

-- 
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: Keyword names and namespaces

2010-10-18 Thread Rob Lachlan
I see, thank you for linking to the ticket, Phil that really clarifies
things.  I suppose that I would tend more to Chas Emerick's view in
his sept 28 comment (on the ticket), questioning whether there is a
need to validate Keywords (and possibly symbols) stringently.  But
I'll take your point that we shouldn't count on the current behaviour
continuing.

Rob

On Oct 18, 9:24 pm, Phil Hagelberg  wrote:
> On Mon, Oct 18, 2010 at 3:02 PM, Rob Lachlan  wrote:
> > There seems to be a discrepancy between what keyword names are
> > supposed to be allowed, according to the reader documentation, and
> > which the reader actually allows.  For instance, periods are supposed
> > to be disallowed in keyword names, and only one forward slash allowed,
> > but no errors are thrown at something like this:
>
> I think the official stance is that there's a big difference between
> what is officially supported and what you happen to be able to do in
> the current version without things blowing up.
>
> > Using the keyword function, we seem to be able to make keywords out of
> > any pair arbitrary strings, even including spaces.
>
> I submitted a patch for this over a year ago, but I gather there were
> some concerns about the runtime cost of such behaviour. It's one of
> the most long-standing tickets still open:
>
> https://www.assembla.com/spaces/clojure/tickets/17-gc-issue-13-%09val...)
>
> -Phil

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


Re: Behaviour of clojure.set functions with non-sets.

2010-10-18 Thread Rob Lachlan
It's not free.

(defn set
  "Returns a set of the distinct elements of coll."
  {:added "1.0"}
  [coll] (clojure.lang.PersistentHashSet/create ^clojure.lang.ISeq
(seq coll)))

It seems to go element by element, irrespective of whether it was
given a hashset.

Rob

On Oct 18, 9:43 pm, Phil Hagelberg  wrote:
> It looks like the behaviour of some clojure.set functions is either
> undefined or possibly erroneous when called with non-set arguments:
>
> user> (clojure.set/union #{:a :b} [:b :c])
> #{:a :c :b}
> user> (clojure.set/union #{:a} [:b :c])
> [:b :c :a]
>
> Seems likely that the behaviour in such cases is just undefined, but I
> wonder if it would be worth calling set on each argument just to avoid
> weird edge-case bugs. Is it a cheap operation to call set on a set?
>
> -Phil

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


Re: Ring startup processing?

2010-11-27 Thread Rob Lachlan
The servlet interface includes the init method for this exact
purpose.  In java, this would be used by subclassing one of the
abstract servlet classes, and filling in the init method with whatever
initialization you need.  Or by implementing the servlet interface
directly.

>From the javadoc, the init method "Initializes the servlet. The method
is called once, automatically, by the servlet engine when it loads the
servlet. It is guaranteed to finish before any service requests are
accepted."  I find this approach more straightforward than having an
entire separate servlet for initialization.

I was hoping that initialization of this kind would make it into the
ring spec, but there wasn't much support.  See the thread below for
more details:

http://groups.google.com/group/ring-clojure/browse_thread/thread/ec5a30b5bb4ec823#

Rob


On Nov 27, 4:50 pm, Mike Meyer  wrote:
> My simple web app
> (http://blog.mired.org/2010/11/x10-controller-in-clojure.html) has
> some stuff that needs to happen just once (in this case, opening the
> serial port). It's not clear how to get this to happen using ring. If
> I do it inside my ring handler, then it gets run on every request, and
> I have to check to make sure it's not run multiple times. If I run it
> outside the handler, then it gets run when I do "lein uberwar", which
> is simply wrong.
>
> When the deployment platform activates the war would seem to be the
> right time to run this ("war load time"?). So maybe this is a question
> that depends on the deployment platform, or war? However, a quick
> google search didn't turn up anything that looked interesting.
>
> Anyone got suggestions on how to set up code to be run when Jetty (or
> tomcat, or ...)?
>
>         thanks,
>          --
> Mike Meyer           http://www.mired.org/consulting.html
> Independent Network/Unix/Perforce consultant, email for more information.
>
> O< ascii ribbon campaign - stop html mail -www.asciiribbon.org

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