comparator that compares collections similar to how strings are compared

2011-07-10 Thread Eugen Dück
Say I have this sorted map, using strings as keys: x= (sorted-map ab 1 n 2) {ab 1, n 2} When I do a subseq x= (subseq (sorted-map ab 1 n 2) aa) ([ab 1] [n 2]) I get back both entries. Now if I do the same subseq on the same map, except that I turn all strings into character collections, I

Re: comparator that compares collections similar to how strings are compared

2011-07-10 Thread Eugen Dück
to get the sorting behavior I need? On Jul 10, 6:09 pm, Eugen Dück eu...@dueck.org wrote: Say I have this sorted map, using strings as keys: x= (sorted-map ab 1 n 2) {ab 1, n 2} When I do a subseq x= (subseq (sorted-map ab 1 n 2) aa) ([ab 1] [n 2]) I get back both entries. Now if I do

Re: comparator that compares collections similar to how strings are compared

2011-07-10 Thread Eugen Dück
] (or (first (drop-while zero? (map compare coll1 coll2))) (- (count coll1) (count coll2 Now, is this the way to get the sorting behavior I want or is anyone aware of something simpler or more performant? On Jul 10, 6:09 pm, Eugen Dück eu...@dueck.org wrote: Say I have this sorted map, using

Re: comparator that compares collections similar to how strings are compared

2011-07-10 Thread Eugen Dück
:54 pm, Eugen Dück eu...@dueck.org wrote: Well, turns out string-like-coll-comparator has a bug: x= (subseq (sorted-map-by string-like-coll-comparator (vec ab) 1 (vec n) 2) (vec a)) NullPointerException   clojure.lang.AFunction.compare (AFunction.java: 59) It can be fixed though: (defn

Re: deploying application updates to end users

2011-02-19 Thread Eugen Dück
Java Web Start is super easy to use for end users, if that is an option for you. All they have to do is click a link on a web page. The signing part is a bit of a pita to set up, unless you follow one of the quick howtos on web start for Java in general, and maybe by now there are some clojure

metadata example on http://clojure.org/evaluation

2011-02-11 Thread Eugen Dück
There's an example on metadata that resembles a repl session snippet (although not exactly): user= (def x 1) user= (def y 2) user= ^{:x x} [x y 3] ^{:x 1} [1 2 3] I interpret that as the reader prints out meta data, which of course is not true (by default). It could be changed, e.g. to user=

Re: Any news on pull requests?

2011-02-10 Thread Eugen Dück
: On Fri, Feb 4, 2011 at 6:16 PM, Eugen Dück eu...@dueck.org wrote: Is it really necessary, though? We all agree to EULAs and make other more significant legal commitments online all the time, and in some cases without having proven who and where we are. There are certainly some legal

Re: Any news on pull requests?

2011-02-10 Thread Eugen Dück
Not that size should matter when it comes to legalistics, but it appears the already mentioned KDE project, claiming that the KDE community is the second largest Free Software community by most measures, after the linux kernel, does not seem to have introduced a CA requirement by now. (From

Re: force evaluation of macro parameter

2011-02-05 Thread Eugen Dück
: On Sat, Feb 5, 2011 at 12:08 AM, Eugen Dück eu...@dueck.org wrote: yes, the code is more complex and it is in contrib. Changing contrib requires you to send an intercontinental mail first, as mentioned in my other post today... :) Reason enough to first checkout the other options and dig deeper

Re: Any news on pull requests?

2011-02-05 Thread Eugen Dück
scan - email would be more convenient for me. @Chistopher people keep citing it as some unique requirement foisted upon the community by a power hungry dictator That's a generalization that lacks any relation to this thread, and I guess even the clojure community in general. I'm not aware of

Any news on pull requests?

2011-02-04 Thread Eugen Dück
In June 2009, Rich wrote in clojure goes git!: Some items are still outstanding: Importation of existing issues Placement of generated contrib documentation Patch submission policy In particular, please don't send pull requests via GitHub at this time. Any updates

Re: Any news on pull requests?

2011-02-04 Thread Eugen Dück
On Feb 5, 11:00 am, Sean Corfield seancorfi...@gmail.com wrote: On Fri, Feb 4, 2011 at 5:24 PM, Eugen Dück eu...@dueck.org wrote: Furthermore, I was really surprised to find onhttp://clojure.org/contributing that I have to send a (non-e)mail around the world to be able to contribute

Re: Any news on pull requests?

2011-02-04 Thread Eugen Dück
On Feb 5, 11:51 am, Sean Corfield seancorfi...@gmail.com wrote: off to Rich... If someone really feels signing and mailing an agreement is too much work then they don't seem very committed to contributing, IMO. It's really not much of a hardship is it? Things like github's pull requests are

force evaluation of macro parameter

2011-02-04 Thread Eugen Dück
I'm using a macro that, stripped down to just expose my problem, looks like this: (defmacro quoted-param [x] `(println '~x)) It's all nice if I call it like (quoted-param 23) It will print the number 23. The following, however, will print asdf, rather than 23: (def asdf 23) (quoted-param

Re: force evaluation of macro parameter

2011-02-04 Thread Eugen Dück
On Feb 5, 1:52 pm, Eric Lavigne lavigne.e...@gmail.com wrote: This makes me think that the original macro needs some refactoring. There should be a function that handles most of the work, and a macro to make your code shorter in the common case. (defn unquoted-param [x] (println x))

JSpinner SpinnerModel for numbers with different step sizes - beating Java in its own domain

2011-01-22 Thread Eugen Dück
Anyone who has seen the subject implemented in Java/Swing might have been stunned by the hundreds of lines of code that were deemed necessary for it, with their appropriate share of bugs. (And an implementation I've seen in C#/NetAdvantage was even worse, which was less related to the language

Re: JSpinner SpinnerModel for numbers with different step sizes - beating Java in its own domain

2011-01-22 Thread Eugen Dück
)) inc identity) (quot value tick-size) value)) On Jan 23, 11:18 am, Eugen Dück eu...@dueck.org wrote: Anyone who has seen the subject implemented in Java/Swing might have been stunned by the hundreds of lines of code that were deemed necessary for it, with their appropriate share of bugs

compiling the instructions of a simple vm into a function

2010-06-18 Thread Eugen Dück
Recently, I implemented last year's ICFP problem. Part of it is writing a VM that consists of memory slots, some registers and input and input ports. It takes a list of instructions, works them off one after the other, reading from input or memory, calculating something and the changing registers

Re: compiling the instructions of a simple vm into a function

2010-06-18 Thread Eugen Dück
Thanks Nicolas, your first variant resembles the generated code much closer than my initial approach, which is great. I need the eval though, to be able to pass in non literals. In my real program I'm reading the instructions from a binary file. So if I want to be able to do something like this:

ICFP 2009 / ICFP 2010

2010-06-11 Thread Eugen Dück
I plan on doing ICFP 2010 next weekend in clojure (1.1), if the problem is interesting. In preparation, I'm currently doing the (implementation-wise) crucial bits of last year's contest. I put the first part of my implementation online:

Re: ICFP 2009 / ICFP 2010

2010-06-11 Thread Eugen Dück
BTW, there will also be a 24h lightning round for those who can't waste an extended weekend. On Jun 12, 11:51 am, Eugen Dück eu...@dueck.org wrote: I plan on doing ICFP 2010 next weekend in clojure (1.1), if the problem is interesting. In preparation, I'm currently doing the (implementation

Re: mapping a collection and a transposed collection of collections

2010-06-08 Thread Eugen Dück
That's perfect - Thanks! On Jun 7, 11:43 am, ataggart alex.tagg...@gmail.com wrote: (map list x (apply map list y)) On Jun 6, 5:51 am, Eugen Dück eu...@dueck.org wrote: Suppose I have two collections: (def x [1 2]) (def y [[\a \b] [\d \e] [\f \g]]) And want to iterate over them

Re: (apply interleave [[1 2]])

2010-06-06 Thread Eugen Dück
And we could actually also add an no-arg version. My own version of interleave that I use looks like this: (defn interleav ([] nil) ([c] (seq c)) ([c1 c2] (interleave c1 c2)) ([c1 c2 colls] (apply interleave c1 c2 colls))) I guess that's as generic as it gets. Does Rich read all

mapping a collection and a transposed collection of collections

2010-06-06 Thread Eugen Dück
Suppose I have two collections: (def x [1 2]) (def y [[\a \b] [\d \e] [\f \g]]) And want to iterate over them in the following manner: user= (map list x (transpose y)) ((1 (\a \d \f)) (2 (\b \e \g))) Where this is the transpose fn: (defn transpose [in] (partition (count in) (apply

Re: mapping a collection and a transposed collection of collections

2010-06-06 Thread Eugen Dück
of args passed to: core$interleave (NO_SOURCE_FILE:0) On Jun 6, 9:51 pm, Eugen Dück eu...@dueck.org wrote: Suppose I have two collections: (def x [1 2]) (def y [[\a \b] [\d \e] [\f \g]]) And want to iterate over them in the following manner: user= (map list x (transpose y)) ((1 (\a \d \f

Re: (apply interleave [[1 2]])

2010-05-29 Thread Eugen Dück
?  If not, I don't see a reason to include it. -- Paul Hobbs On Sat, May 29, 2010 at 1:32 AM, Eugen Dück eu...@dueck.org wrote: When I do (apply interleave some-colls) and some-colls is a sequence/collection of only one sequence/ collection, it will throw: user= (apply interleave [[1 2

(apply interleave [[1 2]])

2010-05-28 Thread Eugen Dück
When I do (apply interleave some-colls) and some-colls is a sequence/collection of only one sequence/ collection, it will throw: user= (apply interleave [[1 2]]) java.lang.IllegalArgumentException: Wrong number of args passed to: core$interleave (NO_SOURCE_FILE:0) (Of course I don't need the

Can I GPL my Clojure project?

2010-03-27 Thread Eugen Dück
I was always assuming I can GPL my Clojure project, just as I can GPL projects using completely closed compilers and/or runtime environments (?). And the EPL itself is not restrictive when it comes to non- derived work. But then I read a couple of threads in this group, and also got a response you

ANN: Kanshiki Boom! - Japanese handwriting recognition

2010-03-26 Thread Eugen Dück
I'd like to announce 漢識 Boom!, a handwriting recognition software for Japanese Kanjis. It is available at http://dueck.org/kanshiki-boom/ Currently, it will be useful mainly for learners of the Japanese language, as * it requires the user to use the official stroke order and direction (although

Re: ANN: Kanshiki Boom! - Japanese handwriting recognition

2010-03-26 Thread Eugen Dück
On Mar 27, 1:10 am, Jarkko Oranen chous...@gmail.com wrote: This looks neat. I probably won't find much use for it though, as my input method already has this functionality, and even that doesn't get much use due to the fact that I am horrible at writing kanji with the mouse (I'm left-handed,

Re: web starting clojure apps without Java code

2010-03-25 Thread Eugen Dück
I fixed a couple of other issues, most of which show only on Windows. You should see Kanjis now on the right-hand side when drawing. Eugen On Mar 23, 5:30 pm, Zmitro Lapcjonak idob...@gmail.com wrote: On Mar 17, 4:56 pm, Eugen Dück eu...@dueck.org wrote: The complete jnlp can be found athttp

Re: web starting clojure apps without Java code

2010-03-24 Thread Eugen Dück
a white panel, try resizing the window. But it should re- layout automatically now. And make sure to draw the strokes in the right order and direction. Cheers Eugen On Mar 23, 5:30 pm, Zmitro Lapcjonak idob...@gmail.com wrote: On Mar 17, 4:56 pm, Eugen Dück eu...@dueck.org wrote: The complete

Re: web starting clojure apps without Java code

2010-03-24 Thread Eugen Dück
I just tried starting it from a Windows box, and for some reason, the kanjis are not displayed there. Maybe it's a font issue, not sure yet. Will investigate. On Mar 24, 9:06 pm, Eugen Dück eu...@dueck.org wrote: Hi Zmitro, you should see kanjis being detected as you draw the strokes. Maybe

Re: web starting clojure apps without Java code

2010-03-19 Thread Eugen Dück
That would be great! Please post the link here when you're done. On Mar 18, 5:15 pm, LauJensen lau.jen...@bestinclass.dk wrote: Eugen, Fantastic insight - I cant wait to work that into a blogpost :) Lau On 17 Mar., 15:56, Eugen Dück eu...@dueck.org wrote: All, Developing in clojure

web starting clojure apps without Java code

2010-03-17 Thread Eugen Dück
All, Developing in clojure is a lot of fun, at least it was for me and a project of mine - except for one thing: Deploying the app as Java Web Start app, that took me a bit of time to figure out, and not only because Java Web Start is broken in debian squeeze (for a workaround, see

Re: bounded memoize

2010-03-14 Thread Eugen Dück
On Mar 14, 5:42 pm, Meikel Brandmeyer m...@kotka.de wrote: really shows, that concurrent programming is not trivial. Not even for „trivial“ things like a memoised function. True. It's not too hard to be correct, but being correct and performant at the same time is a different issue... Thinking

Re: bounded memoize

2010-03-14 Thread Eugen Dück
On Mar 14, 7:59 pm, Christophe Grand christo...@cgrand.net wrote: Well the fn passed to swap! can be retried so in case of bad luck you'll still create several delays. You're absolutely right! I wonder whether we can make any statement about the likeliness of this happening in memoize6/7 vs.

Re: bounded memoize

2010-03-13 Thread Eugen Dück
On Mar 13, 4:51 pm, Christophe Grand christo...@cgrand.net wrote: My variations on memoize use a single atom: your bounded-memoize id roughly equivalent to my memoize2 + fifo-strategy, seehttp://gist.github.com/330644#LID19. I finally found the time to fully read your gist, and I see you are

Re: bounded memoize

2010-03-13 Thread Eugen Dück
On Mar 14, 11:57 am, Eugen Dück eu...@dueck.org wrote: This gap shrinks when using memoize7 thanks to the use of delays, but it is not completely closed and can still lead to multiple delays of the same computation. If we want to get rid off this gap and make it Actually, I take that back

Re: bounded memoize

2010-03-13 Thread Eugen Dück
Hi Christophe, your fifo-strategy (the one that uses identity as the hit method) does not work: user= (def g (memoize7 identity (fifo-strategy 3))) #'user/g user= (g 1) 1 user= (g 1) java.lang.IllegalArgumentException: Wrong number of args passed to: core$identity (NO_SOURCE_FILE:0) You have to

Re: bounded memoize

2010-03-12 Thread Eugen Dück
Laurent, Meikel, Christophe, I guess I must be missing something obvious, but can't we just put more than one thing into an atom in order to get atomic behavior? Using, say, a vector. Using the simple bounded memoizer as an example, this looks to me like it works: (defn bounded-memoize [f

Re: bounded memoize

2010-03-09 Thread Eugen Dück
...@kotka.de wrote: Hi, On Mar 9, 4:41 am, Eugen Dück eu...@dueck.org wrote: Good points! Testing array-map briefly led me to believe they can be used as the clojure equivalent of Java\s LinkedHashMaps. Here's a version that uses a vector to remember order of insertion - I guess I have

bounded memoize

2010-03-08 Thread Eugen Dück
In many real applications (I guess that rules out fibonacci), memoize will consume a lot of memory and create OutOfMemoryErrors sooner or later. Often you want to only keep the latest items in the cache and forget about older ones. I've seen a variant of memoize that evicts items based on a

Re: bounded memoize

2010-03-08 Thread Eugen Dück
wrote: On 8 March 2010 05:31, Eugen Dück eu...@dueck.org wrote: And here's a variant that evicts elements when the size of the cache exceeds some limit. In that case, the first item that was put in it will be dissoc'ed. I'm using an array-map to accomplish this: I don't think this will work

Re: generalize distinct

2010-02-23 Thread Eugen Dück
I agree with you, Michal. But let me rephrase the question, maybe my initial long-winded post wasn't clear enough on that. Rather than having a separate fn 'distinct-by' in addition to the existing 'distinct', which, apart from the hard-coded keyfn would be EXACTLY the same, shouldn't we just

Re: generalize distinct

2010-02-23 Thread Eugen Dück
Agree, it might make sense to do that performance-wise. Although I'm hoping that the compiler would be able to inline that as well (optimizing away calls to identity). Btw, what does :inline-arities do? It sounds like this could do what we want. On Feb 24, 5:03 am, Sean Devlin

Re: generalize distinct

2010-02-22 Thread Eugen Dück
group-by does not filter, in contrast to distinct. And I'm really only interested in one of the values considered equal according to my keyfn. So if I sed group-by, I'd have to wrap it with a call to map or similar. This is certainly an option, but I'd rather not create all the intermediate