Symbols, vars, and namespaces
I've been working with Compojure and Ring lately to build an app server, and I've gotten my brain stuck trying to figure out wrap- reload. It seems like I have to turn my routes into vars to get wrap- reload to work, but I don't understand why, and I suppose I don't really understand the "when" or "where" of the situation either. For example, if I have a bunch of resource namespaces with (defroutes ...) calls in them, and a main "core" namespace that aggregates them all, wrap-reload will work in a scenario like this: (defroutes combined #'myapp.resource.users #'myapp.resource.products #'myapp.resource.other (route/resources "/") (route/not-found "Page not found")) In the above, changing code in any of the resource namespaces auto- reloads them. But if I put two defroutes in the same namespace and try to "var" one of them, wrap-reload fails: (defroutes defaults (route/resources "/") (route/not-found "Page not found")) (defroutes all-routes myapp.resource.users myapp.resource.products myapp.resource.other) (defroutes combined #'all-routes defaults) If I pass combined to (handler/site ...) in Compojure, wrap-reload doesn't work. And, if I take the original, and remove the vars, then try to call handler/site and var that route, it doesn't work either: (defroutes combined myapp.resource.users myapp.resource.products myapp.resource.other (route/resources "/") (route/not-found "Page not found")) (def app (handler/site #'combined)) What am I not understanding here? I feel like this is the area I struggle with most, and I'm not getting it at all. P.S. Please don't point me at lein-ring and have me just run that. I'm trying to finally understand this, and I also need to be able to access the REPL in the same classloader as the running server for other reasons. -- 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: Symbols, vars, and namespaces
In this case the var is simply acting as a mutable pointer, so that when the implementation is changed the route reflects the new value. Here's a simple example of that behavior in action, divorced from webservers and the like: ;; caller accepts a function and returns a new one that forwards to it repl-1=> (defn caller [f] (fn [x] (f x))) ;; initially we use identity repl-1=> (defn callee [x] x) ;; the first form passes the current value of callee; the second passes the "pointer" repl-1=> (def passed-value (caller callee)) repl-1=> (def passed-var (caller #'callee)) ;; if we redefine callee, only the pointer-version sees the new value repl-1=> (defn callee [x] (* 2 x)) repl-1=> (passed-value 4) 4 repl-1=> (passed-var 4) 8 On Feb 11, 2:11 am, Sean Bowman wrote: > I've been working with Compojure and Ring lately to build an app > server, and I've gotten my brain stuck trying to figure out wrap- > reload. It seems like I have to turn my routes into vars to get wrap- > reload to work, but I don't understand why, and I suppose I don't > really understand the "when" or "where" of the situation either. > > For example, if I have a bunch of resource namespaces with > (defroutes ...) calls in them, and a main "core" namespace that > aggregates them all, wrap-reload will work in a scenario like this: > > (defroutes combined > #'myapp.resource.users > #'myapp.resource.products > #'myapp.resource.other > (route/resources "/") > (route/not-found "Page not found")) > > In the above, changing code in any of the resource namespaces auto- > reloads them. > > But if I put two defroutes in the same namespace and try to "var" one > of them, wrap-reload fails: > > (defroutes defaults > (route/resources "/") > (route/not-found "Page not found")) > > (defroutes all-routes > myapp.resource.users > myapp.resource.products > myapp.resource.other) > > (defroutes combined > #'all-routes > defaults) > > If I pass combined to (handler/site ...) in Compojure, wrap-reload > doesn't work. > > And, if I take the original, and remove the vars, then try to call > handler/site and var that route, it doesn't work either: > > (defroutes combined > myapp.resource.users > myapp.resource.products > myapp.resource.other > (route/resources "/") > (route/not-found "Page not found")) > > (def app (handler/site #'combined)) > > What am I not understanding here? I feel like this is the area I > struggle with most, and I'm not getting it at all. > > P.S. Please don't point me at lein-ring and have me just run that. > I'm trying to finally understand this, and I also need to be able to > access the REPL in the same classloader as the running server for > other reasons. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojurescript why: (def ... is failing whereas (let ... succeeds
Hi, The solution is to explicitly require goog.fx.DragDrop in the :require in the ns declaration: [goog.fx.DragDrop :as dd-import] This adds this line in the generated js output: goog.require('goog.fx.DragDrop'); This line is required because DragDrop lives in its own file within the Google Closure Library. Also, your second example with the let form doesn't succeed. Try calling the "run-draganddrop" function and it will gave the same error as the failing def case. Using the "let" here makes that the expression is never reached and executed because the function is never called, which is why the error does not show. This case is also solved by adding the DragDrop to require. -Gijs -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojurescript why: (def ... is failing whereas (let ... succeeds
How do you know the let is working? Is the run-draganddrop function being called by something outside of that source file? It'll have the same problem as the def, you just won't see it when you load the file because the function isn't called. I looked into goog.jar and goog.fx.DragDrop is an entire namespace, so you need to explicitly require it so ClojureScript will bring it into the compiled JS: (:require [goog.fx.DragDrop :as _] [goog.fx :as fx] [goog.graphics:as graphics]) If you look inside the Closure library jar (goog.jar) at goog/fx/fx.js only requires the following: goog.require('goog.asserts'); goog.require('goog.fx.Animation'); goog.require('goog.fx.Animation.EventType'); goog.require('goog.fx.Animation.State'); goog.require('goog.fx.AnimationEvent'); goog.require('goog.fx.easing'); which is why DragDrop isn't picked up. best, Kevin On Feb 10, 3:44 pm, billh2233 wrote: > I don't understand (def someVar (newInstantiatedGoogFxObject...)). > Why does (def someVar (new-goog-fx-object ...)) fail whereas (let > [somevar (new-goog-fx-object ...) ] works? > > I'm trying to define a variable using def and instantiate a new > goog.fx.DragDrop, but this clojurescript: > > (def dragSource (fx/DragDrop. "myText" "stuff")) > > produces this javascript and resulting error: > > dom.test.dragSource = (new goog.fx.DragDrop("myText","stuff")); > > -->Uncaught TypeError: undefined is not a function > > whereas the let-based version instantiates and executes just fine: > > (defn run-draganddrop [] > (let [dragSource (fx/DragDrop. "myText" "stuff")] > ... > ) > ) > > --- > Here is the actual source file: > > (ns dom.test > (:require [goog.fx :as fx] > [goog.graphics :as graphics] > )) > > ;FAILS in the browser. It requires the expression to be a function. > The expression is undefined. > ;IMO the expression should produce a new object and should not be a > function. > (def dragSource (fx/DragDrop. "myText" "stuff")) > > ;SUCCEEDS. > (defn run-draganddrop [] > (let [dragSource (fx/DragDrop. "myText" "stuff")] > ) > ) > > Thanks. Bill -- 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: No show?
On Thu, Feb 09, 2012 at 11:41:31AM -0400, Stuart Halloway wrote: > > clojure.reflect/reflect gets you the same information as a big 'ole data > > structure. You can pprint it for readability. > > > > The only thing that was not ported was the formatted text output, which > > would be easy enough to reproduce based on `reflect`. > > In particular, reflect + clojure.pprint/print-table. > => (require 'clojure.reflect) nil => (require 'clojure.pprint) nil => (clojure.pprint/print-table (clojure.reflect/reflect Math)) ClassCastException clojure.lang.Keyword cannot be cast to java.util.Map$Entry clojure.lang.APersistentMap$KeySeq.first (APersistentMap.java:132) But reflect is useful enough just as a map, so problem solved, thanks! -ken -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
clojure-opennlp
HI everyone, I was just wondering whether anyone has used the clojure-opennlp wrapper for multi-word named entity recognition (NER)? I am using it to train a drug finder from my private corpus and even though i get correct behavior when using the command line tool of apache openNLP when trying to use the API i only get single-words entities recognised!!! I've opened up a thread in the official mailing list because initially i thought there was a genuine problem with openNLP but since the command line tool does exactly what i want i'm starting to think that it might not be openNLP's fault but either in my code or in the clojure wrapper... I've followed both the official tutorials and the wrapper documentation and thus i am doing everything as instructed... I know the name finder expects tokenized sentences and i am indeed passing tokenized sentences like this: (defn find-names-model [text] (map #(drug-find (tokenize %)) (get-sentences text))) It is very strange because i am getting back "Folic" but not "Folic acid" regardless of using the exact same model i used with the command line tool... Any help will be greatly appreciated... Regards, Jim -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure CDT up, cont, down, local-names throws arity errors after hitting breakpoint
SeanC is referring to is the fact that swank-cdt now works seamlessly with clojure-jack-in, thanks to the efforts @tavisrudd and the indefatigable technomancy. On Feb 9, 9:18 am, Sean Corfield wrote: > On Wed, Feb 8, 2012 at 10:16 PM, George Jahad > > wrote: > > If you use Emacs and Swank-clojure, it is much > > easier to use swank-cdt, as your UI: > > >http://georgejahad.com/clojure/swank-cdt.html > > I just want to chime in and say swank-clojure 1.4.0 has made this > process so much simpler and it really is a pleasure to work with! I > had a nasty bug in my code the other day and was able to track it down > and fix in "only" about an hour and a half using CDT this way - I > dread to think how long it would have taken with a less integrated > tool chain setup... > -- > Sean A Corfield -- (904) 302-SEAN > An Architect's View --http://corfield.org/ > World Singles, LLC. --http://worldsingles.com/ > > "Perfection is the enemy of the good." > -- Gustave Flaubert, French realist novelist (1821-1880) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Symbols, vars, and namespaces
Using your example--very helpful, BTW--I simplified it a bit more: user=> (def x 10) #'user/x user=> (def y #'x) #'user/y user=> y #'user/x user=> @y 10 user=> (def x (fn [me] (println "Welcome" me))) #'user/x user=> (y "hello") Welcome hello nil user=> (@y "yikes") Welcome yikes nil What I come away with from this is a better understanding that when I refer to "y" in the above code, it's going to return a symbol. When I place this value in the first slot of a list, the symbol will act in its role as a function. Otherwise, if "y" is holding a reference to a symbol that is a value, like 10, then I need to dereference it to use it. user=> (def x 15) #'user/x user=> @y 15 user=> (y) java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0) I believe that ClassCastException makes more sense to me now. Like you said, pointers. I suppose my brain just doesn't want to accept pointers in the JVM! On Feb 11, 3:59 am, Alan Malloy wrote: > In this case the var is simply acting as a mutable pointer, so that > when the implementation is changed the route reflects the new value. > Here's a simple example of that behavior in action, divorced from > webservers and the like: > > ;; caller accepts a function and returns a new one that forwards to it > repl-1=> (defn caller [f] (fn [x] (f x))) > ;; initially we use identity > repl-1=> (defn callee [x] x) > > ;; the first form passes the current value of callee; the second > passes the "pointer" > repl-1=> (def passed-value (caller callee)) > repl-1=> (def passed-var (caller #'callee)) > > ;; if we redefine callee, only the pointer-version sees the new value > repl-1=> (defn callee [x] (* 2 x)) > repl-1=> (passed-value 4) > 4 > repl-1=> (passed-var 4) > 8 > > On Feb 11, 2:11 am, Sean Bowman wrote: > > > > > > > > > I've been working with Compojure and Ring lately to build an app > > server, and I've gotten my brain stuck trying to figure out wrap- > > reload. It seems like I have to turn my routes into vars to get wrap- > > reload to work, but I don't understand why, and I suppose I don't > > really understand the "when" or "where" of the situation either. > > > For example, if I have a bunch of resource namespaces with > > (defroutes ...) calls in them, and a main "core" namespace that > > aggregates them all, wrap-reload will work in a scenario like this: > > > (defroutes combined > > #'myapp.resource.users > > #'myapp.resource.products > > #'myapp.resource.other > > (route/resources "/") > > (route/not-found "Page not found")) > > > In the above, changing code in any of the resource namespaces auto- > > reloads them. > > > But if I put two defroutes in the same namespace and try to "var" one > > of them, wrap-reload fails: > > > (defroutes defaults > > (route/resources "/") > > (route/not-found "Page not found")) > > > (defroutes all-routes > > myapp.resource.users > > myapp.resource.products > > myapp.resource.other) > > > (defroutes combined > > #'all-routes > > defaults) > > > If I pass combined to (handler/site ...) in Compojure, wrap-reload > > doesn't work. > > > And, if I take the original, and remove the vars, then try to call > > handler/site and var that route, it doesn't work either: > > > (defroutes combined > > myapp.resource.users > > myapp.resource.products > > myapp.resource.other > > (route/resources "/") > > (route/not-found "Page not found")) > > > (def app (handler/site #'combined)) > > > What am I not understanding here? I feel like this is the area I > > struggle with most, and I'm not getting it at all. > > > P.S. Please don't point me at lein-ring and have me just run that. > > I'm trying to finally understand this, and I also need to be able to > > access the REPL in the same classloader as the running server for > > other reasons. -- 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: novice question, performance surprise
There is a standard library function for this: separate. For example (separate even? coll) returns two results in a vector: (filter even? coll) and (filter odd? coll). On Feb 10, 9:05 pm, Manuel Paccagnella wrote: > On 02/09/2012 11:40 PM, Steve Miner wrote: > > > filter is lazy so it won't actually do the work unless the values are > > needed. To get a reasonable time, you need to use the result for some > > computation. Try something like this: > > > (defn sum-all [m] (reduce + (apply map + (vals m > > > (time (sum-all (separate-nums (range 1 > > It was pretty simple. I forgot laziness :/ > > I ran several times in a row both functions on the same sequence, and I > obtained these timings (functional first, iterative second): > > "Elapsed time: 3019.56405 msecs" > "Elapsed time: 621.744839 msecs" > > "Elapsed time: 867.197906 msecs" > "Elapsed time: 551.287444 msecs" > > "Elapsed time: 314.490382 msecs" > "Elapsed time: 647.862119 msecs" > > "Elapsed time: 328.403288 msecs" > "Elapsed time: 621.69671 msecs" > > "Elapsed time: 334.29854 msecs" > "Elapsed time: 839.599691 msecs" > > "Elapsed time: 272.061383 msecs" > "Elapsed time: 499.008063 msecs" > > The patterns seems to be this: initially the functional one is slower, > but quickly begins to run about twice as fast as the iterative one. > > Using instead a sequence of random numbers, I got a more stable result: > in average the functional approach is slower than the iterative one. > > I think the lesson here is this: use a functional approach, that way the > code is easier to write, read, compose and reason about. If and when you > need to optimize, one option is to rewrite some core functions in an > iterative style. A plus here is that functional code is easier to profile. -- 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: novice question, performance surprise
On Sat, Feb 11, 2012 at 4:44 PM, Jules wrote: > There is a standard library function for this: separate. Not according to clooj's tab completion, http://clojure.org/cheatsheet, or http://clojure.github.com/clojure/ -- none of those match any library function to the substring "sep", and the third includes clojure.set, clojure.string, and the like as well as clojure.core. The obvious implementation, FWIW, would be (defn separate [pred coll] [(filter pred coll) (remove pred coll)]) -- 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: novice question, performance surprise
(def separate (juxt filter remove)). It's in old-contrib, I think in clojure.contrib.seq-utils or something. Obviously not recommended for use in new programs. On Feb 11, 3:49 pm, Cedric Greevey wrote: > On Sat, Feb 11, 2012 at 4:44 PM, Jules wrote: > > There is a standard library function for this: separate. > > Not according to clooj's tab completion,http://clojure.org/cheatsheet, > orhttp://clojure.github.com/clojure/ > -- none of those match any library function to the substring "sep", > and the third includes clojure.set, clojure.string, and the like as > well as clojure.core. > > The obvious implementation, FWIW, would be > > (defn separate [pred coll] > [(filter pred coll) (remove pred coll)]) -- 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: novice question, performance surprise
On Sat, Feb 11, 2012 at 7:05 PM, Alan Malloy wrote: > (def separate (juxt filter remove)). Cute, but that makes giving it a docstring, pre- and postconditions, and similar things a pain. > It's in old-contrib, I think in clojure.contrib.seq-utils or > something. Obviously not recommended for use in new programs. I wouldn't consider it to be "a standard library function" then. What comes with the language implementation, and so is clearly "standard library", is clojure.core, clojure.set, clojure.io, etc.; even the modular new-contrib IMO doesn't quite qualify. -- 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: novice question, performance surprise
On Sat, Feb 11, 2012 at 4:22 PM, Cedric Greevey wrote: > Cute, but that makes giving it a docstring, pre- and postconditions, > and similar things a pain. You can get a doctoring and even arglists (for code assist in your IDE and for clojure.repl/doc): (def ^{:arglists '([pred coll]) } separate "Returns a pair of collections for which pred is truthy and falsey respectively." (juxt filter remove)) True, you can't get pre/post-conditions on it. How many people use those? (I know the answer is "Fewer than should" but I'm genuinely curious as to how many folks _do_) > even the > modular new-contrib IMO doesn't quite qualify. True, that opinion has also been expressed by members of Clojure/core: contrib library != standard library. At least not until a contrib module is promoted into the main clojure.* package itself. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: novice question, performance surprise
On Sat, Feb 11, 2012 at 8:46 PM, Sean Corfield wrote: > On Sat, Feb 11, 2012 at 4:22 PM, Cedric Greevey wrote: >> Cute, but that makes giving it a docstring, pre- and postconditions, >> and similar things a pain. > > You can get a doctoring and even arglists (for code assist in your IDE > and for clojure.repl/doc): > > (def ^{:arglists '([pred coll]) } separate > "Returns a pair of collections for which pred is truthy and falsey > respectively." > (juxt filter remove)) I said "makes giving it those a pain" rather than "makes giving it those impossible" for a reason, of course. :) >> even the >> modular new-contrib IMO doesn't quite qualify. > > True, that opinion has also been expressed by members of Clojure/core: > contrib library != standard library. At least not until a contrib > module is promoted into the main clojure.* package itself. "Comes with the language implementation" is my usual criterion for where to draw the line. (For languages with numerous implementations, there's usually an actual standard, which makes it explicit, but "comes with every language implementation and varies little from one to the next" will do if necessary.) -- 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: No show?
On 11 February 2012 10:35, Ken Restivo wrote: > => (clojure.pprint/print-table (clojure.reflect/reflect Math)) > ClassCastException clojure.lang.Keyword cannot be cast to java.util.Map$Entry > clojure.lang.APersistentMap$KeySeq.first (APersistentMap.java:132) print-table expects a sequence of maps, e.g. (print-table (:members (reflect Math))) or (print-table (:members (reflect Math :ancestors true))) to include inherited members. 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
Re: novice question, performance surprise
On Sat, Feb 11, 2012 at 5:46 PM, Sean Corfield wrote: > You can get a doctoring D**n you autocorrect! :) You can get a docstring... -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: No show?
On Sat, Feb 11, 2012 at 6:30 PM, Michał Marczyk wrote: > print-table expects a sequence of maps, e.g. > > (print-table (:members (reflect Math))) Wow! I had no idea how useful that could be... Learn something new every day! (and, lately, that's a new Clojure function every day...) -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Hierarchical logs
I've been working on a tracing library, that works much like clojure.contrib.trace (based on it, actually). One sticky problem I've found is, hierarchical logs are really crappy to try to stream to a file. You can't just keep writing to the end of the file - new data needs to be inserted before existing end-tags. So what I'm doing is storing the data as a list, until I know the data is complete, and then i turn it back into a tree to write the file. However I can't think of a simple way to do it, even though it seems like a simple operation. I want to turn this list of pairs (first item is the fn call or return value, the second is a truthy value marking whether it's a call or return) '[[(+ 1 (- 5 2) nil] [(- 5 2) nil] [3 true] [4 true]] I want to turn that into [(+ 1 (- 5 2)) [(- 5 2) 3] 4] Is there a simple way to do this? -- 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