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 vector

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 gen

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 wrote: > I guess I

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 time-t

Re: bounded memoize

2010-03-08 Thread Eugen Dück
te: > On 8 March 2010 05:31, Eugen Dück 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:

Re: bounded memoize

2010-03-09 Thread Eugen Dück
wrote: > Hi, > > On Mar 9, 4:41 am, Eugen Dück 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 o

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 capac

Re: bounded memoize

2010-03-13 Thread Eugen Dück
On Mar 13, 4:51 pm, Christophe Grand 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 indeed doing the sa

Re: bounded memoize

2010-03-13 Thread Eugen Dück
On Mar 14, 11:57 am, Eugen Dück 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 hav

Re: bounded memoize

2010-03-14 Thread Eugen Dück
On Mar 14, 5:42 pm, Meikel Brandmeyer 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 about your

Re: bounded memoize

2010-03-14 Thread Eugen Dück
On Mar 14, 7:59 pm, Christophe Grand 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. memoize7-variant or

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 bugs.debian.org

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 wrote: > Eugen, > > Fantastic insight - I cant wait to work that into a blogpost :) > > Lau > > On 17 Mar., 15:56, Eugen Dück wrote: > > > All, > > > Develo

Re: web starting clojure apps without Java code

2010-03-24 Thread Eugen Dück
till only see 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 wrote: > On Mar 17, 4:56 pm, Eugen Dück wrote: > > > The comple

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 wrote: > Hi Zmitro, > > you should see kanjis being detected as you draw the strokes. M

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 wrote: > On Mar 17, 4:56 pm, Eugen Dück wrote: > > > The complete jnlp can be found athttp://dueck.org/k

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 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, but my mouse-ha

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 "y

(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 a

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

2010-05-29 Thread Eugen Dück
; special case?  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 wrote: > > When I do > > > (apply interleave some-colls) > > > and some-colls is a sequence/collection of only one sequ

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 thread

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 interle

Re: mapping a collection and a "transposed" collection of collections

2010-06-06 Thread Eugen Dück
n: Wrong number of args passed to: core$interleave (NO_SOURCE_FILE:0) On Jun 6, 9:51 pm, Eugen Dück 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 li

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 wrote: > (map list x (apply map list y)) > > On Jun 6, 5:51 am, Eugen Dück wrote: > > > Suppose I have two collections: > > > (def x [1 2]) > > (def y [[\a \b] [\d \e] [\f \g]]) > > > And wa

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: http://read-eval-puke.blogspot.com/2010/06/icfp-2009-orbit-bi

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 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 > (implement

Re: ICFP 2009 / ICFP 2010

2010-06-13 Thread Eugen Dück
So, I'm done for this weekend. What I have (and put on the blog) * a binary parser * the vm (interpreted, maybe I can turn it into a compiled vm in the coming week? any ideas? macros? have to think about it) * a graphical visualizer * a controller "framework", allows you to solve the actual proble

Re: ICFP 2009 / ICFP 2010

2010-06-13 Thread Eugen Dück
OK, I'm done for this weekend. Here's what I got: * the binary reader * the vm ("interpreted" for now - would like to make a "compiled" vm. still have to think about it, I guess macros would help?) * a graphical visualizer * a controller framework to solve the actual problems The code is surprisi

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 o

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:

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 charact

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

2011-07-10 Thread Eugen Dück
t;ab") 1 (vec "n") 2) > (vec "a")) ([[\a \b] 1] [[\n] 2]) So is this then the best way to get the sorting behavior I need? On Jul 10, 6:09 pm, Eugen Dück wrote: > Say I have this sorted map, using strings as keys: > > x=> (sorted-map "ab" 1 "

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

2011-07-10 Thread Eugen Dück
string-like-coll-comparator [coll1 coll2] (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 wrote:

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

2011-07-10 Thread Eugen Dück
:54 pm, Eugen Dück 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 (AFunctio

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 itse

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

2011-01-22 Thread Eugen Dück
e 2)) inc identity) (quot value tick-size) value)) On Jan 23, 11:18 am, Eugen Dück 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 b

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. An

Re: Any news on pull requests?

2011-02-04 Thread Eugen Dück
On Feb 5, 11:00 am, Sean Corfield wrote: > On Fri, Feb 4, 2011 at 5:24 PM, Eugen Dück 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 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 really great, as the

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 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)) > > (defmacro quoted-param

Re: force evaluation of macro parameter

2011-02-05 Thread Eugen Dück
n Sat, Feb 5, 2011 at 12:08 AM, Eugen Dück 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 > > opti

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 o

Re: Time/size bounded cache?

2011-02-06 Thread Eugen Dück
A while back the discussion on the "bounded memoize" thread in this forum lead to Meikel writing up a nice summary of how to do caching, providing a pluggable strategy: lru, ttl, fifo, etc. Meikel's writeup can be found at http://kotka.de/blog/2010/03/memoize_done_right.html It presents a bunch of

Re: Time/size bounded cache?

2011-02-06 Thread Eugen Dück
And if you don't have time to read the whole blog post - it's very detailed - and just read code, you could scroll down to cgrand's memoize8 function at https://gist.github.com/330644 On Feb 6, 8:32 pm, Eugen Dück wrote: > A while back the discussion on the "bounded

Re: Any news on pull requests?

2011-02-10 Thread Eugen Dück
l requests by CA signers, I'm still hopeful though, as I don't see the legal issue there, and there's a hint in "please don't send pull requests via GitHub AT THIS TIME". Cheers Eugen On Feb 5, 11:45 am, Mike Meyer wrote: > On Fri, 4 Feb 2011 18:36:34 -0800

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 quick

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: 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 (lei