Re: (type ...) vs (class ...)
Found this: https://groups.google.com/forum/#!searchin/clojure/%22type$20metadata%22%7Csort:date/clojure/LBGsPs2__pQ/oLgx_kgmQxgJ :tag is applied to source forms to communicate type hints to the compiler. :type can be used, by convention, to add 'type names' to runtime data structures that support metadata. The type function will return the :type metadata if present, else the class, making it a handy dispatch function. Neither :tag nor :type are used directly by isa? Rich On Wednesday, October 24, 2018 at 12:30:14 AM UTC-7, Didier wrote: > > Reviving this thread, as I'd like to kmow if someone can explain the > purpose of the type metadata and what is responsible for adding 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 --- 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/d/optout.
Re: calling a clojure function within a quote/(')
user=> (cond-> query #_=> true #_=> (conj '[? :data/number ?number]) #_=> true #_=> (conj `[(~'> ~'?number ~(foo 2))])) [:find ?e :in $ :where [? :data/number ?number] [(> ?number 3)]] On Friday, November 17, 2017 at 6:15:18 AM UTC-8, Njab Soul wrote: > > Hi guys I need your help. > > I want to make a clojure query, but the :where conditions are condition. > SO i used cond->. > this works well. but now my problem is that I want to make a clojure > function call inside a (') or quote. > > > (defn foo [num] > > (inc num)) > > (def query '[:find ?e > :in $ > :where ]) > > (cond-> query > (some-condition) > (conj '[? :data/number ?number]) > (some-other-condition) > (conj `[~'(> ?number ~(foo 2))])) > > > I get this result: > [:find ?e > :in $ > :where [? :data/number ?number] > [(> ?number (clojure.core/unquote (foo 2)))]] > > > What I am trying to achieve is this: > > [:find ?e > :in $ > :where [? :data/number ?number] > [(> ?number 3)]] > > > Can anyone please 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 --- 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/d/optout.
[ANN] Kern 1.1.0 A library of parser combinators
Kern is a text-parsing library: https://github.com/blancas/kern 1.1.0 has two fixes (times, <+>); operator <*> minimum arity is now 1 (formerly 2). -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- 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/d/optout.
[ANN] Kern 1.0 parsing library
Release 1.0 updates dependencies and gets rid of a name collision with cat. These functions will let you write code that resembles the grammar you're parsing. I've found it useful for interpreters, translators and DSL's. repo: https://github.com/blancas/kern docs: https://github.com/blancas/kern/wiki API: http://blancas.github.io/kern/ -- 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/d/optout.
Re: [newbie] strange behaviour in self-referential primes lazy-seq attempt
Jorge, I tried this on 1.6 and seemed to work: (def primes (cons 2 (for [n (iterate inc 3) :when (prime? primes n)] n))) On Thursday, February 12, 2015 at 4:21:45 PM UTC-8, Jorge Marques Pelizzoni wrote: Neither did delay help: (defn primes [] (let [primes' (atom nil)] (reset! primes' (delay (cons 2 (filter #(prime? (force (deref primes')) %) (drop 3 (range Serious this is not a bug? Em quinta-feira, 12 de fevereiro de 2015 22:14:46 UTC-2, Jorge Marques Pelizzoni escreveu: Thanks, Michael, for your analysis and explanation. However not even this worked: (defn primes [] (let [primes' (atom nil)] (lazy-seq (reset! primes' (lazy-seq (cons 2 (lazy-seq (filter #(prime? (deref primes') %) (drop 3 (range)) -- 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/d/optout.
Re: Modelling in Clojure
Sure, that's the theory behind encapsulation, but I'm not convinced there are many cases in practice where the API can remain consistent while the data changes. I'm not, either. Models that have little or no abstraction --basically aggregates of related items-- end up having APIs that just reflect their contents. For years, my tools were the Eclipse refactoring features and the code (re)generation of the Eclipse Modeling Framework, not encapsulation. I started using Clojure practices, though not totally convinced until a while ago Stuart Sierra wrote: The data *is* the API, which helped me understand what I was really doing. Whereas I never faced the proverbial computed-field change, I've now taken good advantage of generic functions over maps and records. -- 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/d/optout.
Re: clojure/data.json parsing
Alan, what if you do (prn orders_query_result) If the json string is being parsed correctly you should get string values printed in double quotes, as Tobias's examples showed. On Saturday, September 27, 2014 1:25:27 PM UTC-7, Alan Moore wrote: Yes, I printed the type of body and as expected it is a JSON string and as it is printed in the output. That is what I'm trying to parse into clojure data using clojure/data.json. I am not in control of the data format from the server side - it is a third party service. The content-type is text/json... :-\ Thanks for your suggestion. Alan On Saturday, September 27, 2014 12:31:07 PM UTC-7, Tobias Kortkamp wrote: I hope I understood you correctly. You basically don't want to use println if you want to print data in such a way that it can be read in again. For that you need to use pr, prn or pr-str. Example: (println {:a hi there}) will print {:a hi there} (prn {:a hi there}) will print {:a hi there} (println Ex: (pr-str {:a hi there})) will print Ex: {:a hi there} In other words I suspect that your example's :paymentStatus is the string QUEUED already. You can check if a value v is a string with (string? v). -- 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/d/optout.
Re: ClassCastExecption with conj on deftype
Your implementation of cons in your deftype is probably being associated to the ISeq type, not IPersistentCollection. user= (deftype Foo [a b] #_= clojure.lang.IPersistentCollection #_= (cons [_ c] [a b c])) user.Foo user= (conj (Foo. 1 2) 3) [1 2 3] I think Vector supports ISeq through the Seqable interface but not directly. So your type Foo may not need it: user= (.cons [] 1) ; ok [1] user= (.first [] 1) ; ?? IllegalArgumentException No matching method found: first for class clojure.lang.PersistentVector clojure.lang.Reflector.invokeMatchingMetho On Wednesday, September 3, 2014 10:13:36 AM UTC-7, Karsten Schmidt wrote: Hi all, I've defined a custom vector type and implemented various clj/cljs protocols, but now ended up hitting my head against some weird behaviour with conj (or rather cons, internally). The type defines a 2-element vector-like construct and my cons implementation would simply return a standard clojure.lang.PersistentVector with the given arg added like this: (deftype Foo [a b] clojure.lang.IPersistentCollection clojure.lang.Indexed clojure.lang.Sequential clojure.lang.ISeq clojure.lang.Seqable clojure.lang.Reversible ;; ... elided seq fn impls... (cons [_ c] [a b c])) However, attempting a conj results in an exception I don't understand: (conj (Foo. 1 2) 3) java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.ISeq at user.Foo.cons (foo.clj:13) user.Foo.cons (foo.clj:-1) clojure.lang.RT.conj (RT.java:562) clojure.core$conj.invoke (core.clj:83) ... As far as I can tell, clojure.core/conj simply calls RT.conj(coll, x), which just calls coll.cons(x): https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L604 static public IPersistentCollection conj(IPersistentCollection coll, Object x){ if(coll == null) return new PersistentList(x); return coll.cons(x); } So where in that call path is there an attempt or requirement to cast to an ISeq? I've been comparing notes (as far as this possible) with the default PersistenVector implementation, but not sure where I'm going wrong here... -- 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/d/optout.
Re: How to refactor data safely?
Jakub, I'll be interested to learn how you work this out. I also work with data whose structure is known to functions in various modules, thus its very shape is a contract. This is coming from the other end of encapsulating everything in Java classes and interfaces. Also, I write test cases at a high level and not really as unit tests, which prevents rewriting test after a refactoring but will like to know how you handle that too so as to reduce any rework there or else whether it's worth the maintenance. Short of a massive refactoring of data and code, maybe writing data-transform function? Not sure about the proxy concept (is that data?) but if a function can produce the new format from the old you may start changing one consumer function at a time; then work on the producers until you can switch and remove the transform. On Thursday, May 22, 2014 1:17:52 AM UTC-7, Jakub Holy wrote: I have a nested data structure, used by a bunch of functions that presume knowledge of its structure, and I wonder how to change a part of the structure in a safe way, preferably in small incremental steps, rather than having my code broken until I update all the functions and tests for the new structure. I believe many of you must have experiences with this, would you care to share some tips? The data structure is first built incrementally and the collected data is later summarized. Instead of replacing the raw data with their summary, I want to keep both, so I want to wrap the data with a map; i.e. from: { id [ data...] } ;; later replaced with {id summary} to {id {:data [data...], :summary ...} I have a number of functions operating on the structure and tests for those functions (with test data that also need to be updated w.r.t. the refactoring). When I change one of the functions to produce the new data structure (i.e. data wrapped in a map instead of the data itself), everything else breaks. So I fix some tests and another function and get even more failures. This does not feel as a good way to do it as I prefer to have limited redhttp://www.infoq.com/presentations/The-Limited-Red-Societyand am fond of parallel changehttp://theholyjava.wordpress.com/wiki/development/parallel-design-parallel-change/for that reason. Ideally, I would have an automated refactoring or the possibility to wrap the data in some kind of a two-faced proxy that could behave both as a vector (towards the old code) or as a map containing the vector (towards the updated code) [some thing like lenses/cursor?!]. I haven't either so I guess the only option remaining is a well-controlled process of updating the structure and code. Any advice? Thank you! /Jakub -- *Forget software. Strive to make an impact, deliver a valuable change.* *(**Vær så snill og hjelp meg med å forbedre norsken **min –** skriftlig og muntlig. Takk!**)* Jakub Holy Solutions Engineer | +47 966 23 666 Iterate AS | www.iterate.no The Lean Software Development Consultancy - http://theholyjava.wordpress.com/ - -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To 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/d/optout.
Re: Leiningen just hangs
I've had this problem and I suspect is low memory. It happened often with an old box with 1G running Fedora 20, but I've also seen it with my laptop if I leave too many leftover jvm processes running (with 4G allocated for a virtual box instance); on my 16G mac it never happens. So freeing up some memory has fixed it for me. On Thursday, May 15, 2014 11:34:36 AM UTC-7, Mark Watson wrote: I'm running Leiningen on CentOS 6.5. Everything was working fine, and today when I try lein run it just hangs. It takes about 15 minutes for lein version to return. The project works fine on my macbook pro, and another CentOS box. I deleted ~/.m2 and reinstalled Leiningen. I updated Leiningen. I removed and reinstalled Java as well. Has anyone else come across this? I have no clue what I did or what the problem could be. Any help would be greatly appreciated. -bash-4.1$ java -version java version 1.7.0_55 OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13) OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode) -bash-4.1$ lein version Leiningen 2.3.4 on Java 1.7.0_55 OpenJDK 64-Bit Server VM -- 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/d/optout.
Re: Example of using ANTLR from Clojure?
I haven't touched this project in a while, but it might be useful. https://github.com/blancas/tinypost This file has the relevant interop code: src/main/clojure/blancas/tinypost/scan.clj On Saturday, April 26, 2014 3:04:50 AM UTC-7, Kranthi Rajoli wrote: Hi Paul, Do you mind outlining the method you used? I am exactly looking for the same. My Java skills are pathetic too. Thanks, Kras On Wednesday, September 9, 2009 4:17:07 AM UTC+5:30, Paul Henning wrote: Thanks for the information. Once I bit the bullet and learned a bit of Java, it was actually pretty easy to call ANTLR from clojure, after getting all the package naming figured out. Paul On Sep 6, 6:22 am, Laurent PETIT laurent.pe...@gmail.com wrote: 2009/9/5 Mike Hinchey hinche...@gmail.com I don't know anything about it, but counterclockwise uses antlr. http://groups.google.com/group/clojuredev-devel/browse_thread/thread/... That's true. To be more precise, we have a clojure lexer which is extensively used in Counterclockwise clojure source editor for syntax coloration. There is also the lexer part but it was developed a long time ago (so may not be still accurate), and is not used yet (so maybe the way the AST is constructed is nood in the good shape for most purpose). But to come back to your concern of using antlr from clojure : no, Counterclockwise is not yet written in clojure (just the client/server part for communicating with running projects instances) and so you wil not be able to find examples for that, sorry :-( -- Laurent -- 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/d/optout.
Re: creating a map
To add a little, into is generic and has no special treatment if the collection is a map, but works with maps if the elements are vectors because map associations of key-value pairs are a subclass of vector. The other way around: user= (for [elem {:foo :bar}] elem) ([:foo :bar]) ; extracts :foo - :bar as a vector On Wednesday, March 26, 2014 5:51:09 PM UTC-7, Robert Marianski wrote: into expects that because it is implemented with conj. (conj {} [:foo :bar]) {:foo :bar} On Wednesday, March 26, 2014 4:41:16 PM UTC-4, Michael Gardner wrote: For reasons unclear to me, (into {} ...) expects a sequence of 2-element *vectors*, not just 2-element collections. partition returns a seq of lists, not vectors, which is why you're getting that exception. You could try (into {} (map vec (partition 2 2 12))) instead. On Mar 26, 2014, at 15:36 , Andy Smith the4th...@googlemail.com wrote: Hi all, I was wondering why this doesn't create a map 1 - 2 : (into {} (partition 2 2 12)) Must be yet another misunderstanding of mine. Thanks Andy -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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/d/optout.
Re: What is the right way to create dynamic var in another namespace?
This came up a while back and it appeared that the metadata just reflected whether the var was created with the ^:dynamic annotation. But the meta attribute is an output, so to speak; the info flows from the var declaration to the meta but not the reverse. Maybe it'll remain like that as there's already a solution. On Saturday, March 1, 2014 7:02:14 AM UTC-8, Эльдар Габдуллин wrote: I expected the following to work, but it doesn't: (defn declare-foo [] (intern *ns* (with-meta '*foo* {:dynamic true :private true}) foo)) Although it creates a var, it is not dynamic. We can mark it dynamic ourselves, but it seems that such ability is an implementation detail. (defn declare-foo [] (.setDynamic (intern *ns* (with-meta '*foo* {:private true}) foo))) May be it's a Clojure bug and the first variant is supposed to work? -- 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: Can't start repl with Leiningen
I had the same problem with an old box I had around the house. Put Fedora 20 on it with a recent open jdk, but had just 1GB of memory total. I attributed the error to the lower memory since I never have that issue at work or other machines with at least 4GB. If you have more than 2GB, experiment with something like -Xms1024M or more. On Wednesday, February 26, 2014 9:28:42 AM UTC-8, Matej Fröbe wrote: Debian jessie 32-bit Am Mittwoch, 26. Februar 2014 15:50:19 UTC+1 schrieb John Gabriele: On Wednesday, February 26, 2014 3:19:43 AM UTC-5, Matej Fröbe wrote: It seems that this is independent of where I run the project. Matej, What OS (and version) are you using? -- 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: unconditional append to end
For efficient appends at the end you need a vector. Using the sequence library can be tricky while you're putting together your data structures because it's likely that you'll not done yet with type-specific functions. You'll need to re-create your vector after using map/filter/etc to be able to keep adding at the end. On Friday, February 7, 2014 4:20:09 PM UTC-8, t x wrote: Consider the following: (cons 1 '(2 3 4)) == (1 2 3 4) (cons 1 [2 3 4]) == (1 2 3 4) (conj '(a b c) 1) == (1 a b c) (conj '[a b c] 1) == [a b c 1] Now, I would like something that _always_ * appends to the end cons is almost what I want, except it always appends to front. conj is not what I want -- in fact, I'm afraid of conj. Often times, I'll run map/filter on something, and suddenly, instead of a vector, I now have a list -- and conj changes the order of the item added. Thus, my question: is there a builtin to _unconditinoally_ append to the end of a list/sequence/vector? 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 --- 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: bug in clojure.zip when calling next on empty list node?
The implementation of seq-zip uses seq? as its branching predicate. As a result the zipper goes down on () thinking it can have children: user= (seq? ()) true user= (seq? {}) false user= (seq? #{}) false user= (seq? []) false On Sunday, December 29, 2013 10:14:23 AM UTC-8, Lee wrote: I realize that many people are on holiday, but I'm hoping to get some clarity about how to proceed with respect to this issue in the near future. Can anyone tell if I'm right that this is a bug in clojure.zip? If so, then is the right thing to do to post an issue on JIRA? I've re-included the crux of the issue [slightly edited and recombined] below. Thanks, -Lee On Dec 21, 2013, at 11:49 AM, Lee Spector wrote: When I step through a zipper made from a nested list via seq-zip, I get extraneous nils after processing a nested (). Is this somehow expected behavior, or a bug, or am I misunderstanding something fundamental? The problem seems to arise only when an nested empty list is present, not other nested lists [... deleted ...] Here's an illustration, stepping through '(() 0) with next and printing the node at each step: (loop [z (zip/seq-zip '(() 0))] (if (zip/end? z) :done (do (println (zip/node z)) (recur (zip/next z) That produces: (() 0) () nil 0 :done I don't expect the nil to be there. [That is,] when traversing '(() 0) with zip/next, one should first visit the root, then (), and then 0. But what actually happens is that between then () and the 0 one lands on a non-existent nil node. So one ends up visiting 4 nodes when there are only 3, and the extra one is a nil. -- -- 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: java.jdbc DSLs (java.jdbc.sql / java.jdbc.ddl)
We use select several times in one module; it wouldn't be hard to just copy and paste the function somewhere. Now, you could drop DSL and call it optional utility functions not to be used when deemed unhelpful, or whatever. Given your goals stated goals that code isn't bad at all. On Thursday, November 21, 2013 10:12:05 PM UTC-8, Sean Corfield wrote: I spent this afternoon removing use of java.jdbc.sql from World Singles’ code base to see how much work it would be. The worst part for us was how much we relied on the naming strategy convenience macros (especially entities, since it flows :entities through all the DSL constructs). How much impact would it have on you, Alexander, if the java.jdbc.sql namespace went away? Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.orghttp://www.google.com/url?q=http%3A%2F%2Fcorfield.orgsa=Dsntz=1usg=AFQjCNEL49glywShirO3tmvwx6FLxKUMog *From:* Alexander Hudek javascript: *Sent:* Thursday, November 21, 2013 7:37 PM *To:* clo...@googlegroups.com javascript: Is anyone using the java.jdbc.sql namespace? (besides World Singles :) We are using it but not the DDL. We also use honeysql in places where jdbc.sql cannot express the query. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: 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+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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: java.jdbc DSLs (java.jdbc.sql / java.jdbc.ddl)
Didn't think of that. I can just rewrite those simple select calls with parameterized raw SQL, which is our preferred way of using the API. On Friday, November 22, 2013 2:09:19 PM UTC-8, Sean Corfield wrote: On Fri, Nov 22, 2013 at 1:04 PM, Armando Blancas abm2...@gmail.comjavascript: wrote: We use select several times in one module; it wouldn't be hard to just copy and paste the function somewhere. Technically, copying it into your code means absorbing some EPL code and copyright © 2013 Sean Corfield stuff so beware of that in commercial situations (I personally don't mind but lawyers at some companies will object to this). Perhaps a solution here is for me to put it in a library, on Clojars, under a different name and let folks migrate to that as an interim solution (i.e., identical API so folks would just update project.clj and update some ns declarations)? FWIW, I replaced most (select ...) uses in our code with raw SQL in a vector with the parameters, completely replacing the DSL usage where it was easy to do so. I also wrote a function to mimic a subset of (where ...) to just produce the WHERE condition with our quoting of entities strategy hard-coded (and managed the parameters separately). I also mimicked a subset of (order-by ...) with our quoted strategy hard-code, which I could probably simplify some more if I analyze our usage for more than a few minutes. I've asked for guidance on clojure-dev as well, but I suspect I'm in somewhat uncharted territory with a contrib lib wanting to revert a big chunk of changes in an already released (alpha / beta) version of a library. In order to tackle the API bloat (which is temporary until the old 0.2.3 API goes away), one possibility is to restore java.jdbc 0.2.3 to something like java.jdbc.deprecated and strip java.jdbc down to just the new API. It would be a breaking change but relatively painless (just change some ns declarations to switch from java.jdbc to java.jdbc.deprecated for old code, or add java.jdbc.deprecated to support both old and new code). -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/http://www.google.com/url?q=http%3A%2F%2Fcorfield.org%2Fsa=Dsntz=1usg=AFQjCNG57Vm86qfEJUyx_sSGjmOALf2UOQ World Singles, LLC. -- http://worldsingles.com/http://www.google.com/url?q=http%3A%2F%2Fworldsingles.com%2Fsa=Dsntz=1usg=AFQjCNHT-zNEBlNDjKzS125fhVhCAN0j3g 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 --- 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: Rush Hour - an example Clojure architecture
Good work. Thanks for putting this out. On Monday, October 28, 2013 6:03:54 AM UTC-7, Michael Drogalis wrote: Hi everyone, I'm happy to announce the Rush Hour platform - highly realistic traffic simulations done with a careful, exemplar architecture all in Clojure. GitHub platform page: https://github.com/MichaelDrogalis/rush-hour Blog post about the architecture: http://michaeldrogalis.tumblr.com/post/65274692089/clojure-understood-the-rush-hour-platform -- Michael Drogalis -- -- 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: much lower recursion depth with memoization
With memoize there are additional calls (the new function and apply) per recursion, so I guess that will produce the stack overflow to happen sooner. You can use memoization once you remove the stack issue with iteration: (defn gauss-iter [n] (letfn [(f [n acc] (if ( n 1) acc (recur (dec n) (+ acc (dec n)] (f n n))) (def gauss-memo (memoize gauss-iter)) On Sunday, September 22, 2013 8:19:23 AM UTC-7, John Lawrence Aspden wrote: Hi Guys, I'm trying to memoize a fairly complicated double recursion, and it's blowing stack after not terribly many calls. I've reduced the problem to a simple test case, summing from 1 to n : user= (clojure-version) 1.5.1 user= (def gauss-recurse (fn [n] (if ( n 1) 0 (+ n (gauss-recurse (dec n)) #'user/gauss-recurse user= (gauss-recurse 3500) 6126750 user= (def gauss-memoized (memoize (fn [n] (if ( n 1) 0 (+ n (gauss-memoized (dec n))) #'user/gauss-memoized user= (gauss-memoized 160) StackOverflowError clojure.lang.RT.boundedLength (RT.java:1654) user= Does anyone know why this would happen? Do I just have to give up on memoization and find another way to do dynamic programming? Cheers, John. -- -- 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: finding retained head
Can anyone explain to me what's happening here? Something about creating a anonymous function? The problem is not creating the anonymous function but that it closes over the matrix argument. The closure passed on to blah will keep a reference to matrix until blah returns. This won't happen if the anonymous function takes the matrix as a parameter: (defn blah [func v] (func v)) (defn load-exp [matrix] (blah (fn [m] (dorun (map identity m))) matrix)) -- -- 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: finding retained head
I also suspected the closure over the matrix argument as being the root cause but was puzzled when using doseq instead made the problem go away... Right, it doesn't seem to be a hold in the closure, unless the compiler could tell when to release it, which is the case when the code is macro expanded (doseq) or placed inline, but not when you call a function like dorun. That's really kind of puzzling. -- -- 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: Handling name collisions with clojure.core
I just think the default behaviour should be super-friendly and not spit out warnings. If other libs also redefine any of those operators or names, now or in later versions, I'd be glad to know. With last-one-in-wins some will lose. Maybe this will help: mvn clojure:repl 2 /dev/null -- -- 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: evaluation order in loading file/project (with leiningen)
I assume that making a makro out of *define-all-properties* is not the way to go, because it depends on the reading of a file, which should not yet be done at compile time (this may be a false assumption;...). Seems to me this is the key to how you'd construct your program. The csv file could be an artifact of your build, in which case it's got to be read at compile time and it's then when you make a top-level call to (define--all-properties) allowing you to compile (stop?), etc. If the file is input to your program, all this must be done at runtime: reading the file, calling (define-all-properties) and then loading any other code that depends on that, in effect making your program extensible. -- -- 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: To read and write bytes via Socket
With UTF-8 characters are encoded in a variable number of bytes according to various ranges, as you can see here in section Description: http://en.wikipedia.org/wiki/UTF-8 Since you're sending your bytes as chars but read back as bytes, your last two bytes create chars that later produce two bytes each, and thus you see seven bytes at the other end. You may want to get an output stream from the socket and write single bytes directly. On Wednesday, August 28, 2013 7:13:31 PM UTC-7, Yoshinori Kohyama wrote: Hello all. Please help me to read and write bytes via Socket. For example, assumed that I want to send 5 bytes [0x00, 0x01, 0x7f, 0x80, 0xff] to a TCP server. I did: (require '[clojure.java.io :refer :all]) (with-open [s (java.net.Socket. *ip.of.test.server* *port_of_test_server *)] (let [^java.io.BufferedWriter wtr (writer s) ^chars obuf (char-array (map char [0 1 127 128 255]))] (.write wtr obuf 0 5) (.flush wtr Then, my test server received bytes: [0x00, 0x01, 0x7f, 0xc2, 0x80, 0xc3, 0xbf]. * I think I should use a char array so that read() requires 'char[]'. * What is the valid char value to send a byte 0x80? * How can I make the char value from 0x80 int? * How are things about read. * Does character encoding environment affect? (I use -Dfile.encoding=UTF-8) Thank you in advance. Yoshinori Kohyama -- -- 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: tools for minimizing forward declaration
That's what I was referring to. Was there something specific about it that you wanted to call out? :) Nope; just wanted to bring it up. -- -- 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: tools for minimizing forward declaration
I'll point out as well that though I thought Yegge's criticisms of Clojure were a bit polemical (I guess that's his style), the single pass compiler issue was one of his biggest gripes, and I do think it still rings true. I feel like I have to babysit clojure in this regard, when I usually feel like clojure is babysitting me! :) Have you seen this? https://news.ycombinator.com/item?id=2467359 -- -- 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] Leiningen 2.3.0 released
[Mac OS X 10.8.4] I followed this same procedure as Sean and it worked for me last night. On Thursday, August 8, 2013 9:16:06 PM UTC-7, Sean Corfield wrote: It failed for me on Mac OS X 10.8.4 - this has also been a problem on Windows for me (which doesn't have curl / wget anyway). Can we please get the Leiningen JAR posted somewhere that is not prone to this sort of SSL problem? (! 536)- lein upgrade The script at /Developer/workspace/worldsingles/build/bin/lein2 will be upgraded to the latest stable version. Do you want to continue [Y/n]? y Upgrading... % Total% Received % Xferd Average Speed TimeTime Time Current Dload Upload Total SpentLeft Speed 100 126 100 1260 0261 0 --:--:-- --:--:-- --:--:-- 336 100 11353 100 113530 0 11459 0 --:--:-- --:--:-- --:--:-- 101k Manual self-install is deprecated; it will run automatically when necessary. Downloading Leiningen to /Users/sean/.lein/self-installs/leiningen-2.3.0-standalone.jar now... % Total% Received % Xferd Average Speed TimeTime Time Current Dload Upload Total SpentLeft Speed 0 00 00 0 0 0 --:--:-- --:--:-- --:--:-- 0 curl: (22) The requested URL returned error: 403 Failed to download https://leiningen.s3.amazonaws.com/downloads/leiningen-2.3.0-standalone.jar It's possible your HTTP client's certificate store does not have the correct certificate authority needed. This is often caused by an out-of-date version of libssl. Either upgrade it or set HTTP_CLIENT to turn off certificate checks: export HTTP_CLIENT=wget --no-check-certificate -O # or export HTTP_CLIENT=curl --insecure -f -L -o It's also possible that you're behind a firewall haven't yet set HTTP_PROXY and HTTPS_PROXY. Thu Aug 08 21:10:48 (sean)-(jobs:0)-(/Developer/workspace/worldsingles) (! 537)- HTTP_CLIENT=curl --insecure -f -L -o lein upgrade Downloading Leiningen to /Users/sean/.lein/self-installs/leiningen-2.3.0-standalone.jar now... % Total% Received % Xferd Average Speed TimeTime Time Current Dload Upload Total SpentLeft Speed 0 00 00 0 0 0 --:--:-- --:--:-- --:--:-- 0 curl: (22) The requested URL returned error: 403 /usr/bin/lein: line 63: download_failed_message: command not found Thu Aug 08 21:11:19 (sean)-(jobs:0)-(/Developer/workspace/worldsingles) On Thu, Aug 8, 2013 at 8:28 PM, Phil Hagelberg ph...@hagelb.orgjavascript: wrote: Hello everyone. I'm happy to announce the release of Leiningen version 2.3.0. This version contains mostly minor fixes, but some highlights include faster test runs when using selectors (by skipping fixtures), better support for detecting ambiguous version resolutions via :pedantic, and fixes to better isolate different profiles in different :target-paths. * Add `:eval-in :pprint` for debugging. (Phil Hagelberg) * Support cleaning extra dirs with `:clean-targets`. (Yoshinori Kohyama) * Test-selectors skip fixtures too, not just running tests. (Gary Fredericks) * Place licenses and readmes into jars. (Phil Hagelberg) * Include LICENSE as separate file in templates. (Wolodja Wentland) * Allow aborting on ambiguous version resolution with `:pedantic`. (Nelson Morris, Phil Hagelberg) * Scope `:compile-path` and `:native-path` under profile-specific target dir. (Phil Hagelberg) * Fix bug where uberjar filename would include provided profile. (Phil Hagelberg) * Deprecate explicit `self-install` command. (Phil Hagelberg) * Fix bugs around long lines in jar manifests. (Leon Barrett) * Support nested checkout dependencies. (Phil Hagelberg) * Fix bugs around `:filespecs`. (Jean Niklas L'orange) As usual, you can get the latest version by running `lein upgrade`. Thanks to all the contributors who helped make this happen. happy hacking, Phil -- 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 --- 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
Re: Wrong documentation of contains?
The keys docstring says it returns a sequence, and that's all you get: it'll do first and next, nothing special about it. The contains? docstring says it won't do a linear search, so that rules out the result of keys. (KeySeq just wraps a seq of entries to return the key field.) What's confusing to me here is that coll? will return true on a sequence. On Wednesday, August 7, 2013 9:15:54 AM UTC-7, puzzler wrote: Yes, the discussion about contains? has come up before, but there's a new aspect to this particular instance of the discussion that most of the posts seem to be ignoring. The original poster specifically pointed out that his sequence was constructed by calling the `keys` function on a map: (keys {:a f :b 23}) He then went on to point out that it doesn't return just a regular, ordinary lazy sequence, but some sort of special type called a KeySeq. The documentation says that `contains?` looks for whether a given key is present. Probably when the documentation was written, there was some assumption that by saying it looks for a key, that makes it obvious it only works on associative collections. But look here, we've got a sequence of keys. We know it is comprised of keys, and obviously Clojure knows it is a sequence just of keys (because of the custom type). Therefore, it was reasonable for the poster to think that `contains?` would work on to determine whether a given key was in the collection -- it is a collection with keys! So I think the new idea here, worthy of discussion, is this: How can we reword the doc for `contains?` so that it clearly does not apply to a sequence of keys? -- -- 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: Displaying objects in REPL: Clojure equivalent of Java's toString?
Adding to that... have a look at the implemented methods in core_print.clj. The print-method will get called on print and println with your instance as the first argument. In this example prints a pair type; since elements can be anything it just calls print on each. (deftype Pair [fst snd]) (defmethod print-method Pair [r, ^java.io.Writer w] (.write w Pair() (print (.fst r)) (.write w ,) (print (.snd r)) (.write w ))) On Thursday, August 1, 2013 3:04:47 PM UTC-7, Laurent PETIT wrote: I think you have to provide methods for multimethods print-dup and print-method: https://github.com/clojure/clojure/blob/c6756a8bab137128c8119add29a25b0a88509900/src/clj/clojure/core.clj#L3311 2013/8/1 Dragan Djuric drag...@gmail.com javascript:: I have some custom types defined using deftype and I am trying to enable a human-friendly string representation of these types in repl. Something similar to #Atom@123 value. How to do that in Clojure without redefining toString? It seems that Clojure use a different way to achieve this for atoms and refs, I just can't find what. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: 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+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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: Accessing Record Constructors
The constructor should be available, like in this contrived sample: Clojure 1.5.1 user= (deftype Foo [a] Object (toString [this] (Foo. 1))) user.Foo What error are you getting? On Wednesday, July 31, 2013 5:51:36 PM UTC-7, JvJ wrote: I tried to define this record, but the Vec2. constructor doesn't exist yet. How can I use the constructor inside the record's method? (defrecord Vec2 [x y] Vector (mag [this] (Math/sqrt (+ (* x x) (* y y (v+ [this] this) (v+ [this other] (Vec2. (+ (:x this) (:x other) (:y this) (:y other (v+ [this a b c] (reduce v+ this (conj c b 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 --- 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: Does this abstraction have any existing name?
morph's incomplete because it extends Functor only for collections and function composition; I'll add String and boxed types, but for now Long's extension must be supplied: (use 'blancas.morph.core) (extend-type java.lang.Long Functor (fun [this f] (f this))) With this, it's like alto.generic but fmap comes curried: user= (fmap inc {:a 3 :b 9 :c 16}) {:a 4, :c 17, :b 10} user= (fmap (fmap inc) {:a {:b 9 :c 16} :d 25}) {:a {:c 17, :b 10}, :d 26} For use with arbitrarily nested maps something like this is needed: (defn f [k] (fn g [x] (if (map? x) (fmap g x) (k x user= (fmap (f inc) {:a {:b 9 :c {:x 16 :y 20}} :d 25}) {:a {:c {:y 21, :x 17}, :b 10}, :d 26} On Friday, July 26, 2013 9:31:41 PM UTC-7, Ben wrote: On Fri, Jul 26, 2013 at 9:27 PM, Yoshinori Kohyama yyko...@gmail.comjavascript: wrote: Thank you, Ben. If I think the map as a tree, then as a functor, what I do is 'fmap' (in Haskell or some languages), ,as you say. Thanks for saying that. Does Algo supply things around Functor, Applicative and Monad? I'm going to look at Algo. Or anybody knows any other libraries or implementations around these things in Clojure? algo.generic has a functor implementation for regular maps which you could already use, if your maps have uniform depth: (fmap (partial fmap inc) {:a {:x 1} :b {:y 2}}) --- {:a {:x 2} :b {:y 3}} if you want to use that fmap (or, I'd think, the fmaps provided by either morph or fluokitten) with uneven depths, you'd have to wrap them in a defrecord or deftype, I'd expect. -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure. [Larousse, Drink entry] -- -- 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?
There is no one who understands `(if (seq thing)` who wouldn't understand `(if (not (empty? thing))` or, better, `(if (not-empty? thing)`. The converse is not true. That suggests that the latter should be the idiom No, it doesn't. That simply illustrates that idioms must be learned, as in any kind of language. But, for the rest of us, I don't believe you speak for the rest of us. Not for me, anyway. -- -- 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: unusual question: how do you get morale?(or moral support)
Zack, you've probably come across this profile on Jeff Hammerbacher, but just in case. The best minds of my generation are thinking about how to make people click ads, he says. That sucks. http://www.businessweek.com/printer/articles/55578-this-tech-bubble-is-different On Monday, May 13, 2013 2:03:10 PM UTC-7, Zack Maril wrote: One of the reasons I program is because I'm furious. By most accepted metrics, I went to one of the best technical public high schools in the country. I was average there and I was taking graph theory and multivariable calculus as a senior my last semester. The smart kids though? They were doing real analysis, topology, and winning international competitions for mathematics and science. I'm just finishing up college now and I'm watching the geniuses from my high school go from MIT and Stanford to high frequency trading firms or work for places like palantir and facebook. They're using their gifts to remove liquidity from the markets[0], to help fight wars based on lies[1], and to maximize the amount of money they can sell my privacy for[2]. Most of them use programming to indirectly decrease the quality of my life. I'd love it if I could invest money without fear of the markets going crazy because of a tweet[3], if I could support the government without worrying about them killing innocent citizens[4], and if I could connect with my friends and family without worrying about my privacy being sold to the highest bidder. My former classmates are and will be using computers to indirectly prevent me from doing the above with any sort of peace of mind. It is infuriating. When I sit down to program, I now make a conscious effort to build tools that I can use in the future to fight against the trends above. I use Clojure because it's the language I've been able to get the most done in the shortest amount of time. If there were a language that let me do as much as fast, I'd drop Clojure like a rock and learn that. If I want to stem the negative effects the geniuses are having on my life, I'll need to use the best tools possible. That means constantly learning more powerful concepts and building better tools. I've been on a graph theory and network science kick lately because I noticed that google, palantir, and facebook got where they are by virtue of being really good at graph theory. The concepts are crazy powerful and provide immense power to the people who can successfully employ them. So, when I sit down to work on certain projects, the main motivating factor for me is that I'm furious that my classmates are worsening my life. There's a ton of work that I need to do before I can do anything about it though. I'm obviously on a futile crusade fueled by my youth and naiveté, but for the moment, that's why I program. -Zack [0] http://www.nanex.net/aqck2/4136.html [1] http://krugman.blogs.nytimes.com/2013/04/27/the-great-degrader/ [2] https://www.facebook.com/legal/terms [3] http://seekingalpha.com/article/1362731-obama-is-dead-tweet-makes-for-flash-crash [4] http://www.latimes.com/news/opinion/editorials/la-ed-drones-policy-obama-koh-20130513,0,4160911.story On Monday, May 13, 2013 11:35:33 PM UTC+4, Erlis Vidal wrote: Let me share this tale with you guys, hope you like it as much as I do: It is said that Socrates met a worker who asked: what are you doing good man? Don't you see I'm cutting a stone to earn my salary and so I can eat the worker replied. He moved on and later found another worker questioning the same way as the previous one, he replied I'm building a wall, continued Socrates finding their way to a third worker, also questioning, the answer was I'm building a beautiful palace On Mon, May 13, 2013 at 2:17 PM, Timothy Baldridge tbald...@gmail.comwrote: I doubt I'm unique in this area, but for me, programming is a drug. I have to code, or the ideas and thoughts build up in my mind. For me, actually writing down and implementing these is a stress relief. Just ask my parents when I was growing up, or my wife today. Keep me in a room without a computer for a week, and I'll start writing code on paper just to get the thoughts down. So I guess you could say I'm an addict. Timothy Baldridge On Mon, May 13, 2013 at 12:09 PM, Ulises ulises@gmail.com wrote: Code that matters is code that's used by other people. For me personally the ability to share my code with others is the thing that makes programming worth doing in the first place. This is a rather important point. One of the most asked questions (random made up fact) by newcomers to a language is what can I code? what open source programs can I help?. All with the aims of getting better acquainted with the language itself and, hopefully, helping others. I normally direct people to Advice to Aimless, Excited Programmers (http://prog21.dadgum.com/80.html). For those who'd rather read
Re: More idiomatic way to use map like this?
Having failed many attempts, I asked Feng Shen and he kindly told me how: copy some formatted text off a browser and simply paste it on this editor box. So I made a gist and instead of putting this link https://gist.github.com/blancas/5507033 I just pasted the text. On Friday, May 3, 2013 11:32:55 AM UTC-7, Alan Thompson wrote: Hey Armando - How did you get the nice syntax highlighting into your post??? Enquiring minds wanna know. Alan On Fri, May 3, 2013 at 7:41 AM, Jim - FooBar(); jimpi...@gmail.comjavascript: wrote: I Just realised you've many responses and that you've already solved your problem...sorry for the noise people. Jim On 03/05/13 15:38, Jim - FooBar(); wrote: oops there is a typo! line 6 should be: (conj res (doto c (.setAppliedBalance (max 0 (- due (.getBalance c)) On 03/05/13 15:22, Jim - FooBar(); wrote: something like this perhaps? (loop [[c more]] cards res [] due 100] (if-not c res (recur more (conj res (doto c (.setAppliedBalance (max 0 (- due ) (- c .getBalance (- due ) Jim ps: haven't got a clue what objects you're working with so I'm purposefully using setters which is close to what you showed in your Ruby example On 03/05/13 14:28, Jim - FooBar(); wrote: On 02/05/13 22:21, Steven Degutis wrote: Given pseudo-code (Ruby-ish): due = 100 cards = cards.map do |card| card.applied_balance = max(0, due - card.balance) due -= card.applied_balance Notice how due changes at each turn, and each successive item in cards sees the change. What's an idiomatic way to do this in Clojure without using refs? -Steven Not a Ruby expert here, but I think 'reduce' is your friend :) loop/recur is also an option ... the problem is not really how to loop, but how to replace all this mutation...I'm saying this because you specifically asked not to use any reference types. Jim -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: 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+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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: [OT] Re: More idiomatic way to use map like this?
On Friday, May 3, 2013 1:15:24 PM UTC-7, Robert Pitts wrote: Armando was a good citizen and sent along a plain-text version as well – https://groups.google.com/group/clojure/msg/6aae8287bc55d436?dmode=sourceoutput=gplainnoredirect That must have been Google Groups doing the right thing... nice feature. -- -- 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: More idiomatic way to use map like this?
This isn't idiomatic but can be useful for modeling mutable computations in pure functions: (use '[blancas.morph core monads]) (def cards [{:balance 30} {:balance 25}]) (def due 100) (run-state (mapm #(monad [due get-state app (state (min due (:balance %))) _ (put-state (- due app))] (state (assoc % :applied-balance app))) cards) due) mapm is a map for monads; (state x) boxes cards; the state is the total due. ;Pair([{:balance 30, :applied-balance 30} {:balance 25, :applied-balance 25}],45) On Thursday, May 2, 2013 8:34:41 PM UTC-7, Steven Degutis wrote: Epic win. Thanks guys, this is a really neat technique! I was thinking the solution must be something like reduce but with two values, the due amount and the cards, but I couldn't figure out how to get the cards to map. Turns out conj was the missing piece of the puzzle. Thanks again! On Thu, May 2, 2013 at 5:34 PM, Gavin Grover gavingro...@gmail.com javascript: wrote: Is this code applying an amount due against a customer's list of credit cards? If so, there seems to be a bug. The third line should be: card.appliedBalance = min(due, card.balance) and the Clojure code I'd write is: (defrecord Card [balance applied-balance]) (defn apply-due-to-cards [[due new-cards] card] (let [applied-bal (min due (:balance card))] [(- due applied-bal) (conj new-cards (-Card (:balance card) applied-bal))])) (assert (= (reduce apply-due-to-cards [100 []] [(-Card 10 0) (-Card 30 0) (-Card 150 0)]) [0 [(-Card 10 10) (-Card 30 30) (-Card 150 60)]])) Also four lines long like the Ruby example, but it's easier to debug when there's a bug just by changing `reduce` to `reductions`. It's also threadsafe, and can be parallelized for large datasets by using the Clojure 5 Reducers library. On Friday, May 3, 2013 5:21:46 AM UTC+8, Steven Degutis wrote: Given pseudo-code (Ruby-ish): due = 100 cards = cards.map do |card| card.applied_balance = max(0, due - card.balance) due -= card.applied_balance Notice how due changes at each turn, and each successive item in cards sees the change. What's an idiomatic way to do this in Clojure without using refs? -Steven -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: 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+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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] Grojure, a Java/C# syntax atop Clojure using Kern
Nice work, Gavin. Grojure is a good example why Clojure is an excellent UNCOL for the JVM, so some of us will depend less on the ASM lib. Your parser illustrates how to use grammar actions for writing a very compact one-pass translator; pretty cool. On Sunday, April 28, 2013 9:41:00 PM UTC-7, Gavin Grover wrote: Grojure is a Java/C#/Groovy-like syntax atop Clojure using the Kern parser combinator library. It's also of interest as an example grammar for those using Kern to build their own grammars. Available from https://github.com/gavingroovygrover/grojure Gavin Groovy Grover -- -- 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] Grojure, a Java/C# syntax atop Clojure using Kern
Thanks; glad to know the lib's working well. It'll be interesting to see how Clojure semantics like immutability, closures, and programming with values start to take hold in more languages and tools. On Monday, April 29, 2013 3:57:04 PM UTC-7, Gavin Grover wrote: Armando, I intend to keep Grojure as single-pass, unlike what you did with Eisen, so people can easily see a matchup between the Kern combinators and the Clojure macros when looking at the source. I still need to reduce the (at times) exponential backtracking a lot so Grojure will become a more performant showcase for Kern over time. I haven't found any bugs in Kern so congratulations on that one. On Tuesday, April 30, 2013 1:42:06 AM UTC+8, Armando Blancas wrote: Nice work, Gavin. Grojure is a good example why Clojure is an excellent UNCOL for the JVM, so some of us will depend less on the ASM lib. Your parser illustrates how to use grammar actions for writing a very compact one-pass translator; pretty cool. On Sunday, April 28, 2013 9:41:00 PM UTC-7, Gavin Grover wrote: Grojure is a Java/C#/Groovy-like syntax atop Clojure using the Kern parser combinator library. It's also of interest as an example grammar for those using Kern to build their own grammars. Available from https://github.com/gavingroovygrover/grojure Gavin Groovy Grover -- -- 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: Kern 0.7.0 text parsing lib has fixes, better performance
On Tuesday, April 16, 2013 4:06:51 AM UTC-7, Luca Antiga wrote: Great, I just updated clj-toml to 0.7.0 and all tests pass. Thanks Armando Very cool, Luca. I'll be looking for other ways to boost performance while keeping the purely functional design. -- -- 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.
ANN: Morph 0.3.0, monads+functors lib gets perf boost
In this release the lib gets rid of reflective calls by adding type hints. https://github.com/blancas/morph I don't have any benchmarks, but in Ben's tree-numbering Morph's timing goes from ~13,700 msecs down to ~350. https://github.com/bwo/monads/wiki/Tree-numbering-benchmark Morph tries hard to demystify the use of monads (though writing new ones may be a bit tricker). The same with functors: types that map regular functions over their fields. Morph extends Clojure types as functors; want to map over a collection and keep the type? Use Morp's fmap instead of map. Extending your own types as functors is pretty easy. Documentation: https://github.com/blancas/morph/wiki http://blancas.github.io/morph/ For bug reports, feedback, or feature requests: https://github.com/blancas/morph/issues?state=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 --- 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.
ANN: Kern 0.7.0 text parsing lib has fixes, better performance
This is a much needed clean up and perf boost release. https://github.com/blancas/kern Function (parse-file) won't choke with big files, while new parsers (parse-data) and (parse-data-file) work much faster by relaxing their house-keeping for input that's expected to be alright (e.g., serialized data). Parser (search) will match a pattern anywhere in the input, not just at the start. The new lexer configuration for a leading sign in numbers helps in cases where the lexical sign interferes with the grammar for expressions. The Wiki now includes a chapter in lexer config: https://github.com/blancas/kern/wiki/How-to-Customize-the-Lexer Documentation and samples: https://github.com/blancas/kern/wiki http://blancas.github.io/kern/ For bug reports, feedback, and feature requests: https://github.com/blancas/kern/issues?state=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 --- 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: Kern 0.7.0 text parsing lib has fixes, better performance
You're very welcome. Glad to know the lib is useful. On Monday, April 15, 2013 10:15:30 AM UTC-7, Omer Iqbal wrote: Thanks Armando! I've been using kern for a number of projects and I'm really grateful for the awesome documentation :) On Tue, Apr 16, 2013 at 12:38 AM, Armando Blancas abm2...@gmail.comjavascript: wrote: This is a much needed clean up and perf boost release. https://github.com/blancas/kern Function (parse-file) won't choke with big files, while new parsers (parse-data) and (parse-data-file) work much faster by relaxing their house-keeping for input that's expected to be alright (e.g., serialized data). Parser (search) will match a pattern anywhere in the input, not just at the start. The new lexer configuration for a leading sign in numbers helps in cases where the lexical sign interferes with the grammar for expressions. The Wiki now includes a chapter in lexer config: https://github.com/blancas/kern/wiki/How-to-Customize-the-Lexer Documentation and samples: https://github.com/blancas/kern/wiki http://blancas.github.io/kern/ For bug reports, feedback, and feature requests: https://github.com/blancas/kern/issues?state=open -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: 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+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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: Monads usage
Last week I released a project with a monadic translator that needed to: - work on sequences of expressions, arbitrarily nested - generate Clojure code or stop and report the first error - maintain a symbol table with easy access but not global state The relevant code is here: https://github.com/blancas/eisen/blob/master/src/main/clojure/blancas/eisen/trans.clj The code uses a StateT monad transformer and Either monad wrapped in five API functions: -left, -right, get-se, modify-se, run-se. Functions report errors with (-left); function (-right) wraps good values. The macro (monad) corresponds to Haskell's do; it chains monadic values or short-circuits and propagates errors. (defn trans-binop Translates the application of a binary operator. [ast] (monad [x (trans-expr (:left ast)) y (trans-expr (:right ast))] (let [f (- ast :op :value str symbol)] (-right `(~f ~x ~y) The symbol table is available through get-se and modify-se. A typical use case is to enter declared names, translate the expressions, then remove the names from the symbol table. (defn trans-let Translates a let expression. [{:keys [decls exprs]}] (let [env (map (comp symbol :name) decls)] (monad [_ (modify-se into env) decls (trans-bindings decls) exprs (trans-exprs exprs) _ (modify-se difference env)] (-right `(let [~@(apply concat decls)] ~@exprs) To translate expressions in a sequence it uses the generic function (seqm); function (run-se) evaluates the resulting sequenced monads using an initial state predefs. The result from (run-se) feeds (either) which evaluates to the first form on -left and to the second on -right. (let [job (monad [v (seqm (map eval-ast coll))] (-right v))] (either [res (run-se job predefs)] {:ok false :error res} {:ok true :decls (map first res) :value (- res last second)}))) On Monday, April 8, 2013 7:56:35 AM UTC-7, Carlos Galdino wrote: Hi, I've been reading about monads for the past couple of weeks and I think I got the idea, but I still don't know when to use it since I don't have enough experience with functional programming. So, I'd like to ask you guys if you can point me to some examples of Monads usage in the wild. Because I've seen a lot of simple examples but not a real one, used in a library, etc. Does anyone know a good example of real world usage? Thanks in advance. -- -- 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.
ANN: Eisen, a language and API for programmable apps
The goal of this project is to help you write programs that users can change and extend. Besides its practical advantages, there's something really powerful about modifying a deployed program, especially when it's done interactively. As to what language users should write in, I've come to believe it isn't lisp and thus I settled on a syntax close to SML. My reasons are anecdotal and also influenced by Wadler's experience teaching lisp at Oxford [*]. As he writes, is not that lisp can't be explained, but that tricky things tend to compound in the middle of the user trying to do something. Considering that the star of the show is whatever the user gets from a program, I think the language should be effective but low key. Furthermore, the basic Eisen language can itself be extended or built almost from the ground up, so there's room for experimenting and trying things out. The API has functions for hooking up user code, configuring and extending the language, reusing parsing and translation functions. There's also a primitive repl. The project: https://github.com/blancas/eisen Documentation: https://github.com/blancas/eisen/wiki Codox API: http://blancas.github.com/eisen/ For feedback, feature requests and bug reports: https://github.com/blancas/eisen/issues [*] http://www.cs.kent.ac.uk/people/staff/dat/miranda/wadler87.pdf -- -- 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: Attempt at rethrow macro
Define rethrow as a function; Alf's probably right. Also, change to: ~message. user= (defn rethrow [ex-class] `(catch ~ex-class x# (throw x#))) #'user/rethrow user= user= (defmacro handle-ex [message body] `(try ~@body ~(rethrow IllegalArgumentException) (catch Exception x# (throw (IllegalArgumentException. ~message) #'user/handle-ex user= user= (handle-ex no (throw (IllegalArgumentException. yes))) IllegalArgumentException yes user/eval9 (NO_SOURCE_FILE:7) On Monday, April 1, 2013 8:21:30 AM UTC-7, Bill Robertson wrote: I was all excited when I was able to consolidate a lot of try/catch logic behind a macro earlier this morning. All was good. I felt like I could do a better job of communicating my intentions in the code though with a rethrow construct rather than writing (catch FooException #f (throw #f)) I would have liked to have been able to simply write (rethrow FooException) This failed. Poking around the docs a bit, I see that try/catch is a special form. Which makes sense. user= (defmacro rethrow [ex-class] `(catch ~ex-class x# (throw x#))) #'user/rethrow user= (defmacro handle-ex [message body] `(try ~@body (rethrow IllegalArgumentException) (catch Exception x# (throw (IllegalArgumentException. message) #'user/handle-ex user= (handle-ex no (throw (IllegalArgumentException. yes))) CompilerException java.lang.RuntimeException: Unable to resolve symbol: catch in this context, compiling:(NO_SOURCE_PATH:1:1) It was a longshot, but I tried to qualify catch. That fails too, because it's not really there... user= (defmacro rethrow [ex-class] `(clojure.core/catch ~ex-class x# (throw x#))) #'user/rethrow user= (defmacro handle-ex [message body] `(try ~@body (rethrow IllegalArgumentException) (catch Exception x# (throw (IllegalArgumentException. message) #'user/handle-ex user= (handle-ex no (throw (IllegalArgumentException. yes))) CompilerException java.lang.RuntimeException: No such var: clojure.core/catch, compiling:(NO_SOURCE_PATH:1:1) Is this possible to do within the normal bounds of the language? 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 --- 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: doing a Google search from Clojure?
Rich, you may want to check out clojure-http-client. https://github.com/technomancy/clojure-http-client (require '[clj-http.client :as client]) (spit result.html (client/get http://www.google.com/search?q=clojure;)) On Friday, March 22, 2013 12:09:07 AM UTC-7, Rich Morin wrote: I've been successfully using slurp and laser to harvest and pull apart some web pages. However, I can't figure out how to use Google Search from my code. My first thought was to use the Google Search API, but after a lot of frustration in trying to get and use an API key, I gave up on that. My next thought was to slurp in a page from the interactive Google Search facility, using the URL from Advanced Search: http://www.google.com/search?hl=enas_q=...; However, this gives me a 403 nastygram: IOException Server returned HTTP response code: 403 for URL: https://www.google.com/search?hl=enas_q=as_epq=... sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1436) Has anyone here, by chance, been able to do this sort of thing? -r -- http://www.cfcl.com/rdmRich Morin http://www.cfcl.com/rdm/resume r...@cfcl.com javascript: http://www.cfcl.com/rdm/weblog +1 650-873-7841 Software system design, development, and documentation -- -- 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: doing a Google search from Clojure?
Thanks, Anthony; will use that one. On Friday, March 22, 2013 11:37:44 AM UTC-7, Anthony Grimes wrote: clojure-http-client is more or less unmaintained. https://github.com/dakrone/clj-http is the canonical http client these days. Lazybot has a plugin for doing this with the google ajax api, if that's helpful. No API key needed. https://github.com/flatland/lazybot/blob/develop/src/lazybot/plugins/google.clj On Friday, March 22, 2013 10:54:37 AM UTC-7, Armando Blancas wrote: Rich, you may want to check out clojure-http-client. https://github.com/technomancy/clojure-http-client (require '[clj-http.client :as client]) (spit result.html (client/get http://www.google.com/search?q=clojure )) On Friday, March 22, 2013 12:09:07 AM UTC-7, Rich Morin wrote: I've been successfully using slurp and laser to harvest and pull apart some web pages. However, I can't figure out how to use Google Search from my code. My first thought was to use the Google Search API, but after a lot of frustration in trying to get and use an API key, I gave up on that. My next thought was to slurp in a page from the interactive Google Search facility, using the URL from Advanced Search: http://www.google.com/search?hl=enas_q=...; However, this gives me a 403 nastygram: IOException Server returned HTTP response code: 403 for URL: https://www.google.com/search?hl=enas_q=as_epq=... sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1436) Has anyone here, by chance, been able to do this sort of thing? -r -- http://www.cfcl.com/rdmRich Morin http://www.cfcl.com/rdm/resume r...@cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Software system design, development, and documentation -- -- 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.
ANN: Morph 0.2.0, state+error-handling with pure functions
Release 0.2.0 of the Morph library comes with a couple of fixes and some enhancements: https://github.com/blancas/morph Safe error-handling with non-global, shared data is now even easier: https://github.com/blancas/morph/wiki/Simpler-State-with-Error-Handling Documentation and samples: https://github.com/blancas/morph/wiki The docs include a Codox API Reference and a change log. For feedback, bug reports, etc.: https://github.com/blancas/morph/issues?page=1state=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 --- 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.
ANN: Kern 0.6.1, a text-parsing library
I've pushed to Clojars the release 0.6.1 of Kern, a text-parsing library, with some fixes and enhancements. https://github.com/blancas/kern There's updated Codox API docs and a change log. Documentation and samples: https://github.com/blancas/kern/wiki For feedback, bug reports, etc.: https://github.com/blancas/kern/issues?state=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 --- 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] clj-toml 0.2.0
Glad to see Kern being useful. Your parser uses those combinators quite effectively. On Monday, February 25, 2013 1:26:26 AM UTC-8, Luca Antiga wrote: Quick announcement: clj-toml 0.2.0 is available on Clojarshttps://clojars.org/clj-toml . clj-toml https://github.com/lantiga/clj-toml is a TOMLhttps://github.com/mojombo/tomlparser for Clojure. It was written on top of the Kern https://github.com/blancas/kern library by Armando Blancas (kudos). TOML is a minimalistic, human-readable format that maps to a hash (like INI, but more evolved). Cheers, Luca -- -- 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: Easier imperative-style programming
Here's an example of using a state monad for updating a position. The state goes into a simple map and there's a function to add coordinates. (def init {:position [100 100] :st :st0 :keys-held #{:left}}) (defn v+ [v1 v2] (vec (map + v1 v2))) The state monad can compute a value and maintain some arbitrary state. In this case, the statements produce side-effects but nothing is actually computed, which is fine. You'd want to model each statement to encapsulate some action and return a State instance. For simplicity, the function move mixes the conditional statement with the then-branch, but that can be easily separated later: ;; shameless plug (use 'blancas.morph.core 'blancas.morph.monads) (defn move [key v] (monad [held (gets :keys-held)] (if (held key) (modify-state #(update-in % [:position] v+ v)) (state :empty-stmt This function takes the key that was pressed. If it's one held in storage, the state will be modified pretty much the way it was before; otherwise the statement evaluates into a state instance whose value is the empty statement. Each of the following elements models a conditional statement: if x do this: (def stmts [(move :left [-10 0]) (move :right [ 10 0]) (move :up[ 0 -10]) (move :down [ 0 10])]) This runs the sequence of monads and returns the value of the resulting state (not the value since it's not computing anything: (exec-state (seqm stmts) init) ;; {:position [90 100], :st :st0, :keys-held #{:left}} Here we do the same but then change the key and re-evaluate the statements. The combinators seqm and are similar; seqm takes a collection. (exec-state ( (seqm stmts) (modify-state assoc :keys-held #{:down}) (seqm stmts)) init) ;; {:position [90 110], :st :st0, :keys-held #{:down}} This shows a computation; say you want to compute: [50 50] + [12 -5] For this you'd write a new version of v+ that takes monadic args (boxed in a State). As above, the (monad) macro binds the results of monads to the variables, as in a let. Then wraps the result in a state: (defn v+ [v1 v2] (monad [x v1 y v2] (state (vec (map + x y) (This function could take simple vectors, but in a real use case you'd be taking expressions, not just values.) Now you can get the result like so: (eval-state (v+ (state [50 50]) (state [12 -5])) init) ;; [62 45] If you want both the computed value and the finate state you can get them both in a Pair: (run-state (v+ (state [50 50]) (state [12 -5])) init) ;; Pair([62 45],{:position [100 100], :st :st0, :keys-held #{:left}}) On Monday, February 11, 2013 12:10:24 PM UTC-8, JvJ wrote: I'm writing a simple game engine in Clojure, and each game object supplies its own unique update function, which takes the original object (a map of properties) and returns an updated version. However, writing the updates is somewhat cumbersome because each line of code has to return either the original or updated object. I'd like to see if I can clean up this code, possibly by using monads (which I don't understand very well). Does anyone have any advice? Thanks (Code examples below) The pseudocode for what i want to do looks something like this: if left key is held g.position += [-10 0] if right key is held g.position += [10 0] if up key is held g.position += [0 -10] if down key is held g.position += [0 10] if q is pressed fire event {:type :dialogue, :text Hello} if space is pressed g.switchstate(:s2) But the code I ended up writing is this mess: (fn [g] (- g (#(if (@*keys-held* :left) (update-in % [:position] v+ [-10 0]) %)) (#(if (@*keys-held* :right) (update-in % [:position] v+ [10 0]) %)) (#(if (@*keys-held* :up) (update-in % [:position] v+ [0 -10]) %)) (#(if (@*keys-held* :down) (update-in % [:position] v+ [0 10]) %)) (#(if (@*keys-pressed* \q) (do (fire-event {:type :dialogue :text Hello!}) %) %)) (#(if (@*keys-pressed* :space) (do (comment (println spaced!)) (switch-state % :s2)) % -- -- 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
Re: pr-str captures stdout- Is this intentional or a bug?
There's nothing wrong with pr-str. Debug output should go to stderr. user= (def k (pr-str (for [x (range 5)] (do (.println *err* x) (.println *err* nothing) x 0 nothing 1 nothing 2 nothing 3 nothing 4 nothing #'user/k user= k (0 1 2 3 4) On Saturday, February 9, 2013 2:41:23 PM UTC-8, AtKaaZ wrote: these examples to illustrate what you are saying: = (= (debug 1\r\n2 nil 3) (pr-str (lazy-seq (list 2 (println debug 1) 3 true = (= (1\r\n) (pr-str (lazy-seq (println 1 true On Sat, Feb 9, 2013 at 10:57 PM, Conrad drc...@gmail.com javascript:wrote: For those reading this, the issue is NOT that output in the REPL looks funny. The problem is that if, for instance, you put debug code into a chunk of code that makes use of pr-str your debug code is actually WRITTEN TO THE STRING. This is because pr-str works by using with-out-str. This seems clumsy and is undocumented IMHO and I am wondering if other people feel the same. On Saturday, February 9, 2013 12:30:20 PM UTC-6, Conrad wrote: I tested this in the latest 1.5.0-RC6: = (def k (pr-str (for [x (range 5)] (do (pr x) x #'user/k = k (012340 1 2 3 4) This seems wrong to me... I can see what would be needed to fix it in clojure/core.clj, but it would require creating several additional private functions. Does anyone know if this behavior is intentional? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: 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+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate 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 --- 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] Morph v0.1.0 Monads friends: pure functions, less boilerplate
Yeap, I've had looked at Jim Duey's projects and had read his articles at his website; it's good content. On Thursday, February 7, 2013 1:48:12 AM UTC-8, Marek Srank wrote: btw, have you seen https://github.com/jduey/protocol-monads ? Marek On Thursday, February 7, 2013 1:06:39 AM UTC+1, Armando Blancas wrote: Morph is a new implementation of monads based on protocols. It's intended to provide the common patterns of error-handling, short-circuit sequencing, and modeling of stateful computations in pure functions. I've tried to make this library idiomatic while keeping it close to its Haskell roots. This is a utility library that, I hope, can make your coding easier. No particular knowledge is assumed or required. The docs name things but rely on getting an intuitive feeling of what's going on. Protocols are relevant only if you want to write your own plumbing, which shouldn't be difficult; otherwise it's all ready to use. Project: https://github.com/blancas/morph User Guide: https://github.com/blancas/morph/wiki Codox API: http://blancas.github.com/morph Please use the project wiki for feedback, bug reports, or feature requests. -- -- 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] Kern 0.5.0 -- A text-parsing library
Ragnar, thanks for your kind words; I'm glad you're finding kern fun and useful. The lexer module has parsers that take care of whitespace, and conveniences like parens, braces, comma-sep (and others) that shorten things. You might start with the namespace blancas.kern.lexer.basic and use similar functions as core (but without the star) like sym and token that handle whitespace (these functions parse and then consume any whitespace until the next char). Using some of the functions from that namespace, lines 93-102 may come down to: (def ruby-attributes (braces (comma-sep ruby-attr-pair))) Similarly, lines 64-69 could be: (def html-attributes (parens (many html-attr-pair))) just surround the values with (lexeme) to ignore whitespace: the defs for html-name, html-value, ruby-name, etc: (def html-name (lexeme (| ...))) That would reduce the checks for spaces in your (bind) sequences. Just experiment with these ideas and see if it gets simpler. Feel free to ask me any more questions. On Thursday, February 7, 2013 2:35:02 AM UTC-8, Ragnar Dahlén wrote: Hi Armando, Thank you for your great work with this library! I don't have much previous experience with parser combinators, but with your implementation, and the wonderful documentation, I've had a lot of fun playing and learning. I've been hacking on a small project for implementing a subset of HAML for Clojure, with the goal of using HAML instead of HTML for enlive templates. It is very early days, but if you're interested, I'd be very happy for any feedback on the parser, which uses kern. I've probably done a lot of stupid stuff. Project: https://github.com/ragnard/hamelito Parser: https://github.com/ragnard/hamelito/blob/master/src/hamelito/parsing.clj Best regards, Ragnar On Monday, 21 January 2013 18:27:07 UTC, Armando Blancas wrote: Kern is a text-parsing library based on Parsec, the Haskell monadic combinators library. It is useful for parsing all kinds of text: data, program input, configuration files, DSLs, or a full-blown programming language. My main goal is, like the Self folks, the power of simplicity. In the ideal case the grammar is the implementation, but I'm OK with something close. Next comes performance, which appears to be fine with hot code but not great otherwise. Let me know and will see what I can do. https://github.com/blancas/kern The wiki has a user's guide, tutorials, and links to several samples; will be adding some more topics there. There's also a Codox API zip file available for download. Feedback, suggestions, requests, bug reports are all very welcome; please use the project wiki. -- -- 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.
[ANN] Morph v0.1.0 Monads friends: pure functions, less boilerplate
Morph is a new implementation of monads based on protocols. It's intended to provide the common patterns of error-handling, short-circuit sequencing, and modeling of stateful computations in pure functions. I've tried to make this library idiomatic while keeping it close to its Haskell roots. This is a utility library that, I hope, can make your coding easier. No particular knowledge is assumed or required. The docs name things but rely on getting an intuitive feeling of what's going on. Protocols are relevant only if you want to write your own plumbing, which shouldn't be difficult; otherwise it's all ready to use. Project: https://github.com/blancas/morph User Guide: https://github.com/blancas/morph/wiki Codox API: http://blancas.github.com/morph Please use the project wiki for feedback, bug reports, or feature requests. -- -- 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] Morph v0.1.0 Monads friends: pure functions, less boilerplate
Good catch with currying non vars; I'll try to work something out. Also, should come up with a general defcurry macro; I'm not happy with that. Things like foldM may just not be possible, but I'll keep track of these issues so maybe I can give you a good answer for the things you've brought up. Just having to deal with deftype'd monoids is a bit of a pain, so I welcome ideas to simplify them. On Wednesday, February 6, 2013 4:43:33 PM UTC-8, Ben wrote: this is great, just one nit to pick about currying (because it's something that's bitten me in the past in other contexts): in the wiki you say For a predefined function with a fixed number of arguments, only the function name must be supplied., but this is only sort of true---the issue isn't whether the function is predefined or not, the issue is whether the argument is a symbol that resolves to a var. This, for instance, doesn't work: (let [t take] (((curry t) 3) '(1 2 3 4))) Even though take is a predefined function. And this picks up the wrong metadata (this example is factitious on its face, but it could happen in practice): blancas.morph.core (defn three-params [a b c] a) #'blancas.morph.core/three-params blancas.morph.core (let [three-params take] (((curry three-params) 3) '(1 2 3 4))) #core$eval2780$G__2784__2785$G__2786__2787$fn__2788 blancas.morph.core$eval2780 $G__2784__2785$G__2786__2787$fn__2788@65c66812 blancas.morph.core because resolve goes directly to var bindings, overlooking other niceties of lexical scope. Unrelatedly: - I couldn't figure out how to write something like foldM, because I couldn't figure out how to call return on the seed value when the list is empty. ISTR (when you announced your parsing library) that there isn't a way to do that kind of thing at all? - I'm curious about the Monoid protocol---I have one in babbage, and it has two more methods than yours, mempty? and value (instead of monoid-specific accessors). Why not put the accessors in the protocol? On Wed, Feb 6, 2013 at 4:06 PM, Armando Blancas abm2...@gmail.comjavascript: wrote: Morph is a new implementation of monads based on protocols. It's intended to provide the common patterns of error-handling, short-circuit sequencing, and modeling of stateful computations in pure functions. I've tried to make this library idiomatic while keeping it close to its Haskell roots. This is a utility library that, I hope, can make your coding easier. No particular knowledge is assumed or required. The docs name things but rely on getting an intuitive feeling of what's going on. Protocols are relevant only if you want to write your own plumbing, which shouldn't be difficult; otherwise it's all ready to use. Project: https://github.com/blancas/morph User Guide: https://github.com/blancas/morph/wiki Codox API: http://blancas.github.com/morph Please use the project wiki for feedback, bug reports, or feature requests. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: 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+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure. [Larousse, Drink entry] -- -- 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: Clojure - Python Style suggestion
What do you think? I think, go right ahead and give it to them. Worst that could happen is you gain insights into language design. I'd be interested in your users' comments; what worked, what didn't. If you really believe in that idea, don't give it up before you learn something from 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 --- 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.
[ANN] Kern 0.5.0 -- A text-parsing library
Kern is a text-parsing library based on Parsec, the Haskell monadic combinators library. It is useful for parsing all kinds of text: data, program input, configuration files, DSLs, or a full-blown programming language. My main goal is, like the Self folks, the power of simplicity. In the ideal case the grammar is the implementation, but I'm OK with something close. Next comes performance, which appears to be fine with hot code but not great otherwise. Let me know and will see what I can do. https://github.com/blancas/kern The wiki has a user's guide, tutorials, and links to several samples; will be adding some more topics there. There's also a Codox API zip file available for download. Feedback, suggestions, requests, bug reports are all very welcome; please use the project wiki. -- 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] Kern 0.5.0 -- A text-parsing library
I've actually taken a peek at just about every parsing lib that has been mentioned in this board. I've learned plenty by reading other people's code, and also looking at how they approached the subject. On Monday, January 21, 2013 10:32:55 AM UTC-8, Ben wrote: Have you looked also at Parsatron (another parsec-derived library)? https://github.com/youngnh/parsatron I wrote some combinators for parsatron for dealing with clojure datastructures: https://github.com/bwo/macroparser On Mon, Jan 21, 2013 at 10:27 AM, Armando Blancas abm2...@gmail.comjavascript: wrote: Kern is a text-parsing library based on Parsec, the Haskell monadic combinators library. It is useful for parsing all kinds of text: data, program input, configuration files, DSLs, or a full-blown programming language. My main goal is, like the Self folks, the power of simplicity. In the ideal case the grammar is the implementation, but I'm OK with something close. Next comes performance, which appears to be fine with hot code but not great otherwise. Let me know and will see what I can do. https://github.com/blancas/kern The wiki has a user's guide, tutorials, and links to several samples; will be adding some more topics there. There's also a Codox API zip file available for download. Feedback, suggestions, requests, bug reports are all very welcome; please use the project wiki. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure. [Larousse, Drink entry] -- 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] Kern 0.5.0 -- A text-parsing library
Any plans to decouple the parsing combinators (more importantly the error messages/position tracking) from parsing text? A seqable object as in the second argument to parse is not necessarily something for which lines and columns make sense. Not yet. I've decided that first the library must get really good at parsing text. Once I have more experience writing and using this library, that'd be a good goal to have. But for now it's about text. Or to make your parser an honest monad (i.e. to implement the algo.monads interface)? I have my own project for monoids, functors and monads, based on protocols, which I think is much faster than algo.monads, yet I decided against implementing Kern with a monad transformer for performance reasons. Furthermore, though I think algo.monads it's pretty good, I don't believe it's been so widely adopted as to require Kern users to learn it and use it to structure their own programs. The fact that Kern is monadic is to be transparent to its users. -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure. [Larousse, Drink entry] -- 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] Kern 0.5.0 -- A text-parsing library
I see---also fair enough. How do you implement things like return (for monads) or mempty (for monoids) with protocols? I assume it's the perceived desirability of not having to pass in a parameter corresponding to some concrete monad/monoid/whatever to be able to get the right function for m-return or whatever. A protocol for functors does seem more straightforward to implement. I realized that most of the time I was creating an instance out of another; when I wasn't, I could just use a regular constructor, not a monadic one. Thus I came to write code like this for the Writer monad and others; notice the recurrence of return this or mempty working on this; here's where the protocol and type pay off. (I'll put this lib out before long, hoping I can explain it.) At any rate that's the best I've managed so far. https://gist.github.com/4590513 I asked for self-interested reasons; I have a macro (arguably a silly one) for writing monadic code in a style I prefer to domonad (and would also prefer to your bind macro) [1] and would like to be able to use it with arbitrary things that are monadic. That can't really happen if everyone has his own monad interface. You did a good great with that macro. It's the most flexible and clean I've seen; it really captures the do notation. Your last point is well taken, as I'll soon find myself in the same boat with other work. -- 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: methods of a protocol
(defprotocol symbolicExpr (evalx [this args])) (deftype x [a]) (let [y #(+ 1 2)] (extend-type x symbolicExpr (evalx [this args] (y (evalx (x. 0) 0) On Wednesday, December 26, 2012 6:16:13 PM UTC-8, Sunil Nandihalli wrote: Hi Everybody, It looks like the following way of definition is not allowed.. what is a good alternative way of doing this (defprotocol symbolicExpr (evalx [this args])) (let [y #(+ 1 2)] (deftype x [a] symbolicExpr (evalx [this args] (y I know I can do a (def y #(+ 1 2)) but that would unnecessarily make the variable global to the namespace. and I don't want to put it inside the method either, since it would have to re-evaluate the same var multiple times when I know it will remain constant across *evalx* method calls. what is a good way of achieving my goal without making *y *global to the namespace? Thanks, Sunil. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Running a clojure script
I'm not going out of my way to be pseudonymous, it just seems to be a feature of the group. I thought, Mark asking how to run a script? An usurper! -- 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: Confused about comp
(comp (partial apply str) (partial filter #{\a})) Or, (comp join (partial filter #{\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: Running a clojure script
Why are you using puzzler's account and what did you did to him?! On Saturday, December 15, 2012 7:28:56 PM UTC-8, puzzler wrote: Thanks. I think that used to be on the Getting Started page, but now the page is just links to info about how to get up and running with IDEs, so I had trouble finding 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: Can anyone point me to that library that supports quasiquoting without full namespace expansion?
You can do: user= `[~'foo 1] [foo 1] On Sunday, December 2, 2012 10:24:29 AM UTC-8, Conrad wrote: I remember seeing it somewhere recently but I can't find it now... As you probably know, if you quasiquote in clojure it automatically adds namespaces: `[foo ~1] [mylibrary.core/foo 1] The library I am looking for lets you write: (template [foo ~1]) [foo 1] Thanks for your 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: monads
I found these articles very valuable in understanding the original motivation for monads and their use for practical development. Imperative Functional Programming Simon Peyton Jones, Philip Wadler http://research.microsoft.com/pubs/67066/imperative.ps.z Monadic Parser Combinators Graham Hutton http://eprints.nottingham.ac.uk/237/1/monparsing.pdf On Friday, October 26, 2012 9:06:59 AM UTC-7, Brian Craft wrote: I've read about four tutorials on monads so far, but it still escapes me. In fact, I'm still not sure what problem it solves. I'm familiar with the problem of having, say, three functions like f(a) - b, g(c) - d, h(e) - f, which you'd like to chain like f(g(h(x))), but you can't because b is a different type from c and d is a different type from e. The monad tutorials all start with a problem like this, but I still can't tell if they're actually providing a solution, because it appears every monad is specific to a particular type. E.g. a sequence monad. So, great, I have something that takes a scalar and returns a sequence. That might solve g(h(x)) if f is a scalar and c is a sequence by letting me write g(s(h(x))), but it doesn't solve the whole problem, since I still have f() to worry about. So, two specific questions. First, do monads provide a generic solution, so I can apply f(g(h(x)))? Second, is it the whole point of monads to use macros so you don't see the glue functions, like s(), in my example? I mean, we can always write glue functions so we can compose functions with different input/output types without using monads. What exactly are monads adding? Oh, and one more. If I were to actually use a monad in a piece of production code, what are the chances that the next person working on the code would have the faintest idea how it worked? ;-p -- 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: Midje popularity?
Does anyone use Midje currently? I do; and expect to use more of its features. -- 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: Rouge: Ruby + Clojure
Finally came around to install a recent Ruby build and ran a little test script just to get a feel for the startup time. Looks good, though the faster the merrier. ~ $ ruby --version ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin10.8.0] ~/dev/tools/rouge $ cat test.clj (defn square [x] (* x x)) (defn fact [n] (if (= n 0) 1 (* n (fact (- n 1) (print (fact (square 3))) (print) ~/dev/tools/rouge $ time bin/rouge test.clj 362880 real 0m0.303s user 0m0.291s sys 0m0.011s ~/dev/tools/rouge $ time clj test.clj 362880 real 0m1.103s user 0m1.683s sys 0m0.127s On Friday, October 12, 2012 4:40:28 AM UTC-7, Arlen Christian Mart Cuss wrote: Hi all, I'd like to announce Rouge, which is an implementation of Clojure on Ruby. https://github.com/unnali/rouge#readme The readme above shows example of some Rouge code, most of which is currently taken from the boot file of Rouge itself. The thing is fully TDDed, so you can read the specs to see how (in)complete it is. :) I'd love it if you gave it a try, and let me know your thoughts and feedback. Even more than that, I'd love your contributions! Clojure is a beautiful language, and I'm really happy to be able to combine it with my other favourite language. Cheers, Arlen -- 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: Rouge: Ruby + Clojure
Nice work. I'm getting this error: ~/dev/tools/rouge $ bin/rouge ./bin/../lib/rouge.rb:6: undefined method `define_singleton_method' for Rouge:Module (NoMethodError) ~/dev/tools/rouge $ ruby --version In case any of this is relevant: ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin10.0] ~/dev/tools/rouge $ bundle --version Bundler version 1.2.1 ~/dev/tools/rouge $ gem --version 1.8.24 On Friday, October 12, 2012 4:40:28 AM UTC-7, Arlen Christian Mart Cuss wrote: Hi all, I'd like to announce Rouge, which is an implementation of Clojure on Ruby. https://github.com/unnali/rouge#readme The readme above shows example of some Rouge code, most of which is currently taken from the boot file of Rouge itself. The thing is fully TDDed, so you can read the specs to see how (in)complete it is. :) I'd love it if you gave it a try, and let me know your thoughts and feedback. Even more than that, I'd love your contributions! Clojure is a beautiful language, and I'm really happy to be able to combine it with my other favourite language. Cheers, Arlen -- 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: Rouge: Ruby + Clojure
I didn't realize 1.8 was such and old version; will get a recent build and give it another try. I'm interested in scripting, so the basic pieces are already there. With a short startup time this will be looking really useful. On Friday, October 12, 2012 6:05:39 PM UTC-7, Arlen Christian Mart Cuss wrote: Hi Armando, Thanks for giving it a go! On second thought, I've decided against 1.8 support. 1.8 was released initially in 2003, and is now considered deprecated. I gave it a solid go to see if the code I wrote was mostly-compatible with 1.8, but it started to turn into something of a dog's breakfast. Sorry for the hassle. — Arlen On Saturday, October 13, 2012 8:52:05 AM UTC+11, Armando Blancas wrote: Nice work. I'm getting this error: ~/dev/tools/rouge $ bin/rouge ./bin/../lib/rouge.rb:6: undefined method `define_singleton_method' for Rouge:Module (NoMethodError) ~/dev/tools/rouge $ ruby --version In case any of this is relevant: ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin10.0] ~/dev/tools/rouge $ bundle --version Bundler version 1.2.1 ~/dev/tools/rouge $ gem --version 1.8.24 On Friday, October 12, 2012 4:40:28 AM UTC-7, Arlen Christian Mart Cuss wrote: Hi all, I'd like to announce Rouge, which is an implementation of Clojure on Ruby. https://github.com/unnali/rouge#readme The readme above shows example of some Rouge code, most of which is currently taken from the boot file of Rouge itself. The thing is fully TDDed, so you can read the specs to see how (in)complete it is. :) I'd love it if you gave it a try, and let me know your thoughts and feedback. Even more than that, I'd love your contributions! Clojure is a beautiful language, and I'm really happy to be able to combine it with my other favourite language. Cheers, Arlen -- 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: Sort and Java 1.7
You must be referring to the detection of contract violations. It shouldn't be an issue; on the contrary, that seems useful info. And those who depend on legacy or third-party code can always stick to the old behavior. Area: API: Utilities Synopsis: Updated sort behavior for Arrays and Collections may throw an IllegalArgumentException Description: The sorting algorithm used by java.util.Arrays.sort and (indirectly) by java.util.Collections.sort has been replaced. The new sort implementation may throw an IllegalArgumentException if it detects a Comparable that violates the Comparable contract. The previous implementation silently ignored such a situation. If the previous behavior is desired, you can use the new system property, java.util.Arrays.useLegacyMergeSort, to restore previous mergesort behavior. Nature of Incompatibility: behavioral RFE: 6804124 http://www.oracle.com/technetwork/java/javase/compatibility-417013.html#source On Wednesday, September 12, 2012 5:54:22 AM UTC-7, Canonical.Chris wrote: Clojure's sort just trampolines down to the Java sort implementation. Between 1.6 and 1.7, the Java guys have really cracked down on the interface that people must satisfy with their comparators. LISP is much looser with its sorting requirements. I just wanted to know how people felt about these changes. -- 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: edn
I'd say on the basis of convenience, since we get to serialize and deserialize for free (o with customizations), and for most cases the author on both ends is likely to be the same person or team. For other languages, producers don't work any harder either way, and consumers are free to interpret both the schema and data as they need. sexp's only have a list notation because that's all lisp had, and even then, some people got it all for free. On Saturday, September 8, 2012 6:29:06 AM UTC-7, Steven E. Harris wrote: Michael Fogus mef...@gmail.com javascript: writes: Data formats do not exist in a vacuum. They are parsed by languages. Some may have a fine-grained distinction between lists, arrays/vectors and sets and some may not. The concern I have is for someone wanting to define a format atop EDN -- or, to put it differently, to define a schema for it. If we want to define a structure to be represented in EDN such as a list of a person's favorite colors, on what basis would the schema author choose between list and vector notation? Is there a higher-level abstract type that he specify and require that a conforming processor accept either a list or vector literal? Even if he could mandate that, say, the favorite color list is of type sequence -- listed in descending order of preference -- then an author creating the EDN to represent such a person again has to make a choice between a list and a vector, again without a clear basis for his decision. As an appeal to prior art, Rivest's S-Expressions Internet-Draft¹ used only a single list structure, though it does define three different encodings for that structure. Footnotes: ¹ http://people.csail.mit.edu/rivest/Sexp.txt -- Steven E. Harris -- 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: Expanding the Community Through Online Courses
This is a story from the trenches of your every day developer: It's a story with a ridiculous sense of entitlement. Be sure to complete your Scala lessons. -- 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: how to translate this snippet from Scheme to Clojure
That's the definition of a procedure named (A). Scheme48, for one, won't take that name, but Chicken will, even with parameters: #;1 (define ((A) n) n) #;2 ((A) 5) 5 And neither will, btw, bind a value to such a symbol in a (let). Clojure symbols can't start with an open paren, so that's just an invalid name. On Thursday, August 30, 2012 12:07:21 PM UTC-7, Andy C wrote: On Wed, Aug 29, 2012 at 10:14 PM, Baishampayan Ghose b.g...@gmail.comjavascript: wrote: Something like this? (defn A [] 1) (defn A [] (fn [] 1)) That would work but I wonder about how (define ((A)) 1) is evaluated in Scheme and why similar and easier approach is not possible in Clojure? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how to translate this snippet from Scheme to Clojure
Let's take it case by case. (define A 1) is like (def A 1) in Clojure. (define (A) 1) is like (defn A [] 1) (define (A x y) (* x y)) as you'll expect, (defn A [x y] (* x y)) (define (A) 1) is the same as (define A (lambda () 1)) ;; defines procedure A (define ((A)) 1) is the same as (define (A) (lambda () 1));; defines procedure (A) On Thursday, August 30, 2012 2:48:39 PM UTC-7, Andy C wrote: I use Rocket Scheme. The question was inspired by Structure and Interpretation http://www.youtube.com/watch?v=2Op3QLzMgSY at almost end of the video @ 1:11:11 I actually think that ((A)) is more just a symbol name since apparently you define A not a ((A))/ It is more like a recursive/nested symbol name. Very neat and simple concept I am seeking a formal explanation for. 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: how to translate this snippet from Scheme to Clojure
That statement of mine was confusing because if you type each you'll get different things. The equivalence of (define (foo) bar) === (define foo (lambda() bar)) won't hold there: you'd be defining procedure A in the second case. If the first argument is in parens, (define) will be a function definition, and the first symbol in the parens will be the prodecure name. Thus with (define ((A)) body) you're really are defining a procedure named (A). In Chicken: #;3 A #procedure (A) to my surprise, actually. I was expecting A to be not defined, and (A) to be procedure (A) but: #;4 (A) #procedure (?) go figure. My best guess is that the procedure's name is (A) and up to this point we're just typing its name, not applying proc A, whereas with ((A)) we're then calling function (A), but I don't really have more insight into the implementation, I'm just following the usage of (define). On Thursday, August 30, 2012 4:35:22 PM UTC-7, Andy C wrote: Let's focus on that for a sec: (define ((A)) 1) is the same as (define (A) (lambda () 1));; defines procedure (A) I wonder if you meant defines procedure ((A)) instead. Assuming that, if ((A)) is just a name of the procedure, then A and (A). Should not evaluate at all. Apparently above line defines procedure A actually. I know this is not that useful although very interesting in terms of how it was implemented and how that (define ...) form interprets the first argument. 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
How to avoid Attempting to call unbound fn:...
I'm playing around with a parser combinator library from the paper Monadic Parser Combinators by Hutton and Meijer [1] and came up with this: https://gist.github.com/3501273 That's just enough to show the error I'm getting when (expr) calls (factor): Clojure 1.4.0 user= (load-file expr.clj) #'user/expr user= (run expr (5)) IllegalStateException Attempting to call unbound fn: #'user/expr clojure.lang.Var$Unbound.throwArity (Var.java:43) To avoid this error, I coded a new version of the parser (factor) but in this case I use inline calls to (bind) instead of using parser (between), which makes it work: Now using (parser*) inside the definition of (expr): (def expr (bind facfor* ...) Clojure 1.4.0 user= (load-file expr.clj) #'user/expr user= (run expr (5)) 5 I thought it was a bug but this may have to do with the forward declaration of expr and when is deref'ed. After much trying I can't see why this won't work: (def factor (choice (between (match \() (match \)) expr) integer)) But this will: (def factor* (choice (bind (match \() (fn [_] (bind expr (fn [e] (bind (match \)) (fn [_] (result e))) integer)) When called from (expr), since the second case just expands the first. [1] http://eprints.nottingham.ac.uk/237/1/monparsing.pdf -- 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: How to avoid Attempting to call unbound fn:...
Nelson, that explained the case quite nicely. I appreciate it. On Tuesday, August 28, 2012 1:01:32 PM UTC-7, Nelson Morris wrote: On Tue, Aug 28, 2012 at 1:08 PM, Armando Blancas abm2...@gmail.comjavascript: wrote: I'm playing around with a parser combinator library from the paper Monadic Parser Combinators by Hutton and Meijer [1] and came up with this: https://gist.github.com/3501273 That's just enough to show the error I'm getting when (expr) calls (factor): Clojure 1.4.0 user= (load-file expr.clj) #'user/expr user= (run expr (5)) IllegalStateException Attempting to call unbound fn: #'user/expr clojure.lang.Var$Unbound.throwArity (Var.java:43) To avoid this error, I coded a new version of the parser (factor) but in this case I use inline calls to (bind) instead of using parser (between), which makes it work: Now using (parser*) inside the definition of (expr): (def expr (bind facfor* ...) Clojure 1.4.0 user= (load-file expr.clj) #'user/expr user= (run expr (5)) 5 I thought it was a bug but this may have to do with the forward declaration of expr and when is deref'ed. After much trying I can't see why this won't work: (def factor (choice (between (match \() (match \)) expr) integer)) (def factor ...) immediately gets the value of the body to assign to the var #'factor. (choice ...) is a function, so has to get the values of it's arguments before invoking. This means it gets the value of expr, which unbound and uses that. But this will: (def factor* (choice (bind (match \() (fn [_] (bind expr (fn [e] (bind (match \)) (fn [_] (result e))) integer)) This occurs similar to the above, except it hits a fn. fn is a special form defined to wait to get the value of its body until it is executed. By that time the (def expr ...) has occurred and #'expr has a bound value. A similar effect can be achieved with (def factor (choice (between (match \() (match \)) (fn [x] (expr x))) integer)) I ran into the same thing re-exploring that paper in clojure. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Parser combinators in parsatron
pL first tries anbn: many parses zero \a's; then times has to parse zero \b's; and the parser returns the concatenation of two empty lists. An empty list isn't a failure as far as the parser either is concerned, so it won't try xdny in that case. On Wednesday, August 22, 2012 5:38:56 PM UTC-7, Alexsandro Soares wrote: Hi all, I'm using the Parsatron library to build parser combinators. I have the following definition: (defparser anbn [] (let- [as (many (char \a)) bs (times (count as) (char \b))] (always (concat as bs (defparser xdny [] (let- [ds (between (char \x) (char \y) (many (char \d)))] (always (concat '(\x) ds '(\y) (defparser pL [] (either (anbn) (xdny))) When I use this definition in REPL with some examples, I have: user= (run (pL) xddy) () user= (run (pL) aabb) (\a \a \b \b) user= (run (xdny) xddy) (\x \d \d \y) I didn't understand why the first answer is not (\x \d \d \y). The second and third answers are correct for me. Can anyone help me? Regards, Alex -- 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: Buggy FP behavior with Clojure 1.3
I don't get the exception on 1.4.0: ~ $ clj Clojure 1.4.0 user= 1e309 Infinity user= On Monday, June 25, 2012 11:09:14 PM UTC-7, Sean Corfield wrote: On Mon, Jun 25, 2012 at 10:30 PM, dennis zhuang killme2...@gmail.com wrote: Added a postfix M to make the number as BigDecimal or N as a BigInteger: Yes... user= 1e309M 1E+309M The Infinity exception seems wrong but clearly using BigDecimal makes it work. -- 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: Buggy FP behavior with Clojure 1.3
Tried it on my old XP laptop and got the same result with 32 bits. On Tuesday, June 26, 2012 2:46:07 PM UTC-7, tbc++ wrote: On Tue, Jun 26, 2012 at 11:25 AM, Armando Blancas abm221...@gmail.com wrote: I don't get the exception on 1.4.0: Is this a 64bit vs 32bit issue? Timothy -- 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: Buggy FP behavior with Clojure 1.3
Just to clarify, I meant the same result as I got on OSX with 64 bits, namely Infinity. Both with 1.4.0. I'm not getting the exception. On Tuesday, June 26, 2012 6:06:13 PM UTC-7, Sean Corfield wrote: Makes sense. I got the exception on my System76 Netbook which, although technically 64-bit, is mostly running 32-bit software, including Java. On Tue, Jun 26, 2012 at 5:56 PM, Armando Blancas abm221...@gmail.com wrote: Tried it on my old XP laptop and got the same result with 32 bits. On Tuesday, June 26, 2012 2:46:07 PM UTC-7, tbc++ wrote: On Tue, Jun 26, 2012 at 11:25 AM, Armando Blancas abm221...@gmail.com wrote: I don't get the exception on 1.4.0: Is this a 64bit vs 32bit issue? Timothy -- 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.reflect annotations
That's the only way I've seen it done. Cool source box; how did you get it? On Friday, June 1, 2012 11:42:19 AM UTC-7, Jon Rose wrote: sorry, typo. My bluetooth keyboard is geeking out. I meant, is it possible to do this with out using the Jave Reflection classes through interop. On Friday, June 1, 2012 11:38:17 AM UTC-7, Jon Rose wrote: Hello, I am wondering if anyone knows how to get method annotations from a method using the clojure.reflect library. I am going of a Stuart Sierra posthttp://stackoverflow.com/questions/5821286/how-can-i-get-the-methods-of-a-java-class-from-clojureon Stack Overflow which gave me this user= (pprint (reflect hello)) {:bases #{java.io.Serializable java.lang.Comparable java.lang.Object java.lang.CharSequence}, :flags #{:public :final}, :members #{{:name valueOf, :return-type java.lang.String, :declaring-class java.lang.String, :parameter-types [boolean], :exception-types [], :flags #{:static :public}} which works great but I am also hoping to grab method comments. Is this possible with out using interop? thanks jon On Friday, June 1, 2012 11:38:17 AM UTC-7, Jon Rose wrote: Hello, I am wondering if anyone knows how to get method annotations from a method using the clojure.reflect library. I going of a Stuart Sierra posthttp://stackoverflow.com/questions/5821286/how-can-i-get-the-methods-of-a-java-class-from-clojureon Stack Overflow which game me this user= (pprint (reflect hello)) {:bases #{java.io.Serializable java.lang.Comparable java.lang.Object java.lang.CharSequence}, :flags #{:public :final}, :members #{{:name valueOf, :return-type java.lang.String, :declaring-class java.lang.String, :parameter-types [boolean], :exception-types [], :flags #{:static :public}} which works great but I am also hoping to grab method comments. Is this possible with using interop? thanks jon -- 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: Unable to pass unboxed primitive to methods taking multiple numeric primitive types.
Didn't you see that I pasted my sample from the repl? Here it goes again; pay attention: Last login: Thu May 24 07:21:38 on console ~ $ clj Clojure 1.4.0 user= (defn f [^java.awt.image.BufferedImage bi x] (.setData (.getRaster bi) 0 0 0 ^double x)) #'user/f user= ~ $ On Wednesday, May 23, 2012 10:53:15 PM UTC-7, Cedric Greevey wrote: On Wed, May 23, 2012 at 10:21 PM, Armando Blancas abm221...@gmail.com wrote: Is this any better? user= (defn f [^java.awt.image.BufferedImage bi x] (.setData (.getRaster bi) 0 0 0 ^double x)) #'user/f Didn't have a repl handy? It's quick to check that it produces: Reflection warning, NO_SOURCE_PATH:2 - call to setData can't be resolved. -- 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: Unable to pass unboxed primitive to methods taking multiple numeric primitive types.
I saw that you wrote it in the style of a repl interaction, which could have been pasted or could have been synthesized by hand. Aw! Dude, I'd never bullshit you like that. Honest. But I was sloppy and rude; sorry. -- 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: Different behavior at REPL vs compiled code
Why is there this difference in behavior between interactive and compiled code? In case you'd wonder why it works at the repl since what we type there are strings, too. The repl gets them through a call to (read) which parses strings into data structures that are Clojure code. This step is missing for gen-class classes and the contents of *command-line-args* but you could mimic it with something like: (def argv (map read-string *command-line-args*)) Though you'd want to parse numbers safely as Jim showed, for quick tests this can 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: NullPointerException
The redefinition of functions somehow is spooking the compiler. But if you're at the REPL you should be seeing these warnings (are you doing AOT compile?) WARNING: double already refers to: #'clojure.core/double in namespace: user, being replaced by: #'user/double WARNING: * already refers to: #'clojure.core/* in namespace: user, being replaced by: #'user/* Clojure 1.2 will compile regardless; later versions will produce the NPE. There's nothing wrong with your parens or your use of local functions. I just changed double to doubl and * to x and it all works fine. The stack trace isn't pretty but the warnings would've helped, so it's good to try things at the REPL. On Wednesday, May 16, 2012 3:25:20 PM UTC-7, Sargash wrote: Hi! I have a problem. With that code: ; === ; ex 1.17 multiply (defn ex1_17 [] (defn double [x] (+ x x)) (defn halve [x] (/ x 2)) (defn * [a b] (cond (= b 0) 0 (even? b) (* (double a) (halve b)) :else (+ a (* a (- b 1) (println (* 5 5)) ) (ex1_17 ) I gave that exception: Exception in thread main java.lang.NullPointerException, compiling: (D:\workprivate\ll\1\src\first.clj:3) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462) at clojure.lang.Compiler.analyze(Compiler.java:6262) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443) at clojure.lang.Compiler.analyze(Compiler.java:6262) at clojure.lang.Compiler.access$100(Compiler.java:37) at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:518) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455) at clojure.lang.Compiler.analyze(Compiler.java:6262) at clojure.lang.Compiler.analyze(Compiler.java:6223) at clojure.lang.Compiler.eval(Compiler.java:6515) at clojure.lang.Compiler.load(Compiler.java:6952) at clojure.lang.Compiler.loadFile(Compiler.java:6912) at clojure.main$load_script.invoke(main.clj:283) at clojure.main$script_opt.invoke(main.clj:343) at clojure.main$main.doInvoke(main.clj:427) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.lang.Var.invoke(Var.java:415) at clojure.lang.AFn.applyToHelper(AFn.java:161) at clojure.lang.Var.applyTo(Var.java:532) at clojure.main.main(main.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java: 120) Caused by: java.lang.NullPointerException at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4774) at clojure.lang.Compiler$DefExpr.emit(Compiler.java:418) at clojure.lang.Compiler$BodyExpr.emit(Compiler.java:5659) at clojure.lang.Compiler$FnMethod.doEmit(Compiler.java:5215) at clojure.lang.Compiler$FnMethod.emit(Compiler.java:5069) at clojure.lang.Compiler$FnExpr.emitMethods(Compiler.java:3600) at clojure.lang.Compiler$ObjExpr.compile(Compiler.java:4233) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3732) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6453) ... 24 more Could you tell me where I wrong? -- 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: NullPointerException
There's nothing wrong is a pretty strong statement. LOL. Perhaps as strong as it is definitely the wrong way to do things? Jeez. Pedantry is the wrong way to welcome newbies to this board. -- 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: NullPointerException
-- it's also just plain wrong. Those are not local functions: def always operates at top-level. Big deal. You see what I mean? Pedantry is contagious. -- 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: Unable to replace static Java method with Clojure function
This repo and plugin tags should do it. repositories repository idclojure-releases/id urlhttp://build.clojure.org/releases/url /repository /repositories ... plugin groupIdcom.theoryinpractise/groupId artifactIdclojure-maven-plugin/artifactId version1.3.4/version executions execution idcompile-clojure/id phasecompile/phase goals goalcompile/goal /goals /execution /executions /plugin ... On Wednesday, May 16, 2012 7:04:54 AM UTC-7, Matthew Boston wrote: Right, I totally understand I need AOT compilation for calling Clojure from Java. I'm asking how to set that up in maven. Thanks for your help. On Wednesday, May 16, 2012 9:58:18 AM UTC-4, Meikel Brandmeyer (kotarak) wrote: Hi, you have to use AOT compilation to generate the class with gen-class. Additionally you have to compile the clojure source before you compile the java code since otherwise the class is missing. I don't know how to do this with maven. I can tell you only for gradle. Kind regards Meikel -- 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: Unable to replace static Java method with Clojure function
Can you post the error? It's hard to tell without looking at the details. As you've may have seen, the order is this: [INFO] [resources:resources {execution: default-resources}] [INFO] [compiler:compile {execution: default-compile}] [INFO] [clojure:compile {execution: compile-clojure}] [INFO] [resources:testResources {execution: default-testResources}] [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] [surefire:test {execution: default-test}] So it's resources, compile java, compile clj, test resources, test java, test clj. So your Java tests should get any gen'ed classes. On Wednesday, May 16, 2012 8:33:21 AM UTC-7, Matthew Boston wrote: Armando, Thanks for your help. I was using `com. theoryinpractise.clojure-maven-plugin` at first but recently switched because I figured the other would help (seeing that it was built by Stuart Sierra.. I've switched back now, but stil receiving an error. When I `mvn compile` all is fine and dandy. However, `mvn test` fails to find the :gen-class I defined. Do I have my executions setup correctly? executions execution idclojure-compile/id phasecompile/phase goals goalcompile/goal /goals /execution execution idtest-clojure-compile/id phasetest/phase goals goaltestCompile/goal /goals /execution execution idtest-clojure/id phasetest/phase goals goaltest-with-junit/goal /goals /execution /executions On Wednesday, May 16, 2012 10:39:49 AM UTC-4, Armando Blancas wrote: This repo and plugin tags should do it. repositories repository idclojure-releases/id urlhttp://build.clojure.org/releases/url /repository /repositories ... plugin groupIdcom.theoryinpractise/groupId artifactIdclojure-maven-plugin/artifactId version1.3.4/version executions execution idcompile-clojure/id phasecompile/phase goals goalcompile/goal /goals /execution /executions /plugin ... On Wednesday, May 16, 2012 7:04:54 AM UTC-7, Matthew Boston wrote: Right, I totally understand I need AOT compilation for calling Clojure from Java. I'm asking how to set that up in maven. Thanks for your help. On Wednesday, May 16, 2012 9:58:18 AM UTC-4, Meikel Brandmeyer (kotarak) wrote: Hi, you have to use AOT compilation to generate the class with gen-class. Additionally you have to compile the clojure source before you compile the java code since otherwise the class is missing. I don't know how to do this with maven. I can tell you only for gradle. Kind regards Meikel -- 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: Unable to replace static Java method with Clojure function
I think the problem might also be that the failing tests are Java tests calling Java code, which is trying to call Clojure. Usually I'd have Clojure code consuming Java code; then Java and/or Clojure tests consuming compiled code, including classes from gen-class. But given the order [Java.Clojure], seems like your Java sources dependent on Clojure gen-classes will be out of order; in fact, I'd expect the compile phase to fail. You may need to break this up into two projects. Project A has Clojure and Java code consumed by Clojure, if any; and project B will have Java code that consumes stuff from A, including the gen-classes; and all tests. -- 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: Bootstrapping Clojure-in-Clojure
Much of the more recent code in Clojure is very cross platform. Stuff like reducers can simply be copied over, fixed up a bit, and it runs. I wonder how is the fork/join part carrier over for reducers. -- 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: Using 'def' does not create an array-map for small, non-empty maps
You may want to check out the info for contributors and JIRA: http://www.clojure.org/contributing http://dev.clojure.org/jira/browse/CLJ On Tuesday, May 8, 2012 2:01:57 AM UTC-7, jaju wrote: Sent the following to clojure-dev - but then it turned out to be a closed group for posting. Posting here as well: == user (class {}) clojure.lang.PersistentArrayMap user (class {1 1}) clojure.lang.PersistentArrayMap user (def m {1 1}) #'user/m user (class m) clojure.lang.PersistentHashMap The following change fixes the issue: - diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java index 0898f07..2cacd27 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -2837,7 +2837,7 @@ public static class MapExpr implements Expr{ .parse(context == C.EVAL ? context : C.EXPRESSION, ((IObj) form).meta())); else if(constant) { - IPersistentMap m = PersistentHashMap.EMPTY; + IPersistentMap m = PersistentArrayMap.EMPTY; for(int i=0;ikeyvals.length();i+= 2) - But an unwanted side-effect is that some tests (which wrongly depend on the order of elements in a map) fail, since PersistentArrayMap grows by adding new elements to the beginning of the internal array store. 1] test_pretty.clj#print-length-tests 2] sequences.clj#test-flatten-present Thoughts/comments? I'd like to fix and send a pull request! Thanks, jaju -- 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: why can i not shut-down my pc from Java?
Can someone please verify that it works on windows as well??? It works on XP. -- 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: Arithmethic Evaluation
Though I'm opposed to posting solutions to school assignments --in principle-- here's this little something in the hope that it might get you interested in lisp: (defn value [e] (cond (number? e) e (= (second e) '+) (+ (value (first e)) (value (nth e 2))) (= (second e) '-) (- (value (first e)) (value (nth e 2))) (= (second e) '*) (* (value (first e)) (value (nth e 2))) (= (second e) '/) (quot (value (first e)) (value (nth e 2) (defn e [s] (value (read-string s))) Then you use (e) like so: user= (e (1 + (2 * (4 * 5 41 Function e converts the string into a list and calls function value with it. Function value accepts wither a number or a binary operation in a list and applies the corresponding operator to the operands. Since operands can themselves be operations, it calls itself recursively on the first and third elements of the list, which are the operands. On Tuesday, May 1, 2012 8:19:04 PM UTC-7, Asranz wrote: oh please if u can teach me! On 1 mayo, 21:29, Armando Blancas abm221...@gmail.com wrote: i just need to evaluate in infix a string (1 +2 (4 * 5) Check out The Little Schemer. It'll teach you the techniques for doing 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
Re: Arithmethic Evaluation
i just need to evaluate in infix a string (1 +2 (4 * 5) Check out The Little Schemer. It'll teach you the techniques for doing 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
Re: Macros and deftype – usage question
Seems like the expansion is trying to put the function's value in there, and this has already been compiled. If the function' code is expanded in-place it works. user= (defmacro bar [a] (let [b (keyword a) f `(fn [ args#] ~b)] `(deftype ~a [] clojure.lang.ILookup (valAt [this# k#] (~f this# k#)) (valAt [this# k# d#] (~f this# k# d#) #'user/bar user= (bar alex) user.alex user= (def a (alex.)) #'user/a user= (:foo a :bar) :alex On Saturday, April 28, 2012 8:43:21 AM UTC-7, Shantanu Kumar wrote: Hi, I am running into error when using macros with deftype. For example, when I use the macro `foo` it works fine: (defmacro foo [a] (let [b (keyword a)] `(do ~b))) (foo alex) = :b whereas, when I use the macro `bar`: (defmacro bar [a] (let [b (keyword a) f (fn [ args] b)] `(deftype ~a [] clojure.lang.ILookup (valAt [this# k#] (~f this# k#)) (valAt [this# k# d#] (~f this# k# d#) (bar alex) I get the following error: CompilerException java.lang.ExceptionInInitializerError, compiling: (NO_SOURCE_PATH:87) Can somebody help me understand what am I doing wrong here. 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