Re: Anyone want to take a crack at making the fasta shootout program faster?

2011-02-13 Thread Isaac Gouy
On Feb 12, 9:51 pm, Michael Gardner wrote: -snip- > Those are all good, but ... Before I pointed out that code size was already shown, you thought just including such a measure would possibly "do the trick" but now that seems not to be good enough for you. > how many people actually look at an

Re: ANN: Textmash - another IDE for Clojure

2011-02-13 Thread Olek
Hi, Yes I can reproduce the bug on MacOS too. I have added :main textmash.core to project.clj. Now after: lein run, the GUI starts and all implemented functionalities work fine, but in console I get: Exception in thread "main" java.lang.NullPointerException (NO_SOURCE_FILE:1) at clojure.l

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread James Reeves
On 12 February 2011 18:56, Seth wrote: > As the question states - why doesnt defrecord support java class > inheritence? Is it just because people think it wouldnt be 'good' or > are there true technical issues with doing it? It's a design choice. Some languages tie together the concepts of inher

Infinite seqs and testing

2011-02-13 Thread Andreas Liljeqvist
I have a statemap with a couple of infinite lazy-seq. When doing testing I want to check states for equality. This of course fails on the whole infinite thing. The sane thing is taking only the first item from the seqs when doing the equality check. How would I accomplish this in the easiest way?

Re: Infinite seqs and testing

2011-02-13 Thread Stuart Sierra
Redefining equality is not something to be taken lightly. It can break in subtle ways with identity and hash codes. You may want a custom equality function, like "equal up to n elements of a sequence," for use in your tests. -Stuart Sierra clojure.com -- You received this message because you

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Stuart Sierra
I believe there are some technical issues with allowing re-definition of a class that inherits from a concrete (non-interface) superclass, but I don't know the details. However, it was mainly a design decision. Clojure is opinionated, and one of its opinions is that concrete inheritance is bad

Re: Type hinting question

2011-02-13 Thread Stuart Sierra
Modern JVMs like HotSpot are very good at eliminating unnecessary instructions. Unfortunately, I haven't heard of a good tool for observing this process, so you either have to take it on faith or go read the OpenJDK source code. -Stuart Sierra clojure.com -- You received this message because

Pimp my algorithm: finding repeating subsequences

2011-02-13 Thread Mark Fredrickson
Hello friends, I am writing a program to generate directions for humans to read. The directions are composed of a collection with a series of steps, some of which may be duplicated: [:a :b :c :a :b :c] I would like to compress them by indicating repeats, using this notation: [[2 [:a :b :c]] Si

Re: better error messages > smaller stack traces

2011-02-13 Thread Jeff Rose
Here's one: user=> {:a 1 :b} # Instead how about a parse error exception that specifically says something like, "Map literal requires an even number of forms." Thanks, Jeff On Feb 8, 3:01 pm, Stuart Halloway wrote: > This conversation began on Twitter [1] but I want to continue it on the > ma

Request for review: GAHelloWorld

2011-02-13 Thread John Svazic
Thanks again to Alex for helping me with my Clojure mojo in order to get around a ClassCastException. I'm writing to request a code review of my simple "Hello, world!" genetic algorithm simulator written in Clojure. I've written an implementation in Java and I have used that as the basis for my C

Re: Pimp my algorithm: finding repeating subsequences

2011-02-13 Thread Mark Engelberg
This is essentially a compression problem. I think you want to research the topic of "Run-length encoding", and then look at algorithms like LZ77 which handle runs of repeated characters. LZ77 finds repeated blocks that are some distance apart; so, for example, you could restrict the algorithm to

Re: Pimp my algorithm: finding repeating subsequences

2011-02-13 Thread Andy Fingerhut
On Feb 13, 2011, at 10:11 AM, Mark Fredrickson wrote: Hello friends, I am writing a program to generate directions for humans to read. The directions are composed of a collection with a series of steps, some of which may be duplicated: [:a :b :c :a :b :c] I would like to compress them by ind

Re: Pimp my algorithm: finding repeating subsequences

2011-02-13 Thread Fred Concklin
DEFLATE is a compression method that combines LZ77 with Huffman coding. It is implemented in java.util.zip. Read about it here: http://download.oracle.com/javase/1.4.2/docs/api/java/util/zip/package-summary.html fpc -- You received this message because you are subscribed to the Google Groups "

Append a # and a string

2011-02-13 Thread Christopher Maggio
Hi, clojure newbie here; I have a quick question, I am writing a small pattern matching program and I can't figure out how to append a string to a # for re-matcher: (.replaceAll (re-matcher #"ATGCCC" my_String) replacement_String) When I try (string? #"ATGCCC") it returns false. # isnt a macro

Re: Infinite seqs and testing

2011-02-13 Thread Andreas Liljeqvist
Roger that. Thanks for the help. 2011/2/13 Stuart Sierra > Redefining equality is not something to be taken lightly. It can break in > subtle ways with identity and hash codes. > > You may want a custom equality function, like "equal up to n elements of a > sequence," for use in your tests. >

noob Echo Server coded, need help to figure out if there is better/idiomatic way of doing things.

2011-02-13 Thread Jigar Gosar
* I think io-loop function can be improved/simplified. * I usually don't like duplication (.readLine in) is being repeated in io-loop. * any other comments/links/reference to some other idiomatic code are welcome. (ns echo.server [:use clojure.contrib.server-socket clojure.java.io clojure.contri

Re: Append a # and a string

2011-02-13 Thread Fred Concklin
Christopher Maggio writes: > Hi, clojure newbie here; > > I have a quick question, I am writing a small pattern matching program > and I can't figure out how to append a string to a # for re-matcher: Not quite following, but check out re-pattern (http://clojuredocs.org/clojure_core/clojure.core/r

Re: Request for review: GAHelloWorld

2011-02-13 Thread Stefan Kamphausen
Hi, you may be interested in reading the code from our book which a) includes the code for doing exactly what you did (evolve a string) and b) shows how multithreading can change your way of doing GAs (get rid of the concept of generations). The book and the code are written in German which ma

Re: Append a # and a string

2011-02-13 Thread Christopher Maggio
Thanks, just what i was looking for! -Chris On Feb 13, 9:04 pm, Fred Concklin wrote: > Christopher Maggio writes: > > Hi, clojure newbie here; > > > I have a quick question, I am writing a small pattern matching program > > and I can't figure out how to append a string to a # for re-matcher: >

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
Cool, thats what I thought. Sometimes, i wish i could inherit from a class, but then i just use proxy to do it instead :) For example, i made a function which acted like a fn? , but had some metadata. At first i was going to use records, but couldnt because i needed to inherit from Afn, but proxies

Best method for storing dynamic data in database

2011-02-13 Thread Seth
I have an application which contains a number of running threads, each which has a state to it. A state is a single record. It contains some random stuff, but most importantly it a has a :var slot which contains a map in which the keys are vars and the values are whatever the vars are (if they can

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Ken Wesson
On Sun, Feb 13, 2011 at 7:00 PM, Seth wrote: > Cool, thats what I thought. Sometimes, i wish i could inherit from a > class, but then i just use proxy to do it instead :) For example, i > made a function which acted like a fn? , but had some metadata. At > first i was going to use records, but cou

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
I already have code which uses fn? everywhere. So i needed to inherit Fn interface. Adding metadata to the function (basically, an id) was a necessary afterthought. Basically, im using an emacs like hook interface for the gui end of my application, so its hightly configurable - but i need to know w

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
oh, and of course the funuction needs to be executable (they are after all just functions with metadata) - so we cant use ifn?, which would return true on record! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clo

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
And just for the heck of it, if anyones interested - heres the hook code. (ns forex.util.emacs)) (defmacro is [val & message] `(let [result# ~val] (if (not result#) (throw (Exception. ~(or (and (first message) `(format ~@message)) (format "assert: %s" (str val) result#)))

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
and of course i forgot to include some utility functions. oh well... -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with

Re: Best method for storing dynamic data in database

2011-02-13 Thread Ken Wesson
On Sun, Feb 13, 2011 at 8:39 PM, Seth wrote: > I have an application which contains a number of running threads, each > which has a state to it. A state is a single record. It contains some > random stuff, but most importantly it a has a :var slot which contains > a map in which the keys are vars

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Ken Wesson
On Sun, Feb 13, 2011 at 10:14 PM, Seth wrote: > oh, and of course the funuction needs to be executable (they are after > all just functions with metadata) - so we cant use ifn?, which would > return true on record! The map? function also returns true on a record, and false on a deftype, so #(and

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Ken Wesson
As for being able to attach metadata, you just have to implement IObj on your functoids. -- 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 - ple

Re: Pimp my algorithm: finding repeating subsequences

2011-02-13 Thread Mark Fredrickson
Thanks for the hint on LZ77. That was exactly what I was looking for. Thank you also to the others who provided this and other answers. Thanks! -Mark On Feb 13, 1:00 pm, Mark Engelberg wrote: > This is essentially a compression problem.  I think you want to research the > topic of "Run-length

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
whats wrong with implementing Fn and IMeta? On Feb 13, 9:35 pm, Ken Wesson wrote: > As for being able to attach metadata, you just have to implement IObj > on your functoids. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, sen

Re: Help - .class files and GAE's "too many files" problem

2011-02-13 Thread Constantine Vetoshev
On Feb 10, 7:47 pm, Edgar Gonçalves wrote: > So for future reference, if you come up with the same issue, the solution is > to compile your gen'ed-classes and delete all the others from the > war/WEB-INF directory, making sure you have a standalone jar along the > remaining used jars (a uberjar ma

Re: Best method for storing dynamic data in database

2011-02-13 Thread Seth
any serializable java object should be supported. hmmm... i guess that would work - simply output the object as a byte string and then decode that. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegrou

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Ken Wesson
On Sun, Feb 13, 2011 at 11:26 PM, Seth wrote: > whats wrong with implementing Fn and IMeta? I don't know. But when I checked a normal function's supers I saw IFn, AFn, and AFunction; and when I checked a vector's I saw only IFn of those three. I also saw IObj, did a .getMethods on it, and the met

Re: any good reason why defrecord/deftype doesn't support java class inheritence?

2011-02-13 Thread Seth
I know that IMeta is used with the (meta) function and with IObj, you can also implement with-meta. And fn? tests for 'true functions' , i.e. only the function created by (fn). Not sure about the rest... -- You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: Best method for storing dynamic data in database

2011-02-13 Thread Seth
not fast, but it works:) any ideas on better code? ;code from http://www.mail-archive.com/clojure@googlegroups.com/msg19378.html ;;saving objects to strings and going back -slow, but it works (import (java.io ByteArrayOutputStream ObjectOutputStream ByteArrayInputStream Objec

Re: Best method for storing dynamic data in database

2011-02-13 Thread Seth
or i could have just used base64:) I love leiningen +maven+central repository! (import (java.io ByteArrayOutputStream ObjectOutputStream ByteArrayInputStream ObjectInputStream) org.apache.commons.codec.binary.Base64) (defn bytes-to-obj "convert string to object" [s]

Re: Newbie: What's your opinion about this Clojure code?

2011-02-13 Thread Nick Wiedenbrueck
Thanks a lot. I'll have to get used to closing all parentheses of a function on a single line, cause this makes finding the right position when editing the code afterwards a little harder. Also now I got the clojure mode for emacs (instead of lisp mode) to get the indentation right. -- You recei

Re: Handling of unsigned bytes

2011-02-13 Thread Rasmus Svensson
To turn a signed byte (-128 to 127) into an unsigned one: (bit-and the-byte 0xff) The byte (for example 0x80, which is negative) will be extended to an int (0xff80) and anded with 0x00ff (and you get 0x0080, which is positive). The javadoc for the methods of DataInput[1] contain form