Re: marking deprecated functions, namespaces or other?
Thanks Phil, I'll take a look D -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ClojureScript DOM-manipulation library?
Ryan, JQuery cannot be compiled by the closure compiler. If you use advanced mode compilation - you must include the minified jquery lib in your pages and an externs file when compiling clojurescript. If you are using simple optimisations you can include jquery as a "foreign lib" as documented here: http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html some externs files are found here (including jquery to 1.7) http://code.google.com/p/closure-compiler/source/browse/trunk/contrib/externs/ As well as: http://code.google.com/p/closure-compiler/source/browse/trunk/#trunk%2Fexterns The overhead of including the jquery minified js is probably not a major issue. I expect jquery plugins will generally not work if using advanced compilation. I may be wrong. Cheers Dave -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ProtegeClojureOMTabs-1.5 announcement
Hello dear Clojure users! New version of ProtegeClojureTab published on this link: http://oogis.ru/clojuretab In this version 1.5 added the digital maps of OpenMap and several application examples that uses GeoNames, Wikipedia and DBpedia's spatial data for displaying on the map. ProtegeClojureTab can be used as simple IDE for Clojure that uses Protege for visual knowledge representation and OpenMap for visual spatial information representation. Enjoy Protege OpenMap and Clojure! Sincerely, Ru -- 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
ClojureScript – inter-namespace usage
I ran into few issues with compiling ClojureScript sources: 1. ns macro doesn't support docstring; found http://dev.clojure.org/jira/browse/CLJS-86 2. ns macro doesn't support :import (required for defprotocol, defrecord) 3. `binding` doesn't seem to work with vars in :require'd namespaces I can live with #1 and to an extent with #2, however, #3 seems to be a tough one. Will ClojureScript eventually support binding of vars in :require'd namespaces? (I know ClojureScript doesn't have true vars, but I thought the user-experience should be the same as Clojure.) Shantanu -- 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: marking deprecated functions, namespaces or other?
FWIW, autodoc looks for something like {:deprecated "1.3"}. See https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L201 which results in http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/agent-errors. On Jan 6, 8:19 pm, Phil Hagelberg wrote: > Dave Sann writes: > > I sometimes have need to change the names of fns in some of my libs. > > > As I was doing this, I wondered - is there a way to mark a function or > > namespace or other as deprecated? > > > I have not seen anything to this effect. > > Here's what I use in Leiningen: > > https://github.com/technomancy/leiningen/blob/1.x/src/leiningen/core > > For things that are just deprecated but not moved, probably just > ^:deprecated or ^{:deprecated "1.3.1"} is probably best. > > -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
Clojure Extension for Chrome
Hi everyone, I recently wrote a Chrome browser extension for Clojure. Basically, it allows users to select a code snippet, right click it and choose Eval as Clojure from the context menu. Code would then be evaluated in the backend and the result shown in a message. I found the lack of ability to eval code directly on the blog where it is published so annoying that I wrote this plugin. If anyone else considers this feature useful, feel free to install it. Plugin link: https://chrome.google.com/webstore/detail/dkhaobmljgohccicjemmbacpooaacgeo GitHub repo: https://github.com/goranjovic/chromeclojure My blog post explaining what it is and how to use it: http://clockwork-fig.blogspot.com/2012/01/clojure-extension-for-chrome.html The project is open source - EPL specifically. If anyone wants to extend its functionality - fork it from GitHub and for the rest, you know what to do. P.S. Is it ok to use Clojure logo in the extension icon? Do I need a permission to use and if so, do I have it? -- 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 Extension for Chrome
Interesting plugin. I've been pondering for a while about whether it'd be interesting to write clojure (or language X) blog posts in a literate fashion, i.e. with weave and tangle that knew how to download the post and then extract and execute the code. This would come in rather handy since more often than not blog posts show a few snippets of code and then a link to github. Thoughts? U -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure Extension for Chrome
Goran Jovic writes: > P.S. Is it ok to use Clojure logo in the extension icon? Do I need a > permission to use and if so, do I have it? I believe the logo's trademark means you need permission. -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
Survey says: be eco-friendly (ClojureCLR Action Items)
Is anyone currently working on any of these action items for ClojureCLR? These items are from the blog post: http://clojureclr.blogspot.com/2011/11/survey-says-be-eco-friendly.html 1. Action item: Develop a version of Leiningen supporting ClojureCLR projects (nlein?) 2. Action item: Develop a NuGet distribution for ClojureCLR, and perhaps ported contrib libs 3. Action item: Develop Emacs support for ClojureCLR 4. Action item: Improve VS integration (vsClojure?) 5. Action item: Investigate Mono compatibility I have some spare cycles to work on vsClojure and/or Mono compatibility. Thanks Robert -- 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: Destructuring syntax
"Joy of Clojure" adds a second reason for this: "The second reason is because it allows us to conjure up other destructuring features by using forms that would otherwise make no sense. Because the item on the left of each pair will be a new local name, it must be a symbol or possibly a nested destructuring form. But one thing it can’t be is a keyword, unless the keyword is a specially supported feature such as :keys, :strs, :syms, :as, and :or." On Wed, Jan 4, 2012 at 7:20 PM, Matthew Boston wrote: > I'm with Alex. I think of it as though it's a let binding, cause > that's basically what's happening; the is bound to the scoped name. > > On Jan 4, 11:29 am, Alex Miller wrote: > > I had the same thought when I first started learning Clojure - I think > > the idea is that there is some nice mental resonance when > > destructuring matches up to your mental model of the data structure > > (it's literal form). In sequential destructuring, that holds but in > > maps it doesn't so things look "backwards". I think the way I've come > > to understand it is that when doing a let-style binding, the thing > > being bound is always "on the left" so when destructuring a map, you > > specify the variable, then the key which is looked up to provide the > > value. > > > > On Jan 4, 12:36 am, Johnny Weng Luu wrote: > > > > > > > > > > > > > > > > > One thing that seems weird is the way Clojure destructures a map > > > > > I have this map: {:last-name "Vinge" :first-name "Vernor"} which is > passed > > > to this function: (defn greet-author-2 [{fname :first-name}] ... ) > > > > > Wouldn't it be better doing: (defn greet-author-2 [{:first-name > fname}] ... > > > ) > > > > > You first type the keyword, then followed by the parameter to bind to. > It > > > reads that the value is bound to the parameter in the same place. > > > > > Feels more natural to me in a way. > > > > > Thoughts? > > -- > 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 -- Jeb Beich http://www.red-source.net/jeb -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Autodoc 0.9.0 (Finally!)
And there was much rejoicing. Tom: Thanks for the work on a great tool. It tends to be thankless work but its greatly appreciated. On Thu, Jan 5, 2012 at 4:07 AM, Tom Faulhaber wrote: > A new version of Autodoc (0.9.0) is now available from clojars. This > version should work with all versions of Clojure that exist in the > wild and is generally more robust to weird dependency relationships > than previous versions. > > For those who aren't familiar, Autodoc is the tool that is used to > generate the API documentation for Clojure (http://clojure.github.com/ > clojure) and the various contrib libraries (see index under > construction at http://clojure.github.com). > > Leiningen integration has been broken out into a separate project, > lein-autodoc (also 0.9.0), to provide better insulation between the > two. > > Full documentation can be found at http://tomfaulhaber.github.com/autodoc. > > New features in this version: > - Support for Clojure 1.3 > - Single namespace projects will now longer have an extraneous > overview page > - An index.clj file is generated that contains all the documentation > info for the project in Clojure readable form. > - A bunch of little things I can't even remember > > Coming soon: full documentation for protocols, types and records. > > This version has not been tested on an extensive set of projects, so > please do let me know if you see any problems. You can file issues at > https://github.com/tomfaulhaber/autodoc or just email. > > I do sincerely apologize to everyone who has been inconvenienced by my > long delay in getting this out. All the usual excuses apply. > > I hope this helps with all your Clojure work, > > Tom > > -- > 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 -- Gordon J Miller Oakwood Controls, Corp gmil...@oakwoodcontrols.com gordon.j.miller@mail.mil 571-989-1692 -- 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: Storing clojure lists and maps in Redis
It sounds like maybe you've already solved your problem, Shoeb, but just in case: The book _Clojure in Action_ has a section on data mapping and data persistence using Redis. You can download the source code here: http://www.manning.com/rathore/source-code.zip (The relevant files are chapter12_redis_datamapper.clj and chapter12_redis_persistence.clj) M On Thu, Jan 5, 2012 at 11:32 AM, Shoeb Bhinderwala wrote: > Hi Peter - > I looked at deep-freeze but did not quite understand how to use it. > I used the following to freeze my Clojure complex data structure - > results (map of list of maps) and persist to redis: > (redis/hmset k k (deep-freeze/freeze-to-array results)) > Then I tried to retrieve and thaw it as follows: > (deep-freeze/thaw-from-array (redis/hget k k)) > The thaw gives me the following exception: > java.lang.String cannot be cast to [B - (class > java.lang.ClassCastException) > What am I doing wrong? > ThanksShoeb > > On Jan 4, 10:55 am, Peter Taoussanis wrote: >> read/pr-str works well, but it's painfully slow relative to something >> likeRedis. JSON libraries and the like would be faster, but might >> require more contortions if you're using lots of Clojure data types. >> My 2c: the best overall compromise atm is the Deep-Freeze >> serialization library (https://github.com/halgari/deep-freeze). It >> gets you very decent performance and great support for Clojure data >> types. >> >> You don't mention whatRedisclient you're using, but be aware that if >> you're going to be going the binary serialization route, you'll want >> to communicate withRedisvia byte[]s rather than JVM strings. If >> you're using Jedis, take a look at BinaryJedis. >> >> Hope that helps! >> >> --Peter > > -- > 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
Bug with ClojureScript keyword? function
Hi, Is this a bug with ClojureScript's keyword? function? On the REPL, the return value of the function is fine. ClojureScript:cljs.user> (keyword? :foobar) true ClojureScript:cljs.user> (string? :foobar) false However, when the following is compiled to JavaScript, the output is not as expected: (js/alert (keyword? :foobar)) => false (js/alert (string? :foobar)) => true The actual JavaScript output is: alert.call(null,cljs.core.keyword_QMARK_.call(null,"�'foobar")); alert.call(null,cljs.core.keyword_QMARK_.call(null,"�'foobar")); Is this a bug, or something that is to be expected? Thanks! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ClojureScript DOM-manipulation library?
There is Luke VanderHart's excellent library, domina [https:// github.com/levand/domina]. I'm using it in a project now with great success. On Jan 6, 3:16 am, Shantanu Kumar wrote: > Is anybody working on a DOM-manipulation library for ClojureScript? > > There are several JavaScript libraries that can probably be wrapped, > but a ClojureScript library should be great. I noticed a short > comparative list of jQuery basic operations vs JavaScript equivalent > that looks interesting:http://sharedfil.es/js-48hIfQE4XK.html > > Shantanu -- 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
Help with binding
I have the following code (very simple) for writing some binary data to a file (def ^{:dynamic true} *out*) ;; writers (defmulti write-a (fn [spec val] (cond (keyword? spec) spec))) (defmethod write-a :byte [_ val] (.writeByte *out* (int val))) And this code to write to the dynamic *out* binding (defn id3-encode ([] (id3-encode test-out)) ([file] (with-open [out (-> (File. file) (FileOutputStream.) (BufferedOutputStream.) (DataOutputStream.))] (binding [*out* out] (map #(write-a :byte %) [\I \D \3]) When i run the id3-encode function I get this exception: user=> (fixlkg.fix/id3-encode) (user=> IllegalArgumentException No matching method found: writeByte for class clojure.lang.Var$Unbound clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:52) Could somebody help explain why this is happening. It appears to be because of either the map or the anonymous function. Because if I change the function to just iteratively call (write-a :byte \I) (write- a :byte \D) etc it works fine. Thanks, matthew -- 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 DOM-manipulation library?
Isn't domina a good library for dom manipulation ? https://github.com/levand/domina On 6 jan, 19:37, Chris Granger wrote: > So there's pinot, but I've come to a relatively similar conclusion to > Kovas that wrapping the goog libs aren't really the way to go. For > one, I was basically replicating aspects of jQuery (like event > delegation). > > Recently I started on doing some thing that makes jQuery play in the > Clojure world really nicely. I'll get this onto github soon. > > Cheers, > Chris. > > On Jan 6, 5:18 pm, kovas boguta wrote: > > > > > > > > > Yes. > > > I've created a jquery wrapper conveniently called cljs-jquery , > > however there is no documentation, tests, or general housekeeping yet > > so haven't announced it. If you are > > brave,https://github.com/kovasb/cljs-jquery > > > Previous libraries have followed the lead of the initial Clojurescript > > examples, and tried to wrap gclosure to make it more > > clojure-idiomatic. > > > I think this whole approach is a mistake. > > > This is not a generic data processing problem, so we shouldn't be > > converting the dom into verbose generic clojure structures with > > namespace prefixes everywhere. > > > DOM manipulation is ideally suited to a DSL. JQuery already defines > > the primitives, and provides the implementation. Lets just wrap it. > > > The idea of my library is trivial. Just have a macro that expands into > > a jquery call chain: > > > $(selector).f(a,b).g(c,d) > > is represented by > > ($ selector (f a b) (g c d)) > > > (note that f and g don't need buzz-killing namespace prefixes) > > > For bonus points, selector can be a hiccup structure (or a hiccup > > structure with embedded dom objects) which ends up saving a huge > > amount of code when creating new elements. > > > In general this is far more concise and easier to code than any other > > approach I've seen thus far. > > > On Fri, Jan 6, 2012 at 3:16 AM, Shantanu Kumar > > wrote: > > > Is anybody working on a DOM-manipulation library for ClojureScript? > > > > There are several JavaScript libraries that can probably be wrapped, > > > but a ClojureScript library should be great. I noticed a short > > > comparative list of jQuery basic operations vs JavaScript equivalent > > > that looks interesting:http://sharedfil.es/js-48hIfQE4XK.html > > > > Shantanu > > > > -- > > > 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: add records in mysql????
Hi You're not supposed to specify the insert statement. Try this: (sql/insert-record :books {:BOOK_ID "%", :BOOK_NAME "joe", :BOOK_PRICE 12, :BOOK_AUTHOR "siley"}) ...using the same values as in your insert statement. Don't know about BOOK_ID, though... -- Henrik On Fri, Jan 6, 2012 at 10:56 PM, jayvandal wrote: > I tried this code : > (defn add-ausers [user] > (sql/with-connection db > (sql/insert-record :books user > ["INSERT INTO books(BOOK_ID, BOOK_NAME, BOOK_PRICE, BOOK_AUTHOR) > VALUES('%','joe','12', 'siley')"]; > > (println rows > > user=> (mysql.core/add-ausers) > java.sql.SQLException: Can not issue data manipulation statements with > executeQu > ery(). (NO_SOURCE_FILE:0) > > What is Query?? > > On Jan 6, 1:20 pm, Allen Johnson wrote: > > You'd want to use one of the insert functions for that: > > > > (defn add-user [user] > > (sql/with-connection db > > (sql/insert-record :books user))) > > > > http://clojure.github.com/java.jdbc > > > > Allen > > > > > > > > > > > > > > > > On Fri, Jan 6, 2012 at 3:13 PM, jayvandal wrote: > > > i am using leinningen and mysql example. I can select records as: > > > > > (defn list-ausers [] > > > (sql/with-connection db > > >(sql/with-query-results rows > > > > > ["SELECT * FROM books WHERE BOOK_ID = '1'"] > > > (println rows > > > > > but I can't insert records,i doesn't like the query as: > > > > > (defn add-ausers [] > > > (sql/with-connection db > > >;(sql/with-query-results rows > > > > > sql ["INSERT INTO books(BOOK_ID, BOOK_NAME, BOOK_PRICE, > > > BOOK_AUTHOR) VALUES('2','joe','12', 'siley')"] > > > (println rows) > > > > > why or? > > > ;) > > > )) > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Clojure" group.> To post to this group, send email > tocloj...@googlegroups.com > > > Note that posts from new members are moderated - please be patient > with your first post. > > > To unsubscribe from this group, send email to> > clojure+unsubscr...@googlegroups.com > > > For more options, visit this group at > > >http://groups.google.com/group/clojure?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Odd Behavior of lazy-seq
I was implementing a lazy infinite Fibonacci sequence as an exercise, and it wasn't working. I remembered that I had seen a working example somewhere, Googled it, and up it came. And it works, but mine, while similar (and I've modified the two versions to make them even more similar except for the problem)...mine fails: ;; works: (take 7 fib-seq1) => (1 1 2 3 5) (def fib-seq1 ((fn rfib [a b] (lazy-seq (cons a (rfib b (+ a b) 1 1)) ;; fails: (take 7 fib-seq2) => IllegalArgumentException: Don't know how to create ISeq from: user$fib_seq2 (defn fib-seq2 ([] (fib-seq2 1 1)) ([a b] (lazy-seq (cons a (fib-seq2 b (+ a b)) Any clue as to why the second version fails? (This is with with clojure "1.3.0") -- 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
Difference between clojure.lang.Cons and clojure.lang.PersistenList
Hi and Happy New Year to all the Clojure mailing list, I am am having some trouble with the two classes Cons and PersistentList: user> (class (conj (map #(+ % 1) '(1 2 3)) 4)) clojure.lang.Cons user> (class '(1 2 3 4)) clojure.lang.PersistentList My problem is that list? returns false for a Cons and true for a PersistentList. What can I do to make my Cons a PersistentList, or is there a way to use another function instead of list? that will return true for both classes? Many thanks, Sam -- 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
Trying to understand variable capture
Hello, I'm reading /Clojure in Action/, and I'm confused by one of the examples. I'm hoping someone can clarify it for me. :-) The author gives an example of an assertion macro: (defmacro assert-true [test-expr] (let [[operator lhs rhs] test-expr] `(let [lhsv# ~lhs rhsv# ~rhs ret# ~test-expr] (if-not ret# (throw (RuntimeException. (str '~lhs " is not " '~operator " " rhsv#))) true This can be used in this manner: (assert-true (< 4 3)), which will raise an exception, since 4 is not less than 3. What I do not understand is why he does not need to use gensyms in the first let form (i.e., (let [[operator# lhs# rhs#] test-expr] ... ) . By my understanding, I would expect (let [rhs 3] (assert-true (= rhs 4))) To incorrectly fail to assert due to "rhs" being captured. However, it works the way the author intends (i.e., it raises an exception.) Why does "rhs" not get captured? Thanks! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
AoT Compilation fails
Hello. I'm currently hacking away at a small project (turn-based game) that as of now spans over 7 namespaces/files. I'm working in an emacs/lein/swank environment. lein run works without problems. lein compile/jar/uberjar fails, yelling NullPointerException at game.clj:1. (slime-compile-and-load-file) works on every single file without any exceptions. (slime-eval-buffer) on the main file and then (-main) also works without problems. I don't know what it is that could possibly make AoT compilation fail... -- 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
Two Slightly Different Versions Using lazy-seq: One works, One doesn't. Why?
Trying to get experience working with lazy-seq, after several earlier successful attempts, I was implementing a lazy infinite Fibonacci sequence as a lazy-seq (having already implemented it in a greedy way before), and it wasn't working. I remembered that I had seen a working example somewhere, Googled it, and up it came. And that version works, but mine, while very similar (and I've modified the two versions to make them even more similar except for the problem)...mine fails: ;; works: (take 7 fib-seq-works) => (1 1 2 3 5 8 13) (def fib-seq-works ((fn rfib [a b] (lazy-seq (cons a (rfib b (+ a b) 1 1)) ;; fails: (take 7 fib-seq-fails) => IllegalArgumentException: Don't know how to create ISeq from: user$fib-seq-fails (defn fib-seq-fails ([] (fib-seq-fails 1 1)) ([a b] (lazy-seq (cons a (fib-seq-fails b (+ a b)) Any clue as to why the second version fails? I have made about six attempts, and some work great, and some fail in this same manner. What is wrong with the "fails" version? (This is with with clojure "1.3.0") -- 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 with ClojureScript keyword? function
In the compiled code it looks like the call to keyword? Is happening in both cases. Wires are definitely crossed, but it's unclear where. Are you certain that the ClojureScript shown is the same code that gets compiled? -- 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: Odd Behavior of lazy-seq
It looks like you're trying to take from the function fibseq2 itself rather than the result of the function call. Try taking fron the invocation of it instead (I.e. put parens around it): -- 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: Help with binding
On Fri, Jan 6, 2012 at 9:25 AM, Matthew wrote: > (defn id3-encode > ([] (id3-encode test-out)) > ([file] > (with-open [out (-> (File. file) (FileOutputStream.) > (BufferedOutputStream.) (DataOutputStream.))] > (binding [*out* out] > (map #(write-a :byte %) [\I \D \3]) > > When i run the id3-encode function I get this exception: > > user=> (fixlkg.fix/id3-encode) > > (user=> IllegalArgumentException No matching method found: writeByte > for class clojure.lang.Var$Unbound > clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:52) Looks like laziness. If you don't use the return values from write-a then you should probably change (map #(write-a :byte %) [\I \D \3]) to (doseq [c [\I \D \3]] (write-a :byte c)) though an alternative is just to wrap the map expression in (dorun ...). If you do use the return values, wrap in (doall ...): (doall (map #(write-a :byte %) [\I \D \3])) The latter will cause the whole sequence of write-a return values to be held in memory at once. In this case you only have three such values, but I suppose you might have a larger job in reality than the short one you posted here with your query, or that your real code may return large objects from each call. All three modifications will ensure the writes take place inside the dynamic scope of the binding (and the surrounding with-open!). -- 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: Trying to understand variable capture
The names in the first let only exist at compile time and do not exist when the expanded form eventually runs. -- 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: Two Slightly Different Versions Using lazy-seq: One works, One doesn't. Why?
See my answer in the other, seemingly identical thread. -- 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: Difference between clojure.lang.Cons and clojure.lang.PersistenList
On Sun, Jan 8, 2012 at 10:30 AM, Samuel Lê wrote: > Hi and Happy New Year to all the Clojure mailing list, > > I am am having some trouble with the two classes Cons and PersistentList: > > user> (class (conj (map #(+ % 1) '(1 2 3)) 4)) > clojure.lang.Cons > user> (class '(1 2 3 4)) > clojure.lang.PersistentList > > My problem is that list? returns false for a Cons and true for a > PersistentList. > What can I do to make my Cons a PersistentList, or is there a way to use > another function instead of list? that will return true for both classes? If any (...) structure will do, test with seq? instead. If you really need a PersistentList, you'll probably have to call that class's constructor or resort to icky hacks like user=> (class (apply list (cons 4 '(1 2 3 clojure.lang.PersistentList (though much more evil would be user=> (class (eval `(quote ~(cons 4 '(1 2 3) clojure.lang.PersistentList instead), because for some odd reason and despite its name (list* 4 '(1 2 3)) returns a clojure.lang.Cons. -- 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: Disequality
Thanks for report. Please open a ticket. I'll look into this later this week. David On Saturday, January 7, 2012, jim wrote: > Hey David, > > From the readme the failing disequality example: > > (run* [q] > (fresh [x y] >(!= [x 2] [1 y]) >(== x 1) >(== y 2) >(== q [x y]))) > > gives me ([1 2]) > > Shouldn't it be: > > (run* [q] > (fresh [x y] >(!= [x 2] [1 y]) >(== x 1) >(== y 2) >(== q [x y]))) > > -- > 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: AoT Compilation fails
On Sun, 2012-01-08 at 10:01 -0800, Narvius wrote: > lein compile/jar/uberjar fails, yelling NullPointerException at > game.clj:1. Source and exact error message would be helpful here. > (slime-compile-and-load-file) works on every single file without any > exceptions. This doesn't tell you that AOT works in some context, because that SLIME function is implemented as a regular load on swank-clojure's side. -- Stephen Compall ^aCollection allSatisfy: [:each|aCondition]: less is 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
mysql and fruit tables
I have been able to access tables in mysql, but not able to add records. I look at the examples fo "fruit so I created a lein named fruitI made th project file as the mysql project file. I copied the database instructions as in mysql. I added all of the statements for the "fruit" example but I can't even get it to access the connection or the database Doesn't this statement access the mysql db? : (sql/with-connection db Here is the project file ; defproject fruit "1.0.0-SNAPSHOT" :description "FIXME: write description" :dependencies [[org.clojure/clojure "1.3.0"]] [org.clojure/java.jdbc "0.0.6"] [mysql/mysql-connector-java "5.1.6"]) here is the core file; (ns fruit.core (:require [clojure.java.jdbc :as sql])) (defn db {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql" :subname "//localhost:3306/world" :user "root" :password "pass"}) (defn create-fruit [] (sql/with-connection db (sql/create-table :fruit [:id :integer "PRIMARY KEY" "AUTO_INCREMENT"] [:name "varchar(25)"] [:appearance "varchar(25)"] [:cost "integer(5)"])) ;Inserting multiple rows ;If you want to insert complete rows, you can use insert-rows and provide the values as a simple vector for each row. Every column's value must be present in the same order the columns are declared in the table. This performs a single insert statement. If you attempt to insert a single row, a map of the generated keys will be returned. (defn insert-rows-fruit "Insert complete rows" [] (sql/insert-rows :fruit ["Apple" "red" 59 87] ["Banana" "yellow" 29 92.2] ["Peach" "fuzzy" 139 90.0] ["Orange" "juicy" 89 88.6])) ;Inserting partial rows ;If you want to insert rows but only specify some columns' values, you can use insert-values and provide the names of the columns following by vectors containing values for those columns. This performs a single insert statement. If you attempt to insert a single row, a map of the generated keys will be returned. (defn insert-values-fruit "Insert rows with values for only specific columns" [] (sql/insert-values :fruit [:name :cost] ["Mango" 722] ["Feijoa" 441])) ;Inserting a record ;If you want to insert a single record, you can use insert-record and specify the columns and their values as a map. This performs a single insert statement. A map of the generated keys will be returned. (defn insert-record-fruit "Insert a single record, map from keys specifying columsn to values" [] (sql/insert-record :fruit {:name "Pear" :appearance "green" :cost 99})) ;Inserting multiple records ;If you want to insert multiple records, you can use insert-records and specify each record as a map of columns and their values. This performs a separate insert statement for each record. The generated keys are returned in a sequence of maps. (defn insert-records-fruit "Insert records, maps from keys specifying columns to values" [] (sql/insert-records :fruit {:name "Pomegranate" :appearance "fresh" :cost 585} {:name "Kiwifruit" :grade 93})) ;Using transactions ;You can write multiple operations in a transaction to ensure they are either all performed, or all rolled back. (defn db-write "Write initial values to the database as a transaction" [] (sql/with-connection db (sql/transaction ; (drop-fruit) (create-fruit) (insert-rows-fruit) (insert-values-fruit) (insert-records-fruit))) nil) ;Reading and processing rows ;To execute code against each row in a result set, use with-query- results with SQL. (defn db-read "Read the entire fruit table" [] (sql/with-connection db (sql/with-query-results res ["SELECT * FROM fruit"] (doseq [rec res] (println rec) (defn db-read-all "Return all the rows of the fruit table as a vector" [] (sql/with-connection db (sql/with-query-results res ["SELECT * FROM fruit"] (into [] res (defn db-grade-range "Print rows describing fruit that are within a grade range" [min max] (sql/with-connection db (sql/with-query-results res [(str "SELECT name, cost, grade " "FROM fruit " "WHERE grade >= ? AND grade <= ?") min max] (doseq [rec res] (println rec) (defn db-grade-a "Print rows describing all grade a fruit (grade between 90 and 100)" [] (db-grade-range 90 100)) ;Updating values across a table ;To update column values based on a SQL predicate, use update-values with a SQL where clause and a map of columns to new values. The result is a sequence of update counts, indicating the number of records affected by each update (in this case, a single update and therefore a single count in the sequence). (defn db-update-appearance-cost "Update the appearance and cost of the named fruit" [name appearance cost] (sql/update-values :fruit ["name=?" name] {:appearance ap
mysql and fruit tables
I have been able to access tables in mysql, but not able to add records. I look at the examples fo "fruit so I created a lein named fruitI made th project file as the mysql project file. I copied the database instructions as in mysql. I added all of the statements for the "fruit" example but I can't even get it to access the connection or the database Doesn't this statement access the mysql db? : (sql/with-connection db Here is the project file ; defproject fruit "1.0.0-SNAPSHOT" :description "FIXME: write description" :dependencies [[org.clojure/clojure "1.3.0"]] [org.clojure/java.jdbc "0.0.6"] [mysql/mysql-connector-java "5.1.6"]) here is the core file; (ns fruit.core (:require [clojure.java.jdbc :as sql])) (defn db {:classname "com.mysql.jdbc.Driver" :subprotocol "mysql" :subname "//localhost:3306/world" :user "root" :password "pass"}) (defn create-fruit [] (sql/with-connection db (sql/create-table :fruit [:id :integer "PRIMARY KEY" "AUTO_INCREMENT"] [:name "varchar(25)"] [:appearance "varchar(25)"] [:cost "integer(5)"])) ;Inserting multiple rows ;If you want to insert complete rows, you can use insert-rows and provide the values as a simple vector for each row. Every column's value must be present in the same order the columns are declared in the table. This performs a single insert statement. If you attempt to insert a single row, a map of the generated keys will be returned. (defn insert-rows-fruit "Insert complete rows" [] (sql/insert-rows :fruit ["Apple" "red" 59 87] ["Banana" "yellow" 29 92.2] ["Peach" "fuzzy" 139 90.0] ["Orange" "juicy" 89 88.6])) ;Inserting partial rows ;If you want to insert rows but only specify some columns' values, you can use insert-values and provide the names of the columns following by vectors containing values for those columns. This performs a single insert statement. If you attempt to insert a single row, a map of the generated keys will be returned. (defn insert-values-fruit "Insert rows with values for only specific columns" [] (sql/insert-values :fruit [:name :cost] ["Mango" 722] ["Feijoa" 441])) ;Inserting a record ;If you want to insert a single record, you can use insert-record and specify the columns and their values as a map. This performs a single insert statement. A map of the generated keys will be returned. (defn insert-record-fruit "Insert a single record, map from keys specifying columsn to values" [] (sql/insert-record :fruit {:name "Pear" :appearance "green" :cost 99})) ;Inserting multiple records ;If you want to insert multiple records, you can use insert-records and specify each record as a map of columns and their values. This performs a separate insert statement for each record. The generated keys are returned in a sequence of maps. (defn insert-records-fruit "Insert records, maps from keys specifying columns to values" [] (sql/insert-records :fruit {:name "Pomegranate" :appearance "fresh" :cost 585} {:name "Kiwifruit" :grade 93})) ;Using transactions ;You can write multiple operations in a transaction to ensure they are either all performed, or all rolled back. (defn db-write "Write initial values to the database as a transaction" [] (sql/with-connection db (sql/transaction ; (drop-fruit) (create-fruit) (insert-rows-fruit) (insert-values-fruit) (insert-records-fruit))) nil) ;Reading and processing rows ;To execute code against each row in a result set, use with-query- results with SQL. (defn db-read "Read the entire fruit table" [] (sql/with-connection db (sql/with-query-results res ["SELECT * FROM fruit"] (doseq [rec res] (println rec) (defn db-read-all "Return all the rows of the fruit table as a vector" [] (sql/with-connection db (sql/with-query-results res ["SELECT * FROM fruit"] (into [] res (defn db-grade-range "Print rows describing fruit that are within a grade range" [min max] (sql/with-connection db (sql/with-query-results res [(str "SELECT name, cost, grade " "FROM fruit " "WHERE grade >= ? AND grade <= ?") min max] (doseq [rec res] (println rec) (defn db-grade-a "Print rows describing all grade a fruit (grade between 90 and 100)" [] (db-grade-range 90 100)) ;Updating values across a table ;To update column values based on a SQL predicate, use update-values with a SQL where clause and a map of columns to new values. The result is a sequence of update counts, indicating the number of records affected by each update (in this case, a single update and therefore a single count in the sequence). (defn db-update-appearance-cost "Update the appearance and cost of the named fruit" [name appearance cost] (sql/update-values :fruit ["name=?" name] {:appearance ap
Re: Enlive reborn in ClojureScript - Enfocus (Dom Manipulation Lib)
Hey Creighton, I think this seems really, really interesting! Actually, I'm a little surprised that no one else has commented yet. I wouldn't take it as a bad sign if I were you: I suspect this is just a case of everyone waiting for someone else to take the first look: social proof in action ;) I also get the impression that Enlive itself seems to be quite widely misunderstood and consequently underrated. Haven't had a chance to take a serious look at this yet myself (I will!), but just wanted to throw my support behind the idea. Enlive's transformation model sounds like a great fit for the problem. And I'm surprised how mature the library seems to be already in terms of examples, documentation, etc. Definitely excited to check this out properly and give real feedback when I can. Keep up the great work! -- Peter -- 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