Re: Can a protocol method have the same name as a clojure.core function?

2013-02-07 Thread Meikel Brandmeyer (kotarak)
Hi, you can still use a defrecord. Just don't implement the protocol inline. Clojure user= (ns foo.bar (:refer-clojure :exclude [get])) nil foo.bar= (defprotocol FooBar (get [this])) FooBar foo.bar= (ns foo.baz) nil foo.baz= (alias 'fb 'foo.bar) ; this is due to working only in the repl.

Re: leiningen dependencies plugin

2013-02-06 Thread Meikel Brandmeyer (kotarak)
lein deps? Am Mittwoch, 6. Februar 2013 12:41:03 UTC+1 schrieb Maris: Is there dependencies plugin for leiningen ? I need to download all dependencies so I can copy my project to a server. ( I can't run leiningen on server ). mvn dependency:copy-dependencies -- -- You received this

AW: (into [] (take n v)) vs (subvec v 0 n)

2013-01-31 Thread Meikel Brandmeyer
Hi, how about simply doing this: (defn foo-accessor ([] foo-vector) ([n] (subvec foo-vector 0 (min n (count foo-vector) I wouldn't worry too much about subvectors. Unless you identify them as a bottleneck with the profiler. Kind regards Meikel Durch MOTOBLUR™ verbunden

Re: Best practice - (:keyword map) versus (map :keyword)

2013-01-29 Thread Meikel Brandmeyer (kotarak)
For completeness sake... Am Dienstag, 29. Januar 2013 10:31:18 UTC+1 schrieb lpetit: Rationale for b): you have an existing map, but the key may or may not be present. Note that you can also use the version which returns default value if there's no key in the map: (map key default-value)

Re: why did lein just download Clojure 1.5?

2013-01-29 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 30. Januar 2013 07:54:36 UTC+1 schrieb Alan Malloy: `lein deps :tree` will show you the tree of dependencies, and you can see which of your dependencies has a bad dependency specification overriding the one in your project.clj. Typically it turns out a dependency is saying

Re: Importing gen-class classes from one namespace into another, like Java?

2013-01-26 Thread Meikel Brandmeyer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, you have to add a (:require com.rycole.bukkit-plugin.listeners) before you import the class. And you have to replace dashes with underscores on import. Kind regards Meikel -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux)

AW: When using gradle with the clojuresque plugin I'm getting aPlugin with id 'clojure' not found. error

2013-01-25 Thread Meikel Brandmeyer
Hi, quick guess: Pull buildscript out of the subproject. Meikel Durch MOTOBLUR™ verbunden -Ursprüngliche Nachricht- Von: john john.vie...@gmail.com An: clojure@googlegroups.com Gesendet: Fr, 25 Jan 2013, 14:20:14 MEZ Betreff: When using gradle with the clojuresque plugin I'm getting

Re: Is there a better way to update a map atom?

2013-01-21 Thread Meikel Brandmeyer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 And since you can't have enough ways to go to Rome… (defn update-values [m f args] (reduce #(update-in %1 [%2] f args) m (keys m))) -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.18 (Darwin) Comment: GPGTools - http://gpgtools.org

Re: Is there a better way to update a map atom?

2013-01-21 Thread Meikel Brandmeyer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Oops. Add a apply in front of update-in. Am 21.01.13 22:23, schrieb Meikel Brandmeyer: And since you can't have enough ways to go to Rome… (defn update-values [m f args] (reduce #(update-in %1 [%2] f args) m (keys m))) -BEGIN PGP

Re: How to (easily) show the advantages of Clojure

2013-01-16 Thread Meikel Brandmeyer (kotarak)
Hi, I based a recent presentation in a local user group on the bank account example: two accounts, deposit, withdrawal, transfer. Starting with maps. Building the code. Noticing that no locks are required. Replacing maps with records w/o changes to underlying code. Easily testing pure

Re: Unit testing

2013-01-08 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 8. Januar 2013 08:50:05 UTC+1 schrieb Eric MacAdie: Is there a common unit testing framework for Clojure? I did some googling, put all the results were a couple of years old. clojure.test ships with clojure proper. And midje is also very popular. Kind regards Meikel --

Re: Unseemingly Eager Clojure Apprentice Seeking FizzBuzz Feeback

2012-12-30 Thread Meikel Brandmeyer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, Am 30.12.12 07:14, schrieb Laurent PETIT: `when` provides an implicit `do`, so I generally try to only use it when I want side-effects. (Other side-effecty forms include `do`, `doseq`, `dotimes` and `when-not`.) On the other end, using when

Re: Use repeat with a function argument

2012-12-23 Thread Meikel Brandmeyer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, Am 24.12.12 04:20, schrieb Andrew Care: Why can I use (repeat 9) and not (repeat number)? Because you call zero? on nil, which doesn't work. Instead of (zero? (some #{0} ...)) use (some zero? ...). Kind regards Meikel -BEGIN PGP

Re: abysmal multicore performance, especially on AMD processors

2012-12-21 Thread Meikel Brandmeyer
Hi, Am 22.12.12 00:37, schrieb Lee Spector: ;; this is defined elsewhere, and I want push-states to have fields for each push-type that's defined here (def push-types '(:exec :integer :float :code :boolean :string :zip :tag :auxiliary :return :environment) (defn

Re: Need ideas for carving project into namespaces

2012-12-14 Thread Meikel Brandmeyer (kotarak)
Hi, Am Freitag, 14. Dezember 2012 09:04:32 UTC+1 schrieb puzzler: Has the situation improved? (Specifically, are you speaking from experience with splitting files up in this way, or is this just a theoretical idea? If you have done this and had a good experience, what tools were you

Re: Need ideas for carving project into namespaces

2012-12-13 Thread Meikel Brandmeyer (kotarak)
Hi, playing devil's advocate: Am Freitag, 14. Dezember 2012 06:51:43 UTC+1 schrieb puzzler: It's interesting that most of the solutions presented here involve something along the lines of immigrate / potemkin / redefine (in your piplin code). With so many people reinventing the same

Re: Injecting new clojure.core functions into third-party libraries

2012-12-06 Thread Meikel Brandmeyer (kotarak)
at the issue in detail, I suspect the toplevel form compile issue. You probably need to transform this into a do with a macro. (defmacro compile-when [test body] (when (eval test) `(do ~@body))) Kind regards Meikel Brandmeyer -- You received this message because you are subscribed to the Google

Re: ANN: contrib-repl

2012-12-03 Thread Meikel Brandmeyer (kotarak)
Hi, may I suggest a different solution? Create a meta project, which just depends on all the contrib libraries and specify this as a dependency in your project. In other parts of the world this is called a BOM - a bill of material. Kind regards Meikel -- You received this message because

Re: call superclass method in classes created by Clojure?

2012-11-28 Thread Meikel Brandmeyer
Am 28.11.12 23:10, schrieb Vladimir Tsichevski: Is it possible? See exposes-methods in documentation for gen-class. http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/gen-class Kind regards Meikel -- You received this message because you are subscribed to the Google Groups

Re: Where did the idea of metadata come from?

2012-11-12 Thread Meikel Brandmeyer
Hi, Am 12.11.2012 um 22:01 schrieb JvJ: Metadata is a really useful feature, and it's been helping me a lot. It seems like a flash of genius on the part of Mr. Hickey. I'm wondering if similar concepts exist in other programming languages that inspired it, or if it's unique to Clojure.

Re: with-open and line-seq

2012-11-07 Thread Meikel Brandmeyer
Hi Dave, Am 07.11.2012 um 20:09 schrieb Dave Ray: There aren't any problems with with-open/doseq/line-seq. The issue is with with-open/line-seq. For example, it's instinctive (at least for me anyway) to want to write a function like this: (defn get-records [file-name] (with-open [r

Re: Why is a non-transient `into` faster than the built-in one?

2012-11-05 Thread Meikel Brandmeyer (kotarak)
Hi, I get the following results using criterium[1]: user= (bench (naive-into #{} (range 1e5))) Evaluation count : 900 in 60 samples of 15 calls. Execution time mean : 70,659330 ms Execution time std-deviation : 2,605840 ms Execution time lower quantile : 67,538775 ms ( 2,5%)

Re: ANN clojure-doc.org progress report for the week of Nov 4th, 2012

2012-11-05 Thread Meikel Brandmeyer (kotarak)
Am Montag, 5. November 2012 15:04:12 UTC+1 schrieb Ambrose Bonnaire-Sergeant: Dave Ray's VimClojure page is fantastic. Thank you to all involved. Indeed. The best introduction so far, IMHO*.* * * Meikel (thankful VimClojure author) -- You received this message because you are subscribed to

Re: slow repl startup because of package finding

2012-11-02 Thread Meikel Brandmeyer (kotarak)
Hi, Am Freitag, 2. November 2012 08:23:00 UTC+1 schrieb Satoru Logic: Hi, all. Every time I type `*lein repl*`, several line of log get printed out: Could not find artifact org.clojure:clojure:pom:1.+ in central ( http://repo1.maven.org/maven2) Could not find artifact

Re: slow repl startup because of package finding

2012-11-02 Thread Meikel Brandmeyer (kotarak)
Hi, Am Freitag, 2. November 2012 08:50:09 UTC+1 schrieb Satoru Logic: My ~/.lein/profiles.clj contains one line only: {:user {:plugins [[lein-minnow 0.1.4]]}} Is it the case that this plugin requiring something that can't be find? Minnow uses seesaw 1.3.0 which depends on j18n 1.0.0.

Re: Registering a Java class as a call back in a Clojure client

2012-11-02 Thread Meikel Brandmeyer (kotarak)
Hi, you have to pass an instance of INotificationHandler, not the class itself. (.registerNotificationHandler myClient 123 (MyClass.)) or with proxy (let [handler (proxy [INotificationHandler] [] (handle [notification] here))] (.registerNotificationHandler myClient 123

Re: Question about doseq

2012-10-31 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 31. Oktober 2012 01:29:11 UTC+1 schrieb Ryan T.: user= (doseq [[id item] my-hash key (:a-key item)] (println key)) [:value a value] [:value a value] nil The next step in the doseq also introduces a seq traversal. So your

Re: Question about doseq

2012-10-31 Thread Meikel Brandmeyer (kotarak)
Hi, I'm not sure what you are refering to in the provided link. If it's eg. about :warehouses, then the difference is, that :warehouses contains a vector in the example in the link. So you basically walk the warehouse vector one warehouse at a time. But here you of only a single item (the

Re: Method overloading by the arity in proxy

2012-10-30 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 30. Oktober 2012 08:14:22 UTC+1 schrieb Nikita Beloglazov: Hi. I have a java class that has 2 methods with same but different arities (one take no arguments, other takes 1 argument). I create a proxy that overrides both this methods. The problem is that if no-arg method is

Re: clojure.org requires more clicks now

2012-10-29 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 29. Oktober 2012 02:20:42 UTC+1 schrieb Vinod Kurup: On Sunday, October 28, 2012 6:16:12 PM UTC-4, raschedh wrote: ... If you do not come back, you do not want it enough. ... Then a few extra clicks on the homepage shouldn't deter you. Sorry, couldn't resist :-)

Re: ANN: codeq

2012-10-10 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 10. Oktober 2012 16:27:37 UTC+2 schrieb Rich Hickey: I released a little app today that imports Git repos into Datomic. My hope is that it can be used as the underpinnings of some interesting Clojure tooling. More info here: http://blog.datomic.com/2012/10/codeq.html

Re: nth performance (was: performance in versions = 1.4.0)

2012-10-05 Thread Meikel Brandmeyer (kotarak)
Hi, Am Freitag, 5. Oktober 2012 10:58:05 UTC+2 schrieb Karsten Schmidt: I've also seen the checks for RandomAccess and Sequential and by simply moving them to the top (after the null check) of the long if-then cascade in RT.nthFrom(), the old performance is restored. I will open a ticket

Re: interleave

2012-10-04 Thread Meikel Brandmeyer (kotarak)
Hi, you should probably add some dorun somewhere. 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

Re: Questions regarding do form

2012-09-27 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu: I am new to clojure and I have two questions about do and the way it should be used. *Question 1: Which of the following two functions is more idiomatic and why? Both functions produce the same result.* code (defn

Re: (merge) = nil

2012-08-29 Thread Meikel Brandmeyer
Hi, Am 29.08.2012 um 23:38 schrieb dmirylenka: Although, code working with maps shouldn't use conj anyway. Why? Kind regards Meikel signature.asc Description: Message signed with OpenPGP using GPGMail

Re: function parameters were working, and now I suddenly get a cast error

2012-08-28 Thread Meikel Brandmeyer (kotarak)
And service should not be a string. Am Dienstag, 28. August 2012 13:49:54 UTC+2 schrieb Fogus: The ctor call for ServerSocket should be (ServerSocket. port localhost). -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

AW: Re: Pattern of Succinctness

2012-08-12 Thread Meikel Brandmeyer
Hi, in case you really want only nils filtered out: (filter (complement nil?) coll) or (remove nil? coll) Kind regards Meikel -Ursprüngliche Nachricht- Von: Bill Caputo logos...@gmail.com An: Tamreen Khan histor...@gmail.com Cc: clojure@googlegroups.com Gesendet: So, 12 Aug 2012,

AW: Pattern of Succinctness

2012-08-12 Thread Meikel Brandmeyer
Hi, pay attention: (or (:a {:a false}) 0) (:a {:a false} 0) Same holds in case false is nil. Using these transformations can easily introduce bugs, depending on the context. Kind regards Meikel -Ursprüngliche Nachricht- Von: Takahiro Hozumi fat...@googlemail.com An:

Re: Is this expected of seesaw ?

2012-08-09 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 9. August 2012 14:10:55 UTC+2 schrieb Jim foo.bar: 1. First of all, my lein repl hangs each time I reload a namespace that uses seesaw.core. Not when I first load it (load-file blah...blah), but when I reload it after some changes...this is really a problem

Re: Is this expected of seesaw ?

2012-08-09 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 9. August 2012 14:43:57 UTC+2 schrieb Jim foo.bar: are you 'using' or 'requiring' seesaw.core in your projects? I usually do (require '[seesaw.core :as swing]). the same thing happens (repl hangs) when i cose my frame and try to open up a new one! this is weird yes?

Re: core.cache 0.6.2 is not available from Central

2012-08-08 Thread Meikel Brandmeyer (kotarak)
Hi, why recommending a specific version at all? Just point to search.maven.org or mvnrepository.com and let the user choose one? 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

Re: core.cache 0.6.2 is not available from Central

2012-08-08 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 8. August 2012 12:06:36 UTC+2 schrieb Michael Klishin: Because users do not want to choose? Just give her a version to install, asking people to go through maven search results figuring out how to determine what's the most recent version is at least not very friendly.

Re: core.cache 0.6.2 is not available from Central

2012-08-08 Thread Meikel Brandmeyer
Hi, Am 08.08.2012 um 20:48 schrieb Sean Corfield: On Wed, Aug 8, 2012 at 11:46 AM, Sean Corfield seancorfi...@gmail.com wrote: On Wed, Aug 8, 2012 at 2:52 AM, Meikel Brandmeyer (kotarak) m...@kotka.de wrote: why recommending a specific version at all? Just point to search.maven.org

Re: What concurrency models to document?

2012-08-02 Thread Meikel Brandmeyer (kotarak)
Hi, I agree with the previous posters. Concurrency in Clojure is neither free nor automatic. You have to put quite a bit of thought in to get things right. I'm always reminded of the classic memoize discussionhttp://kotka.de/blog/2010/03/memoize_done_right.html. Things like futures or

Re: swap! and atom behavior

2012-08-01 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 1. August 2012 14:21:22 UTC+2 schrieb Vinay D.E: Just curious, but if I chained a large number of such lazy constructs, isn't there danger of a big unpredictable spike in CPU / Memory if something deeply nested is accessed ? Is there someplace where this is discussed in

Re: swap! and atom behavior

2012-08-01 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 1. August 2012 14:21:22 UTC+2 schrieb Vinay D.E: Just curious, but if I chained a large number of such lazy constructs, isn't there danger of a big unpredictable spike in CPU / Memory if something deeply nested is accessed ? You may run into a stackoverflow, though. This

Re: seesaw's beautiful docstrings

2012-07-25 Thread Meikel Brandmeyer (kotarak)
Hi, you should choose a fixed width font. Then you can line up sentences without problems using spaces. Inconvenient, but doable. 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

Re: atom and lock

2012-07-18 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 18. Juli 2012 00:57:13 UTC+2 schrieb Warren Lynn: I have a hard time understanding why there is a need to retry when doing swap! on an atom. Why does not Clojure just lock the atom up-front and do the update? I have this question because I don't see any benefit of the

Re: how do I get primitive typ hints to appear in the output of a macro?

2012-07-18 Thread Meikel Brandmeyer (kotarak)
Hi, the correct syntax is (defmacro aTest [] `(defn ~'aFun [~(with-meta 'b {:tag 'long})])) ; (meta (first (nth (macroexpand-1 '(aTest)) 2))) = {:tag long} The 'long might also be a `long. I'm not sure about that one. Kind regards Meikel PS: Shameless self-promotion:

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Meikel Brandmeyer (kotarak)
Hi, I think you don't handle the switching of streams correctly. You have to keep track with atoms. But then you run into thread-safety issues. (defn concat-input-stream Gets one or many input streams and returns a new input stream that concatenates the given streams. [is streams] (let

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Meikel Brandmeyer (kotarak)
Hi again, talking about thread safety. Am Freitag, 13. Juli 2012 16:13:54 UTC+2 schrieb Meikel Brandmeyer (kotarak): (close [] (when @is (.close @is) (doseq [s @streams] (.close s (close [] (locking this (when @is (.close

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Meikel Brandmeyer
Hi, Am 13.07.2012 um 19:25 schrieb Alan Malloy: (defn coll-enumeration [coll] (clojure.lang.SeqEnumeration. coll)) Ah. I knew there must be something. But it doesn't seem to be official, public API. Meikel signature.asc Description: Message signed with OpenPGP using GPGMail

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Meikel Brandmeyer
Hi, Am 13.07.2012 um 23:48 schrieb Kevin Downey: thank you for responding personally to me, but I sent my message to clojure google group. given the thread has the subject Concatenating InputStreams and I linked javadocs for a standard part of java.io that does exactly that, I am

Re: Concatenating InputStreams (was: Re: Parsing SGML)

2012-07-13 Thread Meikel Brandmeyer
Hi, and more errata: reading is not thread-safe when the result is -1. Then an unintended switch! might happen. There things have to be packed into a locking together with a second read to verify it's still −1. Details! Details! Kind regards Meikel signature.asc Description: Message signed

Re: Tail-recursive lazy sequence construction by appending to the end of accumulator problem.

2012-07-12 Thread Meikel Brandmeyer (kotarak)
Hi, I'm not sure I understand your problem. As soon as you talk about loop there is no laziness involved anymore. Then just use a vector. If you need laziness then use the usual lazy-seq approach with recursion (or if possible use higher-level sequence functions). Kind regards Meikel -- You

Re: Tail-recursive lazy sequence construction by appending to the end of accumulator problem.

2012-07-12 Thread Meikel Brandmeyer (kotarak)
Hi, in the first example the recursion happens immediately. That is when you call my-map you get start the recursion immediately all the way down. Hence you get the overflow. With lazy-seq basically nothing is done when calling my-map. The computation is deferred. Only when accessed the

Re: Matching map in ArraySeq

2012-06-29 Thread Meikel Brandmeyer (kotarak)
Hi, (defn example [ args] (let [[opts args] (let [opts? (first args)] (if (map? opts?) [opts? (next args)] [nil args]))] (reduce str args))) Kind regards Meikel -- You received this message because you are subscribed

Re: General subsequence function

2012-06-28 Thread Meikel Brandmeyer
Hi, Am 28.06.2012 um 20:52 schrieb Tassilo Horn: And yes, there are some counter examples like `count` and `last`... last is not a counterexample. last is a sequence function, which acts on seqs. It just calls seq on its argument so you may pass in a vector (or anything seqable). The vector

Re: Why cannot last be fast on vector?

2012-06-28 Thread Meikel Brandmeyer (kotarak)
Hi, Am Freitag, 29. Juni 2012 05:26:07 UTC+2 schrieb tbc++: For instance, one such function I wrote tonight is called every-other (returns '(1 3 5) if you hand it (1 2 3 4 5)) user= (take-nth 2 [1 2 3 4 5]) (1 3 5) Kind regards Meikel -- You received this message because you are

Re: memoization of an no-arg fn that returns a map?makes sense?

2012-06-19 Thread Meikel Brandmeyer (kotarak)
Hi, maybe lazymap might help you: https://clojars.org/de.kotka/lazymap http://bitbucket.org/kotarak/lazymap 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

Re: Best practices for named arguments

2012-06-15 Thread Meikel Brandmeyer (kotarak)
Hi, you can use destructuring to provide defaults. And you can easily curry in options when passing things through. (defn general-descend [xy ys {:keys [gradient-fn cost-fn yield-fn alpha iterations thetas] :or {cost-fncost yield-fn println alpha

Re: IllegalStateException I/O in transaction in REPL

2012-06-14 Thread Meikel Brandmeyer (kotarak)
Hi, the exception probably stems from the fact that you do the database interaction inside a dosync transaction. 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

Re: IllegalStateException I/O in transaction in REPL

2012-06-14 Thread Meikel Brandmeyer
Hi, Am 14.06.2012 um 22:33 schrieb dmirylenka: Could you please explain a bit more? I don't have any dosync in my code. transaction* contains an io! form which throws such an exception when called in a dosync. How does the code look like, which does not work? Kind regards Meikel -- You

Re: How about 'nth' accepts maps?

2012-06-12 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 12. Juni 2012 12:10:08 UTC+2 schrieb Chris Ford: While first and next need to be supported to make maps and sets sequable, I don't think that conceptually the elements are ordered. Take care! Neither maps nor sets (nor vectors for that matter) support first and next! These

Re: Is still idiomatic the ant simulation code?

2012-06-12 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 12. Juni 2012 10:24:31 UTC+2 schrieb Baishampayan Ghose: While I agree that one could use a record in place of a struct, I don't think structs are obsolete, at least not officially. From http://clojure.org/datatypes: Overall, records will be better than structmaps for

Re: If a protocol creates a Java interface under the covers...

2012-06-12 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 12. Juni 2012 14:28:21 UTC+2 schrieb Jim foo.bar: Of course, I Just noticed that type-hinting 'p' renders the precondition useless...an extra performance bonus! If update-position is a protocol function just call it without the dot. Just like a normal function. Then any

Re: Why isn't there a fold-right?

2012-06-11 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 11. Juni 2012 10:04:59 UTC+2 schrieb Tassilo Horn: The main difference is that I build up a new vector of functions instead of a list of functions in order not to have to reverse it. You should probably inline comp for your purposes. Note the reverse call there.

Re: Why isn't there a fold-right?

2012-06-11 Thread Meikel Brandmeyer (kotarak)
Hi, I propose to use criterium to do benchmarking. https://clojars.org/criterium The restart of the JVM should not be necessary. You normally need just enough warm-up rounds. criterium (mostly) takes care of such details. Kind regards Meikel -- You received this message because you are

Re: Doseq, map-style

2012-06-10 Thread Meikel Brandmeyer
Hi, Beware the personal opinion! map applies a function to each element of a sequence and returns a sequence of the results. If you call the function just for side-effects, but not the return value, then the semantics of map don't apply. Kind regards Meikel -Ursprüngliche Nachricht-

AW: Re: Doseq, map-style

2012-06-09 Thread Meikel Brandmeyer
Hi, the doseq has the additional benefit of its ugliness which makes side-effects stand out. ;) Kind regards Meikel -Ursprüngliche Nachricht- Von: Sean Corfield seancorfi...@gmail.com An: clojure@googlegroups.com Gesendet: Sa, 09 Jun 2012, 04:50:53 MESZ Betreff: Re: Doseq, map-style

Re: why String is not a collection (of Character)

2012-06-08 Thread Meikel Brandmeyer
Hi, this will be simplified tremenduously when there is a Seqable protocol. Then satisfies? will do the job. I'm still thinking when I ever needed seqable?, though. Kind regards Meikel -Ursprüngliche Nachricht- Von: Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com An:

Re: Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Meikel Brandmeyer (kotarak)
Hi, because the first element is taken verbatim and the function is not applied to it. In this case it is the zero. (iterate f x) = (x (f x) (f (f x)) ...) So the pluses you see are for the 1 and the 2. Kind regards Meikel -- You received this message because you are subscribed to the

Re: Last element of sequence returned by 'take' not showing side effects

2012-06-06 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 6. Juni 2012 12:13:56 UTC+2 schrieb Jim foo.bar: Your f is NOT free of side-effects...Nonetheless, I would expect (0 +1 +2) instead of (+0 +1 2)! Can anyone shine some light on this? When printing the sequence the tail is realized before the current item is printed.

Re: Creating a hashmap

2012-06-05 Thread Meikel Brandmeyer (kotarak)
And a completely different approach: (into {} (map-indexed #(vector (inc %1) %2) [a b c])) 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

Re: (#({:a %}) :b)

2012-06-04 Thread Meikel Brandmeyer (kotarak)
Or simply: #(vector 1 % 3) Literals are not the only way to create data structures. 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

Re: checking for a key in a sorted map

2012-06-04 Thread Meikel Brandmeyer
Hi, Am 04.06.2012 um 23:36 schrieb Jay Fields: I have some code that checks for a key as part of a cond statement. If I use a map everything works fine, but if I ever pass in a sorted-map things fail. I boiled down the issue to this: user= (contains? (sorted-map 1 2 3 4) :a)

Re: defrecord with inheritance

2012-05-22 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 22. Mai 2012 00:08:52 UTC+2 schrieb puzzler: Mergeable maps are a good idea, but the current way of doing things steers people away from that solution and requires too much forethought to actively plan for reuse. I wonder why the current way of doing things “steers away”

Re: defrecord with inheritance

2012-05-22 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 22. Mai 2012 09:01:31 UTC+2 schrieb Nicolas Oury: I think the whole thread is about the trade-off: some people complains that deftype lacks features. It's not about trade-offs. It's about deftype seemingly lacking features. Another problem with extend is that you

Re: Different behavior at REPL vs compiled code

2012-05-18 Thread Meikel Brandmeyer
Hi, because in the repl you probably call (fact 1) while running the same from the commandline passes a string: (fact 1). You should get the same error when calling the fact functions with a string at the repl. Kind regards Meikel -- You received this message because you are subscribed to

Re: Unable to replace static Java method with Clojure function

2012-05-16 Thread Meikel Brandmeyer (kotarak)
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 --

Re: Unable to replace static Java method with Clojure function

2012-05-15 Thread Meikel Brandmeyer (kotarak)
Hi, you are sure that your AOT compiled class files are on the classpath before compiling the Java side? 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

Re: how to get good at clojure?

2012-05-09 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 9. Mai 2012 08:08:10 UTC+2 schrieb Alex Baranosky: 3) read through core.clj, like a fine classic novel. You'll get all sorts of good stuff through this process. I can't express deeply enough how important this is. Just DO IT. I throw in a warning here. core.clj

Re: IllegalStateException in ns macro

2012-05-07 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 7. Mai 2012 16:15:44 UTC+2 schrieb dgrnbrg: I haven't been able to figure out how to consistently repro it--it happens when I evaluate it with VimClojure, and sometimes from the lein repl, but I don't have a clear repro case :(. Here's the repository that the code lives

Re: IllegalStateException in ns macro

2012-05-07 Thread Meikel Brandmeyer (kotarak)
Hi again, Am Montag, 7. Mai 2012 16:26:48 UTC+2 schrieb Meikel Brandmeyer (kotarak): (ns piplin.test.math (:refer-clojure :exclude [not=]) (:use ...) (:import ...)) You should do the same in piplin.math, btw. Kind regards Meikel -- You received this message because you

Re: weird pprint behaviour ?

2012-05-03 Thread Meikel Brandmeyer
Hi, Am 03.05.2012 um 18:43 schrieb Frank Siebenlist: user= (pprint #'clojure.core/*print-length*) #Var@5d2aea3e: nil nil user= (clj-ns-browser.utils/pprint-str #'clojure.core/*print-length*) #Var@5d2aea3e: 32\n user= (with-out-str (binding [*print-length* 32 *print-level* 6] (pprint

Re: weird pprint behaviour ?

2012-05-03 Thread Meikel Brandmeyer
Hi again, Am 03.05.2012 um 18:59 schrieb Meikel Brandmeyer: user= (def f nil) #'user/f user= (binding [*print-length* 32] (clojure.pprint/pprint f)) nil Of course I should have printed the Var. user= (binding [*print-length* 32] (clojure.pprint/pprint #'f)) #Var@4a3a6e5c: nil Kind regards

Re: Pulling constants out of interfaces

2012-05-02 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 1. Mai 2012 20:17:21 UTC+2 schrieb Chris Perkins: I wouldn't put too much stock in what it says at clojure.org/reader - it hasn't been updated in a long time. The implementation is probably a more definitive definition of what characters are allowed. In the past, Rich

Re: Bug recognizing tail position as default value in maps?

2012-04-27 Thread Meikel Brandmeyer (kotarak)
Hi, (defn fix2 [f x] (let [v (f x)] ({x x} v (recur f v recur is not in the tail position. The call to the map is the tail call. So the result is as expected. Kind regards, Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: Cheap defrecord transformation

2012-04-25 Thread Meikel Brandmeyer (kotarak)
Hi, your comparison is not fair. The map example merely assoc's a new value, while in the record case you create a complete fresh value with a different type. Here some more comparisons: user= (defrecord Foo [a b]) user.Foo user= (defrecord Bar [a b c]) user.Bar user= (let [x (-Foo 10 20)]

Re: Help with #'

2012-04-23 Thread Meikel Brandmeyer (kotarak)
Hi, it does not automatically deref the Var. Instead the Var delegates being called like a function to the value it's holding. If Clojure was automatically to dereffing a Var upon access, you wouldn't be able to use it as a value, because you'd always get its contents. Kind regards Meikel --

Re: inconsistent behavior with destructuring ...

2012-04-19 Thread Meikel Brandmeyer (kotarak)
Hi, I think this is a bug. This is the expansion without any :as clause: (let* [map__4496 {:a 10, :b 20, :c {:a 30, :b 40}} map__4496 (if (clojure.core/seq? map__4496) (clojure.core/apply clojure.core/hash-map map__4496) map__4496) map__4497 (clojure.core/get map__4496

Re: inconsistent behavior with destructuring ...

2012-04-19 Thread Meikel Brandmeyer (kotarak)
Hi, yes, I think so. The destructuring should not depend on the presence or absence of a (for a given key) unrelated option. So no matter what I do with :as the :a, :b, etc. keys should be correctly destructured, even in nested maps as in your example. Kind regards Meikel -- You received

Re: Boolean

2012-04-13 Thread Meikel Brandmeyer
Hi, Am 13.04.2012 um 21:45 schrieb Andy Fingerhut: One little nit that confuses me. Boolean/FALSE is documented as being of type Boolean in Java documentation, yet it is treated by Clojure the same as primitive boolean false: user= (clojure-version) 1.3.0 user= (if Boolean/FALSE

Re: Subtle differences in quoted and backquoted forms

2012-04-11 Thread Meikel Brandmeyer
Hi, for hygienic reasons. ` qualifies symbols, while ' does not. So `or might result in clojure.core/or, while 'or is always or. This is important. Consider the following example. (ns foo.bar) (defmacro foo-or [ body] `(or ~@body)) (ns frob.nicate (:refer-clojure :exclude [or]) (:use

Re: Subtle differences in quoted and backquoted forms

2012-04-11 Thread Meikel Brandmeyer
Hi, Am 11.04.2012 um 10:46 schrieb Alexander Shabanov: Oh, I see it. Well, it complicates the matters but at least it is not a bug :) In fact it makes things less complicated. You rarely want a quoted symbol in Clojure. Most of the time you'd use a keyword in such cases. Kind regards Meikel

Re: Boolean

2012-04-07 Thread Meikel Brandmeyer
Hi, Am 07.04.2012 um 18:10 schrieb Steven Obua: Thx, I am using (boolean ...) now to normalize my load-store function. ObjectInputStream and ObjectOutputStream have .readBoolean resp. .writeBoolean methods which do the right thing. Kind regards Meikel -- You received this message because

Re: Compiling Libraries With :aot

2012-04-05 Thread Meikel Brandmeyer (kotarak)
Hi Luc, Am Donnerstag, 5. April 2012 01:51:25 UTC+2 schrieb Luc: Agree, I still wonder about the downsides of AOT, comments ? Main downside - especially for an arbitrary library: it locks you down on the specific clojure version you used for compiling, also the using project. For a library

Re: Clojure meetups near Zürich, Italy, Europe

2012-03-23 Thread Meikel Brandmeyer (kotarak)
Hi Marco, would you add me to the mix? I want to build up a users group for Frankfurt am Main (Germany). However, at the moment it has only one semi-active member, myself. Nevertheless I'd like to take part in the meet the group event - should it happen - to exchange experiences a bit for

Re: Returning Success

2012-03-19 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 19. März 2012 11:56:28 UTC+1 schrieb Narvius: 1) Compare the old and new value - doesn't seem very efficient. Just return the very same world state object? You can easily and insanely fast decide whether it was changed by virtue of identical?. Then you don't need any special

Re: Recursive anonymous functions in the call position

2012-03-16 Thread Meikel Brandmeyer (kotarak)
Hi, there is no 6th element in your example. That's why you get nil. Clojure 1.3.0 user= ((fn [[f r] n] (if (zero? n) f (recur r (dec n [4 5 6 7 8 9] 2) 6 Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,

<    1   2   3   4   5   6   7   8   9   10   >