Nilsafe operators from clojure.core.contrib fail when not referred

2013-01-30 Thread Marko Topolnik
The expression (clojure.core.incubator/-? 1 identity identity) fails with Unable to resolve symbol: -? in this context unless -? is referred into the local namespace. Why it fails is clear: (macroexpand-1 `(clojure.core.incubator/-? 1 identity identity)) outputs (-? (-? 1

Re: Nilsafe operators from clojure.core.contrib fail when not referred

2013-01-30 Thread Marko Topolnik
Good point; too late to fix them now that they are about to be deprecated. On Wednesday, January 30, 2013 8:33:12 PM UTC+1, miner wrote: In Clojure 1.5 pre-releases, there's a new macro called some- . The source looks like it would work fine in earlier versions of Clojure. At this point,

Re: strange error: : Could not find or load main class –jar

2013-01-31 Thread Marko Topolnik
The java command is interpreting -jar as the name of a class instead of a command-line option. Something is messed up in the way the command is executed in your sysadmin's context. On Thursday, January 31, 2013 9:01:07 PM UTC+1, larry google groups wrote: Any suggestion, no matter how far

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

2013-02-01 Thread Marko Topolnik
Also make sure to keep in mind that subvecs are *second class* objects and are not equivalent to regular vectors in terms of API. See for example this issue. http://dev.clojure.org/jira/browse/CLJ-1082 I wouldn't worry too much about subvectors. Unless you identify them as a bottleneck

Re: Efficient idioms to handle large lists?

2013-02-01 Thread Marko Topolnik
Definitely don't recursively apply concat, it will end up with a stack overflow due the way the laziness of concat is implemented. First and foremost, are you absolutely sure you need the full list realized in memory? Your first approach with *mapcat* could be the best option if you can make

Re: How to use pmap over a partition-all list of list?

2013-02-02 Thread Marko Topolnik
no need for macros and stuff...actually apply is a macro... Not really, it's a function. But it does rely on the low-level IFn interface methods. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: reflection used for (or ...) and (into-array ...)

2013-02-18 Thread Marko Topolnik
A side note: dorun makes no sense around doseq since doseq returns nil and dorun operates on a lazy seq. On Monday, February 18, 2013 8:16:16 PM UTC+1, AtKaaZ wrote: = (time (dorun (doseq [x (take 1000 (range))] (java.awt.Color. 0 0 *(int a)* 0 Elapsed time: 7352.883635 msecs

Re: The case for as- (as-last)

2013-02-18 Thread Marko Topolnik
On Monday, February 18, 2013 5:40:51 PM UTC+1, vemv wrote: And neither can be solved by adding a lambda: (- [[1 1 1] 2 3] (nth 0) #(map inc %)) ;; fail Lambda does solve it, you are just missing the parens around the lambda: (- [[1 1 1] 2 3] (nth 0) (#(map inc %))) Clojure 1.5's as-,

Re: Clojure Performance For Expensive Algorithms

2013-02-19 Thread Marko Topolnik
The difference between String[] and Object[] is that a member of the former doesn't need a checked cast to String, but the latter does need one. In the code under consideration, however, nothing specific to String is used, so even in the Java code you can freely replace String[] with Object[]

Re: Clojure Performance For Expensive Algorithms

2013-02-19 Thread Marko Topolnik
Naturally, it's Object#equals. String's override of equals gets involved without the checked downcast. On Tuesday, February 19, 2013 6:38:07 PM UTC+1, Geo wrote: What about the call to .equals? On Tuesday, February 19, 2013 12:20:28 PM UTC-5, Marko Topolnik wrote: The difference between

Re: Possible bug with realized? and cancelled futures

2013-02-19 Thread Marko Topolnik
It could be that actually the *realized?* docstring needs change or clarification because a future can be realized in one of two ways: a value or a failure. Both count as realized in the sense that they are the *outcome * of the future; in other words, *realized?* evaluating to true* *gives the

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
On Thursday, February 21, 2013 10:49:42 PM UTC+1, David Nolen wrote: On Thu, Feb 21, 2013 at 4:55 AM, Marko Topolnik marko.t...@gmail.comjavascript: wrote: Whatever the final performance achieved, the fact remains that the original Java code was much cleaner, simpler, and more

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
Perhaps it's time to hit the decompiler :) AOT compile and apply javap; do the same for a comparable Java version. This will be a time-consuming and frustrating experience and it won't bring you lasting insight into performant Clojure because things will change around in the next release. On

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
. Phil Marko Topolnik marko.t...@gmail.com javascript: writes: Perhaps it's time to hit the decompiler :) AOT compile and apply javap; do the same for a comparable Java version. This will be a time-consuming and frustrating experience and it won't bring you lasting insight

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
It's right there in the docstring of deftype, but OK. ...followed by several sentences of big fat warnings, including that they are present only to facilitate the building of higher level constructs, such as Clojure's reference types, in Clojure itself. Other than that, you are right,

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
On Friday, February 22, 2013 8:23:38 PM UTC+1, David Nolen wrote: I'll give you one specific item that I keep tripping upon: the lack of reassignable, stack-based locals. Without them I can't efficiently get more than one value out of a loop. Another item is that I can get zero

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
On Friday, February 22, 2013 8:44:30 PM UTC+1, Marko Topolnik wrote: * implement efficient tuple type which uses mutation for multiple value return Basically, this is the ^:unsynchronized-mutable that we just mentioned :) This is much better, but still it's not stack-based, so

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
On Friday, February 22, 2013 9:04:31 PM UTC+1, David Nolen wrote: On Friday, February 22, 2013, Marko Topolnik wrote: Annoying *and* slower than Java's locals, unfortunately. Most of the time it won't make a huge dent in the performance, but I just happen to have an inner loop

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
On Friday, February 22, 2013 8:41:15 PM UTC+1, David Nolen wrote: Er re: assigning stack based locals. Forget wasting time making a tuple type, probably best to just do that with a small mutable array. This worked ok for us when porting some Java persistent data structure code to

Re: Clojure Performance For Expensive Algorithms

2013-02-22 Thread Marko Topolnik
the Java if they just want performance and just don't want to bother. On Fri, Feb 22, 2013 at 3:27 PM, Marko Topolnik marko.t...@gmail.comjavascript: wrote: On Friday, February 22, 2013 8:41:15 PM UTC+1, David Nolen wrote: Er re: assigning stack based locals. Forget wasting time making

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread Marko Topolnik
No, src is root for all Clojure. That means that your java root is under the Clojure root. Move java to top-level. On Friday, February 22, 2013 11:28:17 PM UTC+1, larry google groups wrote: I see this sentence: Having one source root contain another (e.g. src and src/java) can cause

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread Marko Topolnik
: Caused by: java.lang.RuntimeException: No such namespace: Base64Coder Not sure how to import this. I tried a simple: (ns mpdv.core (:gen-class) (:import (Base64Coder)) But that does not work. On Friday, February 22, 2013 5:31:49 PM UTC-5, Marko Topolnik wrote: No, src is root

Re: Clojure Performance For Expensive Algorithms

2013-02-23 Thread Marko Topolnik
I tend to think clojure is in a similar position - fast enough for the vast majority of things (ymmv of course - depending on what your domain is) and if you meet a situation like this where optimising the clojure becomes too ugly, you can drop down to Java (or indeed C!) Not quite, I'd

Re: Clojure Performance For Expensive Algorithms

2013-02-23 Thread Marko Topolnik
From my (admittedly limited) experience with Scala, yes, you can freely use reassignable local vars and write pretty much the same loops as in Java, but on the other hand there are many non-obvious performance pitfalls (like simply using the built-in *for comprehension*) and the optimized

Re: Clojure Performance For Expensive Algorithms

2013-02-23 Thread Marko Topolnik
wrote: Lisp programmers know the value of everything and the cost of nothing ;) On Saturday, February 23, 2013, Marko Topolnik wrote: In Clojure this is nohwere close to being true. Idiomatic Clojure is concise, expressive, and *slow.* Not 50% slower; not 100% slower; more like 100 *times

Re: Clojure Performance For Expensive Algorithms

2013-02-23 Thread Marko Topolnik
. On Saturday, February 23, 2013 9:14:12 PM UTC+1, Nicolas Oury wrote: On Fri, Feb 22, 2013 at 8:01 PM, Marko Topolnik marko.t...@gmail.comjavascript: wrote: Forgot to mention another hugely important factor: heap-allocated objects spell disaster for CPU cachelines. With today's

Re: Can't type-hint a def with ^objects

2013-02-23 Thread Marko Topolnik
Actually, ^doubles can be used for two separate things, one of which applies to ^objects as well: avoid reflection and avoid boxing/unboxing. I do need to avoid reflection. On Saturday, February 23, 2013 10:00:58 PM UTC+1, Michael Klishin wrote: 2013/2/24 Marko Topolnik marko.t...@gmail.com

Re: Can't type-hint a def with ^objects

2013-02-23 Thread Marko Topolnik
Klishin wrote: 2013/2/24 Marko Topolnik marko.t...@gmail.com javascript: I do need to avoid reflection. Then use ^[Ljava.lang.Object; and friends, it works just fine. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- You received this message because you

Re: Clojure Performance For Expensive Algorithms

2013-02-24 Thread Marko Topolnik
On Sunday, February 24, 2013 2:50:01 PM UTC+1, bernardH wrote: FWIW, I, for one, am really glad that Clojure allows us to select precisely which nice tools we want (have to) throw away (persistent data structures, dynamic typing, synchronized) when the need arises. Reminds me of the don't

Re: Clojure Performance For Expensive Algorithms

2013-02-24 Thread Marko Topolnik
On Sunday, February 24, 2013 4:27:34 PM UTC+1, Geo wrote: At the moment I don't find the Clojure solution simple, but again this may simply be to lack of exposure. Have you written a lot of performance optimized Clojure? Yes, that's the catch, isn't it? If we had to write Clojure in the

Re: Clojure Performance For Expensive Algorithms

2013-02-24 Thread Marko Topolnik
Take a look at any of the Common Lisp or Haskell submissions to the Computer Language Benchmarks Game web site, and you will see some programs that are nowhere near what people typically write in those languages, and certainly not what people would write if they weren't concerned with

Re: Clojure Performance For Expensive Algorithms

2013-02-24 Thread Marko Topolnik
from what I hear, idiomatic Haskell is a performance devil as well Does this mean very good, or very bad? It means the same as in speed devil :) On a related note, is there currently any way to get the Clojure compiler to tell you where boxing is occurring, like

Re: Clojure Performance For Expensive Algorithms

2013-02-24 Thread Marko Topolnik
I'm no Haskell expert, but it doesn't take much Googling to give strong evidence that the answer is yes, you can get mutability in Haskell. Search through this Haskell program on the Benchmarks Game site for occurrences of the string unsafe. I see; quite disgusting :) In my

Re: Clojure Performance For Expensive Algorithms

2013-02-24 Thread Marko Topolnik
On Sunday, February 24, 2013 9:15:45 PM UTC+1, puzzler wrote: As I mentioned before, I'm generally happy with Clojure's performance, but the few times I've had performance problems, I ended up rewriting the code at least three different ways in order to try to find the magic combination

Re: Clojure Performance For Expensive Algorithms

2013-02-26 Thread Marko Topolnik
This is a great analysis, thanks for the link; shame it's so old. On Sunday, February 24, 2013 10:45:33 PM UTC+1, Ben Mabey wrote: Yeah, I wish the Benchmarks allowed for idiomatic submissions and finely tuned submissions. That would allow you to get some sort of an idea how performant

Re: Clojure Performance For Expensive Algorithms

2013-02-26 Thread Marko Topolnik
-time-used-shapes.php On 2/26/13 2:35 AM, Marko Topolnik wrote: This is a great analysis, thanks for the link; shame it's so old. On Sunday, February 24, 2013 10:45:33 PM UTC+1, Ben Mabey wrote: Yeah, I wish the Benchmarks allowed for idiomatic submissions and finely tuned submissions

Re: Clojure Performance For Expensive Algorithms

2013-02-27 Thread Marko Topolnik
On Wednesday, February 27, 2013 12:53:14 AM UTC+1, Luc wrote: Why insist on getting Clojure to be at par with languages that may offer a performance boost on narrow problems at the expense of making parallel processing and code in general more complex everywhere else ? This doesn't

Re: Clojure Performance For Expensive Algorithms

2013-02-27 Thread Marko Topolnik
On Wednesday, February 27, 2013 5:19:20 AM UTC+1, Isaac Gouy wrote: If idiomatic Clojure was used... The problem, of course, is that: the code one-person considers to be idiomatic; another person considers to be idiotic, naïve. Not really. Take Stuart Halloway's opening example in the

Re: Clojure Performance For Expensive Algorithms

2013-02-27 Thread Marko Topolnik
(defn blank? [s] (every? #(Character/isWhitespace %) s)) Have you ever wondered about its performance? Here you go: user (time (dotimes [_ 1] (blank? ))) Elapsed time: 3887.578 msecs To give a more complete picture, this version (defn

Re: Clojure Performance For Expensive Algorithms

2013-02-27 Thread Marko Topolnik
On Wednesday, February 27, 2013 10:59:33 AM UTC+1, Christophe Grand wrote: Now that reduce can be short-circuited, redifining every?, some and al on top of it would yield some interesting gains: (defn revery? [pred coll] (reduce (fn [t x] (if (pred x) t

Re: wouldn't it make sense for identity to take variadic args?

2013-02-27 Thread Marko Topolnik
Apparently you misunderstand the term *identity*. The sense is the same as in *identity transform*: it is a function that transforms its argument into itself. It is useful in the context of higher-order functions where it plays the role of a no-op. None of your uses of *identity* make sense to

Re: wouldn't it make sense for identity to take variadic args?

2013-02-27 Thread Marko Topolnik
that. On Wednesday, February 27, 2013 1:39:54 PM UTC+1, Jim foo.bar wrote: On 27/02/13 12:35, Marko Topolnik wrote: it is a function that transforms its argument into itself. It is useful in the context of higher-order functions where it plays the role of a no-op that is exactly what I'm trying

Re: wouldn't it make sense for identity to take variadic args?

2013-02-27 Thread Marko Topolnik
On Wednesday, February 27, 2013 2:02:36 PM UTC+1, Jim foo.bar wrote: The actual code looks like this: (let [tok-array (into-array ^String token-seq)] (map #((if spans? (fn [span _] span) spans-strings) ;;decide what fn to use (.find this tok-array) tok-array) token-seq) As you

Re: Clojure Performance For Expensive Algorithms

2013-02-27 Thread Marko Topolnik
In your specific case, where you want every last inch of performance, it is acceptable that you will need to use the optimized idiom. However, if your overall code did anything else besides banging hard against your algorithm, a performance say 5 times worse than Java may soon become

Re: Clojure Performance For Expensive Algorithms

2013-02-27 Thread Marko Topolnik
On Wednesday, February 27, 2013 12:48:13 AM UTC+1, David Nolen wrote: Hang out with JRuby? Seriously? http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?test=alllang=clojurelang2=jruby Well, all the code-size bars are above the baseline :) Let's see how it fares when they disappear

Re: Clojure Performance For Expensive Algorithms

2013-02-27 Thread Marko Topolnik
On Wednesday, February 27, 2013 5:17:16 PM UTC+1, Luc wrote: There's no magic. You cannot win on all fronts. You defeatist, you :) I'm just trying to represent the enthusiastic perspective where if it *could* be better, it *must* be better. In many respects Clojure already embodies exactly

Re: Clojure Performance For Expensive Algorithms

2013-02-27 Thread Marko Topolnik
On Wednesday, February 27, 2013 5:59:25 PM UTC+1, Isaac Gouy wrote: (defn blank? [s] (every? #(Character/isWhitespace %) s)) Have you ever wondered about its performance? No. Why would I wonder about the performance of a one line code snippet that was written without concern for

Re: Clojure Performance For Expensive Algorithms

2013-02-27 Thread Marko Topolnik
On Wednesday, February 27, 2013 6:28:03 PM UTC+1, Andy Fingerhut wrote: If you wanted to create a collection of idiomatic Clojure programs for solving a particular set of problems, e.g. the Benchmarks Game problems, as soon as more than one person submitted a program and/or reviewed a

Re: what on earth is happening?

2013-02-28 Thread Marko Topolnik
Just a general pointer: the bytecode verification that the JVM performs when loading a class has failed. There is a code path through the bytecode of the mentioned method such that it pops more than it pushes (Java bytecode is a stack-oriented machine language). So it makes sense that it blows

Re: what on earth is happening?

2013-02-28 Thread Marko Topolnik
Nondeterministic behavior - suspect race conditions. Maybe compilation was happening concurrently on several threads and the resulting bytecode got mangled. On Thursday, February 28, 2013 4:17:52 PM UTC+1, Jim foo.bar wrote: On 28/02/13 15:12, Alex Robbins wrote: Maybe you are already

Re: what on earth is happening?

2013-02-28 Thread Marko Topolnik
reading... As a side note, I hope you all had a good laugh with my major grammar-error (throwed instead of threw)... hehe :) Jim On 28/02/13 15:21, Marko Topolnik wrote: Nondeterministic behavior - suspect race conditions. Maybe compilation was happening concurrently on several threads

Re: what on earth is happening?

2013-02-28 Thread Marko Topolnik
You could also have two independent compile-and-load operations going on in parallel. On Thursday, February 28, 2013 4:37:53 PM UTC+1, Marko Topolnik wrote: I don't have the regular compile-and-load route in mind; this doesn't use concurrency. However if the runtime evaluation of a form

Re: Clojure Performance For Expensive Algorithms

2013-03-01 Thread Marko Topolnik
below this is done calling the function reduced? Is this in Clojure 1.5 only and is where is this documented? On Wednesday, February 27, 2013 4:59:33 AM UTC-5, Christophe Grand wrote: On Wed, Feb 27, 2013 at 10:21 AM, Marko Topolnik marko.t...@gmail.comwrote: (defn blank? [s] (every

Re: In order to get java-like performance, one needs to write java-like code first?

2013-03-01 Thread Marko Topolnik
On Friday, March 1, 2013 5:35:16 AM UTC+1, yizhen wei wrote: I just start learning clojure recently. So I was looking for some performance related post on the internet, and found some optimization tips, fast clojure code and so on. Which lead to the question above. It seems like most of

Re: Java interop: Can't call public method of non-public class

2013-03-01 Thread Marko Topolnik
I'd say it's a bug. You are invoking a public class's method, which happens to be inherited from a package-private class. Clojure's reflective code accesses the superclass method directly so there's no distinction between direct invocation and invocation through inheritance. If you are

Re: byte-array woes

2013-03-02 Thread Marko Topolnik
On Saturday, March 2, 2013 6:22:51 PM UTC+1, Karsten Schmidt wrote: Is that a bug or can someone please explain why bytes seem to require special treatment in Clojure? Calling it a bug wouldn't be entirely fair since it's a missing feature. I'd say this is filable as an enhancement

Re: lazy seqs overflow the stack?

2013-03-02 Thread Marko Topolnik
It's a known issue. I guess it could be avoided if some kind of trampolining scheme was introduced instead of the current recursive one in LazySeq.java. On Saturday, March 2, 2013 8:38:24 PM UTC+1, Ben wrote: Try it and see: (reduce (fn [acc _] (concat acc acc)) '() (range 1750)) blows

Re: Faster lein

2013-03-03 Thread Marko Topolnik
If you specify AOT compilation for your main namespace (which presumably depends on everything else), the compilation resutls will be saved and reused. On Sunday, March 3, 2013 8:40:27 AM UTC+1, Buck Golemon wrote: Thanks Luc. In summary, the current compile system has no smart way to cache

Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Marko Topolnik
On Monday, March 4, 2013 3:01:13 PM UTC+1, Meikel Brandmeyer (kotarak) wrote: The range [1.2;1.5) means that the library was tested with 1.2 up to 1.4 and - believing in semver - their patchlevel children. 1.5 (was at that time) not released, yet. So compatibility couldn't be guaranteed.

Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Marko Topolnik
On Monday, March 4, 2013 3:42:56 PM UTC+1, David Powell wrote: Version ranges aren't for communicating what versions of libraries you have tested against - that is best done out-of-band. If you include a version range, like the one above, you are saying that you want the software to fail

Re: args destructuring in functions?

2013-03-06 Thread Marko Topolnik
One criterion would be how often you expect to call with zero or one z. If a lot, use ; otherwise prefer calling with an explicit collection. On Wednesday, March 6, 2013 12:45:38 PM UTC+1, Dave Sann wrote: a minor thing. which do you prefer? (defn blah [x y zs] ...) , or, (defn blah [x y

Re: args destructuring in functions?

2013-03-06 Thread Marko Topolnik
I don't think that's the question here: x and y are each their own kind of argument, followed by zero or more same-kinded arguments. Take dissoc as an example and compare with select-keys. On Wednesday, March 6, 2013 12:54:13 PM UTC+1, Achint Sandhu wrote: I personally think the first

Re: :use an entire namespace full of protocols or stick with :require?

2013-03-10 Thread Marko Topolnik
Isn't it true that you must *import* those protocols, and not :use them? In that case your dilemma would be moot. On Thursday, February 14, 2013 2:26:50 PM UTC+1, Jim foo.bar wrote: I know that using a bare :use in the ns macro is generally frowned upon as it provides no hints about what is

Re: :use an entire namespace full of protocols or stick with :require?

2013-03-10 Thread Marko Topolnik
I came to prefer one-letter prefix for a common ns over no prefix at all. Once you get accustomed to it, prefixless fns start looking wrong, and the overhead of two chars is something we can live with. On Sunday, March 10, 2013 12:50:57 PM UTC+1, Alex Baranosky wrote: Stick with require/as.

Re: Model-View-Controller in Clojure?

2013-03-10 Thread Marko Topolnik
My approach to this was to build a GUI framework which facilitates the use of closures to capture all the state atoms. This avoids the global map. The downside of global maps is also the limitation to singletons: if the same GUI element were created twice, name clashes in the global map would

Re: Newbie requesting review

2013-03-10 Thread Marko Topolnik
Several comments: 1. camelCase is not idiomatic for Clojure. Prefer lowercase-dashed-style. 2. use :keywords for map keys and, more generally, for any enumeration-type values (coming from a closed set of options). If you want JSON output, transform these into camelCased strings only at the

Re: Namespaced symbols, and errors

2013-03-10 Thread Marko Topolnik
On Friday, March 8, 2013 4:56:03 PM UTC+1, nick rothwell wrote: Typing the following at a REPL: (str ::junk/junk) (where there's no alias for junk) gives me: RuntimeException Invalid token: ::junk/junk clojure.lang.Util.runtimeException (Util.java:219) RuntimeException Unmatched

Re: fold over a sequence

2013-03-11 Thread Marko Topolnik
The idea is to transform into a lazy sequence of eager chunks. That approach should work. On Monday, March 11, 2013 11:40:01 AM UTC+1, Jim foo.bar wrote: I don't think you will be able to do a parallel fold on a lazy-seq which is what clojure.data.xml/parse returns. Vectors are the only

Re: What's the point of - ?

2013-03-11 Thread Marko Topolnik
On Monday, March 11, 2013 12:03:59 PM UTC+1, Michael Klishin wrote: 2013/3/11 edw...@kenworthy.info javascript: What I don't understand is the need for - the only thing it seems to do is make something Lispy appear to be imperative. Is that it? When you have longer chains of functions,

Re: Newbie requesting review

2013-03-11 Thread Marko Topolnik
On Monday, March 11, 2013 2:18:32 AM UTC+1, Craig Ching wrote: Ok, I *think* I understand what you're saying. I did try an anonymous function at one point, but gave it up, I don't know why I did because it ended up working pretty well after reading your advice. How's this then? (defn-

Re: Newbie requesting review

2013-03-11 Thread Marko Topolnik
That's what the web ui expects (I'm not really using teachers and students, but the actual data we do use is camel case) and there's actually a really good reason it uses what it uses. I'll make sure I didn't miss any others though, thanks! You still have the option that I've

Re: What's the point of - ?

2013-03-11 Thread Marko Topolnik
On Monday, March 11, 2013 4:00:13 PM UTC+1, edw...@kenworthy.info wrote: But to understand the first you have to expand it into the second- which means understanding the arcane squiggle - and how it differs from the equally arcane squiggle -. Nasty, sticky, syntactic sugar :) I suspect

Re: Get difference between two lists with java objects of same class

2013-03-11 Thread Marko Topolnik
I have two lists which contain java objects of the same class. I am trying to find out if there is a clojure function which i can use to compare those lists based on a key and return the objects from list A that do not exist in list B. Lists as in Clojure lists, or as in

Re: Get difference between two lists with java objects of same class

2013-03-11 Thread Marko Topolnik
Another approach, preserving the order of list-a, would be (remove (comp (into #{} (map key-fn list-b)) key-fn) list-a) On Monday, March 11, 2013 10:01:09 PM UTC+1, Marko Topolnik wrote: I have two lists which contain java objects of the same class. I am trying to find out

Re: Get difference between two lists with java objects of same class

2013-03-11 Thread Marko Topolnik
On Monday, March 11, 2013 10:55:12 PM UTC+1, Ryan wrote: Thank you all for your replies. @Marko, well, at first my question was intended to be more generic, but in reality I am dealing with two java.util.Lists I only asked because if they aren't java.util.Lists to begin with, you'd

Re: What's the point of - ?

2013-03-12 Thread Marko Topolnik
On Monday, March 11, 2013 11:51:17 PM UTC+1, Sean Corfield wrote: In addition to clj-time, I tend to use - with date-clj as well: (- (today) (subtract 30 :days)) And I find something like this: (- (- response :body :postalCodes) (map to-location) (sort-by

Re: Get difference between two lists with java objects of same class

2013-03-12 Thread Marko Topolnik
Assuming :id is the key you care about: (filter (comp (complement (set (map :id list-b))) :id) list-a) This is almost exactly the same as the one from an earlier post here: (remove (comp (into #{} (map key-fn list-b)) key-fn) list-a) I'd prefer *remove* to *filter + complement*,

Re: Get difference between two lists with java objects of same class

2013-03-12 Thread Marko Topolnik
On Monday, March 11, 2013 11:09:31 PM UTC+1, Ryan wrote: What if, i had two clojure lists, with hash-maps which have the same keys and based on a specific key, i wanted to find the items from list-a which do not exist in list-b. Would i go with the two functions you suggested or is there

Re: Noobie question - sorry :)

2013-03-12 Thread Marko Topolnik
On Tuesday, March 12, 2013 8:59:47 AM UTC+1, edw...@kenworthy.info wrote: So I do not understand why calling (defn evolve [] (Thread/sleep 1000) (print .) (recur)) Never results in anything being printed until I press Ctrl-C at which point a bunch of . are printed.

Re: What's the point of - ?

2013-03-12 Thread Marko Topolnik
On Tuesday, March 12, 2013 10:54:35 AM UTC+1, Laurent PETIT wrote: or perhaps (- response :body :postalCodes (- (map to-location) (sort-by :city))) :-) Yes, jumping to - in the middle of - works; it fails the other way around. I was always frustrated by that asymmetry, hence my love for

Re: What's the point of - ?

2013-03-12 Thread Marko Topolnik
On Tuesday, March 12, 2013 1:22:20 PM UTC+1, Dave Kincaid wrote: Before long Clojure will have as much ugly, arcane syntax as Scala. (I say that mostly tongue in cheek, btw). Clojure is way behind Scala on this score :) For me, a lot of the attractiveness of Lisp languages is the minimal

Re: fold over a sequence

2013-03-12 Thread Marko Topolnik
/in/paulbutcher MSN: pa...@paulbutcher.com javascript: AIM: paulrabutcher Skype: paulrabutcher On 11 Mar 2013, at 13:38, Paul Butcher pa...@paulbutcher.comjavascript: wrote: On 11 Mar 2013, at 11:00, Marko Topolnik marko.t...@gmail.comjavascript: wrote: The idea is to transform into a lazy

Re: fold over a sequence

2013-03-12 Thread Marko Topolnik
On Tuesday, March 12, 2013 2:48:52 PM UTC+1, Paul Butcher wrote: On 12 Mar 2013, at 13:45, Marko Topolnik marko.t...@gmail.comjavascript: wrote: Nice going :) Is it really impossible to somehow do this from the outside, through the public API? I think that it *does* do it from

Re: strange interop behaviour/issue

2013-03-12 Thread Marko Topolnik
What explains the occurrence of these extra signatures that you don't mention above? It's hard to answer without having the full picture. On Tuesday, March 12, 2013 2:52:19 PM UTC+1, Jim foo.bar wrote: Ok I investigated a bit further and I found some seriously weird stuff...I'm gonna need

Re: What's the point of - ?

2013-03-13 Thread Marko Topolnik
On Tuesday, March 12, 2013 6:20:56 PM UTC+1, Sean Corfield wrote: (as- response x (:body x) (:postalCodes x) (map to-location x) (sort-by :city x)) I like the new threading operators and I'm looking forward to using them but I'm not sure this is better since you need some neutral

Re: What causes the text that I print to the terminal to become mangled garbage?

2013-03-13 Thread Marko Topolnik
There *is* mutual exclusion on all Java output streams (as well as input streams) so at least individual prints should be atomic. Not that it will solve this, but still, this kind of granularity of interleaving is unusual. I have never seen it. On Wednesday, March 13, 2013 4:27:00 AM UTC+1,

Re: What's the point of - ?

2013-03-13 Thread Marko Topolnik
On Wednesday, March 13, 2013 9:11:44 AM UTC+1, Meikel Brandmeyer (kotarak) wrote: Am Dienstag, 12. März 2013 18:21:22 UTC+1 schrieb sw1nn: I find the need to switch between - and - in a pipeline disturbs the clarity of my code. In my experience having problems with switching between -

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.com wrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) user *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} On Wednesday, March 13, 2013 11:34:33 AM UTC+2, Marko Topolnik wrote: It is almost certain that the method you want to call is inherited from a public ancestor. Annotate the call

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) On Wednesday, March 13, 2013 11:58:06 AM UTC+2, Marko Topolnik wrote: It does have a public descendant, though. It is not acceptable for you to annotate with ServerBootstrap? It really is bad practice to annotate with non-public classes. On Wednesday, March

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
UTC+2, Marko Topolnik wrote: I see, that's very unfortunate then. It fails even when it is not actually making the reflective call. Your last recourse is writing your own code against the Java Reflection API, using *setAccesible(true)* if necessary. On Wednesday, March 13, 2013 11:03:50 AM

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
:23:17 AM UTC+1, shlomi...@gmail.com wrote: That is very true. is here the right place? is there a a different group/forum for the language developers? should i file a bug on github? On Wednesday, March 13, 2013 12:17:45 PM UTC+2, Marko Topolnik wrote: The netty people are not to blame

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
I did it: the method must be final. Apparently without that the child is compiled with an overriding method that I didn't even define! On Wednesday, March 13, 2013 11:27:55 AM UTC+1, Marko Topolnik wrote: You should first make a minimal example that reproduces this. I've just failed to do so

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
Detailed finding: it *doesn't* fail at compile time; it always fails at runtime. Reason: at compile time there is a *reflection warning*, which means that the method wasn't found and a reflective call was emited by the compiler. On Wednesday, March 13, 2013 11:31:08 AM UTC+1, Marko Topolnik

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
: java.lang.VerifyError: class Test overrides final method methodA.()I, compiling:(NO_SOURCE_PATH:2) what is your code? On Wed, Mar 13, 2013 at 12:31 PM, Marko Topolnik marko.t...@gmail.comjavascript: wrote: I did it: the method must be final. Apparently without that the child is compiled

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
as i originally got? On Wednesday, March 13, 2013 12:38:26 PM UTC+2, Marko Topolnik wrote: Detailed finding: it *doesn't* fail at compile time; it always fails at runtime. Reason: at compile time there is a *reflection warning*, which means that the method wasn't found and a reflective call

Re: Java interop: Can't call public method of non-public class

2013-03-13 Thread Marko Topolnik
! On Wednesday, March 13, 2013 1:02:25 PM UTC+2, shlomi...@gmail.com wrote: right, i managed to reproduce it here, thanks! so i am opening a bug and linking back here On Wednesday, March 13, 2013 12:48:43 PM UTC+2, Marko Topolnik wrote: Yes, the error is there. I also created a *lein new

Re: set!

2013-03-13 Thread Marko Topolnik
On Wednesday, March 13, 2013 9:35:42 PM UTC+1, puzzler wrote: OK, thanks. The apparent globalness is not the piece I want to imitate. I want to make a var available for users to set!, where the var controls overall behavior of how the library operates. I understand that I can just

Re: skip null

2013-03-13 Thread Marko Topolnik
There are several, depending on what exactly you want to skip. Your example would just be (let [foo (or a b c)] ...) There are also some- and cond-, which you may find useful in other contexts. On Wednesday, March 13, 2013 10:31:33 PM UTC+1, Brian Craft wrote: Is there a common idiom for

  1   2   3   >