Re: Which branch of clojure-hadoop to use?

2011-02-06 Thread Alex Ott
Hello

I'm not working actively on clojure-hadoop, so maybe eslick's and clizzin's
forks could be more advanced (although I hadn't looked onto changes).

I think, that fragmentation of libraries is not so good thing, so I invite
everybody who wants to participate in development to join mailing list
https://groups.google.com/group/clojure-hadoop and I can give commit rights
to repository

Benny Tsai  at Fri, 4 Feb 2011 20:59:00 -0800 (PST) wrote:
 BT I have a bunch of older computers sitting at home, and thought I'd put
 BT them to use for experimenting with clojure-hadoop and swarmiji.
 BT However, I can't figure out which branch of clojure-hadoop to use.
 BT Stuart Sierra's branch looks like the canonical one, but hasn't been
 BT updated since March 2010.  alexott's branch looks to be the most
 BT frequently updated, but there are also more recent branches from
 BT eslick and clizzin.  If someone could shed light on this situation,
 BT that'd be greatly appreciated!



-- 
With best wishes, Alex Ott, MBA
http://alexott.blogspot.com/http://alexott.net/
http://alexott-ru.blogspot.com/
Skype: alex.ott

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Time/size bounded cache?

2011-02-06 Thread Saul Hazledine
On Feb 6, 12:32 pm, Eugen Dück eu...@dueck.org wrote:
 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 athttp://kotka.de/blog/2010/03/memoize_done_right.html

 It presents a bunch of different implementations, detailing whats good/
 bad about each of them.

If you need to move function calls out of the cache there is cache-dot-
clj which consists of minor changes to memoize done right:

https://github.com/alienscience/cache-dot-clj

Saul

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any news on pull requests?

2011-02-06 Thread Laurent PETIT
Hi Eugen,

2011/2/6 Eugen Dück eu...@dueck.org:
 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
 criticism of our beloved dictator and I hope he'll serve many more
 terms. As long as he doesn't torture his people (like force them into
 signing CAs ;)

 Back to the git pull request question - nobody seems to know anything
 about it, but that issue should not be related to legal issues, if
 clojure maintainers pull only stuff from CA signers, right?

Maybe there's a problem with this pull request, in that the act of
bringing the code into the open source project is then done by the
maintainer itself. The guarantees of pulling the exact changest the
pull requester wanted to be incorporated are less clear than if the
contributor explicitly sends the bits he wants to contribute.

But maybe I'm wrong.

Cheers,

-- 
Laurent

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any news on pull requests?

2011-02-06 Thread Eric Lavigne
 Back to the git pull request question - nobody seems to know anything
 about it, but that issue should not be related to legal issues, if
 clojure maintainers pull only stuff from CA signers, right?

Be careful about applying the word should to legal issues. I'm
inclined to just trust Rich and Clojure/core regarding what is legally
acceptable until I've done a similar amount of legal research myself
(which will probably never happen).

Also, anyone who wants to improve the patch process should first have
enough experience with it to understand what, if anything, is wrong
with it. If the patch process were a significant inconvenience, I
would expect to see the issue raised on the clojure-dev mailing list
by people who have actually been through that process. Instead, it
seems that the issue is raised only by people who haven't actually
tried it.

As for the need to physically mail a CA... I wish to contribute to
Clojure, and I was willing to spend a lot more than two hours on
making it happen (related to my employer's intellectual property
policy). I can certainly understand if some potential contributors
aren't willing to spend two hours hiking in the snow, after waiting
for good weather of course. On the other hand, it seems like much more
time than that is spent discussing this issue on a mailing list. Why
not just send the letter and get it over with?

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: overriding seq in defrecord

2011-02-06 Thread Seth
The problem is that defrecord explicitly defines the interface you are
trying to implement, so you are effectively attempting to declare the
interface twice. And since clojure.lang.seqable isnt a protocol, you
cant redefine it with extend. So, you will have to rewrite the
defrecord macro or similar that implements what defrecord does, except
it will actually look at your interfaces to see if you are attempting
to implement the same one, and then use the users interface if so.

Heres an example of a custom deftype i wrote which basically
reimplements defrecord + some more. It is an 'AtomHash', which means
it acts like a hash map (i.e. like a record),
but instead of accessing the record slots directly, it accesses an
atom, which itself contains the map. I never figured out how to make
(merge (atom-hash {:a 2}) {:a 4}) return an atom-hash, but oh well.
Actually, i think the new clojure 1.3 has internal protocols for
merge. Anyways, from this, you can build  a macro which replaces user
defined sequences with any defaults. Or you could just use it as a
template.

(deftype AtomHash [val]
  Object
  (toString [this] (str AtomHash  @val ))
  clojure.lang.IPersistentMap
  clojure.lang.ILookup
  (valAt [this key] (get @val key))
  (valAt [this key notfound] (get @val key notfound))
  clojure.lang.IPersistentCollection
  (count [this] (.count @val))
  (empty [this]  {})
  (cons [this e]  (.cons @val e))
  (equiv [this gs] (or (identical? this gs)
   (when (identical? (class this) (class gs))
 (= val (.val gs)
  clojure.lang.Associative
  (containsKey [this k] (or (and (get @val k) true) false))
  (entryAt [this k] (get @val k))
  clojure.lang.Seqable
  (seq [this] (seq @val))
  clojure.lang.IPersistentMap
  (assoc [this k g] (assoc @val k g))
  (assocEx [this k g] (assoc this k g))
  (without [this k] (.without @val k))
  clojure.lang.IDeref
  (deref [this] @val))
;;REPLACE namespace with implementation namespace
(defmethod print-dup AtomHash [o w]
  (.write w #=(util/atom-hash ) (print-dup @o w) (.write w )))

(defmethod clojure.core/print-method AtomHash [o w]
  (.write w (.toString o)))

(defn atom-hash
  ([] (atom-hash {}))
  ([a] {:pre [(map? a)]} (AtomHash. (atom a


;;examples
(let [{:keys [a b]} (atom-hash {:a 2})] (list a b))

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: overriding seq in defrecord

2011-02-06 Thread Seth
I also found it useful to define my own clojure.core. This is because
i wanted swap! and reset! to work on my AtomHash. So i did something
like this, using clj-nstools.
http://code.google.com/p/clj-nstools/
ns+ is sort of slow for large projects, but im sure that can be
improved.

(ns clj.core
  (:refer-clojure :exclude [swap! reset!])
  (:import clojure.lang.APersistentMap java.io.Writer))

(defmulti swap! (fn [a  args] (class a)))
(defmethod swap! clojure.lang.Atom [ args]
  (apply clojure.core/swap! args))
(defmulti reset! (fn [a  args] (class a)))
(defmethod reset! clojure.lang.Atom [ args]
  (apply clojure.core/reset! args))

and then, using ns+ for another ns, we can do at the top of our file

(clojure.core/use 'nstools.ns)
(ns+ my.ns
  (:clone clj.core)
  anything else here )

Too bad something like ns+ isnt included in clojure core, its quite
useful

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Time/size bounded cache?

2011-02-06 Thread Seth
do you really need that? How about an infinite lazy sequence?
(defn infinite [arg]
  (lazy-seq
   (Thread/sleep 2000) ;;simulate 2 second retrieval time
   (concat (for [i (range 0 arg)]
 i) (infinite arg

(def a (infinite 3))
(first a) ;;= sleep 2 seconds, return 0
(take 3 (filter #(= % 2)  a)) ;;wait a bit and return 3 twos

(loop [i 0 a (infinite 3)] ;;wait a bit, process 3 twos, and return
done
  (cond
   (= i 3) done
   (= (first a) 2) (recur (+ i 1) (rest a))
   true (recur i (rest a

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any news on pull requests?

2011-02-06 Thread Fogus
 Not every potential contributor lives in downtown
 Megalopolis, Coastal State, USA.

Agreed, but you must see that your particular case lays at the
extreme.

I'm of the opinion that if someone is inclined to contribute, then
they will not be deterred by the cost of a postage stamp -- par avion
or not.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Importing defprotocol and deftype

2011-02-06 Thread trptcolin
Forgive me if I'm misunderstanding, but you don't need to import a
protocol to use it.  If you need to actually get ahold of the protocol
(say, to implement another deftype/defrecord), you can just use
`require` or `use` to get ahold of it:

(ns stuff
  (:use [com.example-ns :only [IFoo])
  (:import [com.example-ns Foo]))

Then inside that ns, you can just refer to IFoo and Foo.  I'm
surprised that the underscored version of the import works for a
protocol - I've never seen anyone use that before.  I wonder if it's
just an oversight on my part or if that's a non-recommended use of
import...

Micah Martin just showed me a behavior very similar to this recently,
and since then I'd been thinking of protocols more like normal Clojure
data structures, and deftypes/defrecords more like Java classes.
Confirming that, if I look at the type of IFoo, it is a
clojure.lang.PersistentArrayMap, and Foo is a java.lang.class.

Colin



On Feb 5, 1:20 pm, Shantanu Kumar kumar.shant...@gmail.com wrote:
 When I declare using defprotocol:

 (defprotocol IFoo
   (bar [this] some doc))

 and then using deftype:

 (deftype Foo
   IFoo
     (bar [this] from Foo::bar))

 I noticed there is an interesting difference in the way I need to
 import them in another namespace:

   (:import
     (com.example_ns IFoo)  ; importing Foo here gives error (notice
 underscore)
     (com.example-ns Foo))  ; importing IFoo here gives error (notice
 dash)

 Can somebody explain the rationale behind this? The dash character is
 not valid inside a Java package names so a protocol not supporting it
 is understandable. But when I deftype something, is it not supposed to
 be consumed from within Java-the-language?

 Shantanu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any news on pull requests?

2011-02-06 Thread Ken Wesson
On Sun, Feb 6, 2011 at 3:55 PM, Fogus mefo...@gmail.com wrote:
 Not every potential contributor lives in downtown
 Megalopolis, Coastal State, USA.

 Agreed, but you must see that your particular case lays at the
 extreme.

Does it really? 20% of the population of the US still lives outside of
major cities. That's not a majority but it's hardly an extreme
minority either.

 I'm of the opinion that if someone is inclined to contribute, then
 they will not be deterred by the cost of a postage stamp -- par avion
 or not.

I mentioned other inconveniences than the cost of a postage stamp.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Time/size bounded cache?

2011-02-06 Thread Fogus
 A while back the discussion on the bounded memoize

A truly classic thread, immortalized in JoC and at 
https://github.com/fogus/anamnesis

:-)

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any news on pull requests?

2011-02-06 Thread Fogus
 Does it really? 20% of the population of the US
 still lives outside of major cities. That's
 not a majority but it's hardly an extreme
 minority either.

I'm sorry, I was referring more to your description of a treacherous
hike through a vast winter wonderland; not of the hordes of potential
Clojure contributors living in the Appalachian mountains.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any news on pull requests?

2011-02-06 Thread Eric Lavigne
 Same here. In my case, snail-mail would mean a 2.5km hike through a
 freezing winter wonderland to the nearest mailbox that's used to send
 rather than being receive-only. So, 5 km there and back. It could
 easily take over two hours and might even be dangerous depending on
 the weather.

This may be a solution. (Found via web search - I've never actually used it.)

 http://www.postful.com/

For $1, they will convert an email or PDF into an old fashioned letter
and put it in the mail for you.

If you try this service, I'm interested in hearing how well it works.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any news on pull requests?

2011-02-06 Thread Ken Wesson
On Sun, Feb 6, 2011 at 4:44 PM, Eric Lavigne lavigne.e...@gmail.com wrote:
 Same here. In my case, snail-mail would mean a 2.5km hike through a
 freezing winter wonderland to the nearest mailbox that's used to send
 rather than being receive-only. So, 5 km there and back. It could
 easily take over two hours and might even be dangerous depending on
 the weather.

 This may be a solution. (Found via web search - I've never actually used it.)

     http://www.postful.com/

 For $1, they will convert an email or PDF into an old fashioned letter
 and put it in the mail for you.

 If you try this service, I'm interested in hearing how well it works.

If a snail-mail generated that way would be acceptable for submitting
a CA, I can't fathom why a fax or an e-mail direct to Hickey (bearing
a scanned signed written document) wouldn't also qualify.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any news on pull requests?

2011-02-06 Thread Mike Meyer
On Sat, 5 Feb 2011 20:42:54 -0500
Christopher Petrilli petri...@amber.org wrote:
 On Sat, Feb 5, 2011 at 1:23 PM, Mike Meyer
 mwm-keyword-googlegroups.620...@mired.org wrote:
  On Sat, 5 Feb 2011 00:09:41 -0500
  Christopher Petrilli petri...@amber.org wrote:
  For example, the following projects REQUIRE contributor agreements, in
  writing, signed and either scanned or on paper, prior to accepting any
  patches or commits:
 
  - Free Software Foundation
  - Apache, and everything under it
  - Python
  I'm sorry, I'm going to call foul on this. I've contributed to Python
  without ever signing a CA. And the current developers guide page
  doesn't have anything on it about needing to sign a CA.
 I do not know when you contributed, or whether it was before this
 period, but from

Certainly possible. My largest contributions were docs, which don't
ship with Python and would be excluded.

 http://wiki.python.org/moin/PythonSoftwareFoundationLicenseFaq:
 
  If your code is going to end up in Python or the standard library, the PSF 
  will require you to:
* License your code under an acceptable open source license. These 
  currently include only the Academic Free License and the Apache License 
  2.0, although this list may be expanded in the future. (No, the PSF License 
  is not acceptable; see below)
* Fill out and submit a contributor agreement.
 
 Perhaps they exclude some small amount of code in the form of patches,
 but it certainly applies to libraries, etc. You can find the
 contributor agreement here:
 http://www.python.org/psf/contrib-form.html It's not that different
 than the one for Clojure. Again, I'm not arguing whether it's a good
 thing or not, simply that it's actually not as unheard of as people
 think, nor is it poorly founded in US legal precedent.

I find it odd that they don't mention this on the Developers Guide at
http://www.python.org/dev/ or the developers FAQ at
http://www.python.org/dev/faq/. Possibly this is a reflection of
reality, in that most contributions will be small patches or docs that
don't ship, and they don't enforce it until they want to include a
library. Or maybe this was planned but never actually happened. I know
that it's never been talked about on any of the Python lists I've hung
out on.

  Seriously, the snail-mail requirement is the only one that's really
  objectionable. Most places are quite happy with a scanned image of the
  signed document (i.e. - the Chickasaw nation for my citizenship
  papers).
 Then perhaps someone can offer to Rich to accept the scanned copies
 and deal with them? One of the joys of an open source project is not
 just contributing code, but helping out with the administrative
 overhead of running a project.

Exactly what has to happen to a PDF that was emailed to whoever would
have gotten the snail-mail copy, beyond printing and then treating
like the snail-mail'ed one?

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: Textmash - another IDE for Clojure

2011-02-06 Thread Laurent PETIT
Hi Olek,

I haven't found time to work more on it lately, but checked the
current status of the codebase today.
It appears that all new work is going into Textmash2, a rewrite in
Clojure, if I understand it correctly ?

I have some questions:

* Is your intent to replace eventually the java version with the
clojure version ? If so, how do you deal with the concern of quick
startup time ?
* If I find time to try to add paredit.clj support for it, is it worth
continuing what I've started on the java branch, or should I hack on
the clojure branch ?

Cheers,

-- 
Laurent

2011/1/23 Olek aleksander.nas...@gmail.com:
 Yes, make a branch.
 I seen many people are using leiningened, so it is a good (main
 stream) choice, especially that your parts of code are written in
 Clojure.

 The layout of menus is made in pl/olek/textmash/menu/
 WorkspaceMenu.java.

 I have also started TextMash2 which is going to be entirely written in
 Clojure, it is going to be written - 20 minutes a day, mainly in
 fundamental (proof of concept) parts so It will be easier to other to
 add/fullfill project with new features.


 On 23 Sty, 20:49, Laurent PETIT laurent.pe...@gmail.com wrote:
 2011/1/23 Olek aleksander.nas...@gmail.com

  I have added you to committers group, so you can commit your work.
  Later I will switch to github since SVN with its central repository
  scenario is not very useful in situation where I'm lack of time.

 OK, thanks.

 What I've achieved is more a proof of concept right now. Maybe I should
 put it in a branch.
 I'll quickly describe what I'm talking about, so you can choose:

   * I've leiningened the project. Maybe I could mavenize it instead.
 What are your guts here ?
   * I've leiningened it to test the mavenization, on my side, of
 paredit.clj.
   * paredit.clj uses clojure and clojure contrib. So the feature currently
 shows a delay when it is first invoked. Since the point of my demo was not
 clojure integration but paredit.clj integration, I've not tried to make this
 happen in the background, etc. To the contrary, I've tried to compact the
 proof of concept code as much as possible in one place, so it can be
 easily spotted and reviewed.
   * Currently, I've just demonstrated the raise over sexpr command I
 described in an earlier post in this same thread.

 What I've not been able to achieve (but I admit I haven't spent too much
 time right now on it) is how to make the command appear in the menu. I
 thought at first that it was derived from the actions map in the
 TextEditor class, but the layout of the menus must live somewhere else ...
 If you can help me spot the right place ?

 I also still have to finish proper bundling of paredit.clj in the first
 place, half done and should not last 'til the end of this week.

 Cheers,

 --
 Laurent




 --
 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 your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Time/size bounded cache?

2011-02-06 Thread Bill James
On Feb 6, 2:08 pm, Seth wbu...@gmail.com wrote:

 (filter #(= % 2)  a)

Another way:

(filter #{2}  a)

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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

2011-02-06 Thread Bill James
On Feb 3, 12:22 am, Andy Fingerhut andy.finger...@gmail.com wrote:
 I've done a pass through most of the Clojure programs on the shootout  
 web site recently, making some of them faster, and choosing -Xmx  
 command line arguments when running them to keep the memory usage down  
 to a reasonable level -- not always the smallest heap size that works,  
 mind you -- just one that avoids exorbitantly large memory usage.

 http://shootout.alioth.debian.org

 The Clojure program for the fasta problem, with source code, AOT  
 compilation command, and execution command given on this web page:

 http://shootout.alioth.debian.org/u32/program.php?test=fastalang=clo...

 still takes about 6x to 8x more time than the best Java 6 -server  
 program here, depending upon which of the four machines it is run on:

 http://shootout.alioth.debian.org/u32/program.php?test=fastalang=jav...

 I'm sure the Clojure program can be made faster, e.g. by doing fewer  
 calls to write to the output file, with more bytes per call.  Most of  
 the time seems to be file writing and generating random numbers in gen-
 random!, at least on my systems where I've done testing and  
 profiling.  I'm also seeing a fair amount of time spent in calls to  
 java.lang.Double.valueOf, according to the built-in profiler that  
 comes with the Hotspot JVM.

 Note: The web site is Clojure 1.2 only right now, so don't expect a  
 tweaked-out program using things that only work in Clojure 1.3 to work  
 there yet.


This program is considerably faster on my computer:


(set! *warn-on-reflection* true)


(def *width* 60)
(def *lookup-size* 222000)


(def *alu* (str GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG
GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA
CCAGCCTGGCCAACATGGTGAAAGTCTCTACTAT
ACATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA
GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG
AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC
AGCCTGGGCGACAGAGCGAGACTCCGTCTCA))

(def *codes* acgtBDHKMNRSVWY)

(def *iub* [0.27 0.12 0.12 0.27 0.02 0.02 0.02 0.02
0.02 0.02 0.02 0.02 0.02 0.02 0.02])

(def *homosapiens* [0.3029549426680 0.1979883004921
0.1975473066391 0.3015094502008])



(defn find-index [f coll]
  (first (keep-indexed #(if (f %2) %1) coll)))




(def random-seed (int-array [42]))
(let [ IM (int 139968)
   IA (int 3877)
   IC (int 29573)
   scale (double (/ *lookup-size* IM))
 ]
  (defn gen-random-fast []
(let [ new-seed (unchecked-remainder (unchecked-add (unchecked-
multiply
 (aget (ints random-seed) 0) IA) IC) IM) ]
  (aset (ints random-seed) 0 new-seed)
  (int (* new-seed scale)



;; Takes a vector of probabilities.
(defn make-cumulative [v]
  (vec (map #(reduce + (subvec v 0 %))  (range 1 (inc (count v))

;; Takes a vector of cumulative probabilities.
(defn make-lookup-table [v]
  (let [ lookup-scale (- *lookup-size* 0.0001)
 tmp (map
   (fn [n] (find-index #(= (/ n lookup-scale) %) v))
   (range *lookup-size*)) ]
(int-array tmp)))



(defn cycle-bytes [source source-size n  ^java.io.BufferedOutputStream
ostream]
  (let [ source-size (int source-size)
 width (int *width*)
 width+1 (int (inc width))
 buffer-size (int (* width+1 4096))
 buffer (byte-array buffer-size (byte 10))
 next-i (fn[i]
   (unchecked-remainder (unchecked-add (int i) width) source-
size))
 next-j (fn[j]
(let [j (+ j width+1)]
  (if (= j buffer-size)
(do  (.write ostream buffer)  0)
j)))
   ]
(loop [i (int 0)  j (int 0)  n (int n)]
  (System/arraycopy  source i buffer j width)
  (if ( n width)
(recur (int (next-i i)) (int (next-j j)) (- n width))
(do
  (aset buffer (+ j n) (byte 10))
  (.write ostream buffer 0 (+ j n 1)))



(defn fasta-repeat [n  ^java.io.BufferedOutputStream ostream]
  (let [ source (.getBytes (str *alu* *alu*)) ]
(cycle-bytes source (count *alu*) n ostream)))



(defn fasta-random [probs n  ^java.io.BufferedOutputStream ostream]
  (let [ codes (.getBytes (str *codes*))
 lookup-table (ints (make-lookup-table (make-cumulative
probs)))
 width (int *width*)
 buffer (byte-array 222000)
 seeds  (int-array  222000)
 first-seed (aget (ints random-seed) 0)
   ]
(loop [i (int 0)]
  (aset seeds i (aget (ints random-seed) 0))
  (aset buffer i
(aget codes
  (aget lookup-table
(gen-random-fast
  (if (= (aget (ints random-seed) 0) first-seed)
(do
  (System/arraycopy  buffer 0  buffer (inc i)  *width*)
  (cycle-bytes buffer (inc i) n ostream)
  (aset (ints random-seed) 0 (aget seeds (mod n (inc i)
(recur (unchecked-inc i))



(defn write-line [s 

Re: Any news on pull requests?

2011-02-06 Thread Eric Lavigne
 For $1, they will convert an email or PDF into an old fashioned letter
 and put it in the mail for you.

 If a snail-mail generated that way would be acceptable for submitting
 a CA, I can't fathom why a fax or an e-mail direct to Hickey (bearing
 a scanned signed written document) wouldn't also qualify.

That's a good point. I don't know where the line is on this issue.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: Textmash - another IDE for Clojure

2011-02-06 Thread Shantanu Kumar
 * Is your intent to replace eventually the java version with the
 clojure version ? If so, how do you deal with the concern of quick
 startup time ?

An idea: jEdit optionally lets you start a background server during
system startup so that firing up jEdit can be fast later. Maybe
something similar can help?

Regards,
Shantanu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en