Re: Mersenne Twister

2010-05-28 Thread Lauri Pesonen
Hi Paul, On 27 May 2010 23:24, Paul Moore wrote: > Can someone recommend a good Mersenne Twister implementation I could > use? A web search finds a number of implementations in Java - > presumably I can use these via Java interop - is that a sensible thing > to do? It is very sensible to use an

Re: autoloading code at repl startup

2010-05-18 Thread Lauri Pesonen
On 11 May 2010 11:59, Lauri Pesonen wrote: > > At least in my setup ~/.clojure/user.clj does not get loaded unless > ~/.clojure is in the JVM classpath. (replying to myself) So I've made this work with swank-clojure-project by adding this to my emacs config: (add-hook 'sw

Re: autoloading code at repl startup

2010-05-11 Thread Lauri Pesonen
On 11 May 2010 10:55, Tassilo Horn wrote: > I think ~/.clojure/user.clj is evaluated on each clojure startup, so you > could add that code there. At least in my setup ~/.clojure/user.clj does not get loaded unless ~/.clojure is in the JVM classpath. > Tassilo -- ! Lauri -- You received thi

autoloading code at repl startup

2010-05-11 Thread Lauri Pesonen
Hi all, How do people autoload code in their repl at startup? I'd like to specify code that would be loaded into each repl that I start with slime. E.g. (use 'clojure.contrib.repl-utils) and (set! *warn-on-reflection* true). Not being able to do this easily means that I don't use e.g. the repl-uti

Re: Clojure Concurrency Screencast Available

2010-04-20 Thread Lauri Pesonen
On 20 April 2010 15:41, Craig Andera wrote: > Yep: that's good advice, although I can't say I find much in emacs to > be "basic", even after using it casually for 20 years :). The one I > tended to use in the tutorial (in case someone saw it flash by in the > minibuffer) is C-x C-e, which I have b

Re: Image scaling libraries. Request for recommendations

2009-12-14 Thread Lauri Pesonen
Hi Albert, 2009/12/14 Albert Cardona : > On Mon, Dec 14, 2009 at 10:08 AM, Lauri Pesonen wrote: >> IIRC Java AWT-based libraries require a windowing system on the >> machine. On Windows this is not a big deal since you're always running >> a windowing system, even on a

Re: variation of time macro

2009-12-14 Thread Lauri Pesonen
2009/12/14 jan : > Shawn Hoover writes: >> I see usages of the time macro that wrap the expression of interest in a call >> to dotimes. Is there any interest in an overload of time that takes an >> additional parameter for a number of iterations, evaluates the expression >> that >> many times, an

Re: Image scaling libraries. Request for recommendations

2009-12-14 Thread Lauri Pesonen
Hi Fred, 2009/12/14 Frédéric Morain-Nicolier : >> As far as I can tell, ImageJ isn't really suited for "headless" tasks, >> which is what I want to do; I want to run some image processing in the >> backend of a web app. I guess I'm going to try JAI first. > > Not sure to understand. By "headless"

Re: Getting Started in Mac OS X Snow Leopard

2009-12-07 Thread Lauri Pesonen
Thanks everyone for the recommendations. 2009/12/4 Steve Purcell : > > Here's what I do (in Cocoa Emacs 23) to make 'option' work the same in Emacs > as in other OS X apps: > >  (setq mac-command-modifier 'meta) >  (setq mac-option-modifier 'none) >  (setq default-input-method "MacOSX") Hmm, I'v

Re: Getting Started in Mac OS X Snow Leopard

2009-12-04 Thread Lauri Pesonen
2009/12/2 Matthew Williams : > Using the Cocoa build of Emacs 23 (http://www.emacsformacosx.com) I > was able to get up and running extremely quickly with Technomancy's > swank-clojure install. This is very much off-topic, but... How do you type ''#' in the Cocoa build of Emacs 23 (I'm on a UK ke

Re: One benefit of having a REPL

2009-11-29 Thread Lauri Pesonen
2009/11/28 Joseph Smith : > Definitely- Even when I'm programming Clojure in NetBeans I always have a > REPL open. In general I like having an interpreter/dynamic environment > running when I'm developing in any language that offers such an environment, > e.g. Python, Groovy (I use groovysh while w

Re: Query regarding `conj'

2009-11-27 Thread Lauri Pesonen
Hi Nipra, 2009/11/27 nipra : > Hi, >  (rest *v1) is equal to *v2 in the below mentioned example. Then why >  `conj' operation on them is returning different things. > > user> (def *v1 [1 2 3 4 5]) > #'user/*v1 > user> (def *v2 [2 3 4 5]) > #'user/*v2 > user> (= (rest *v1) *v2) > true > user> (def

Re: AOT'd namespaces lose their metadata

2009-11-23 Thread Lauri Pesonen
2009/11/23 Phil Hagelberg : > > I noticed an odd bug when working on the help command for leiningen. It > uses docstrings on metadata for help output, but when AOTing the > project, the docstrings (as well as all other metadata) would be > lost. Note that this doesn't happen when metadata is added

Re: swap two elements in an arbitrary collection

2009-11-19 Thread Lauri Pesonen
2009/11/18 Jacek Laskowski : > > user=> (macroexpand '(-> v (assoc i (v j)) (assoc j (v i > (assoc (clojure.core/-> v (assoc i (v j))) j (v i)) > > How to expand the macro in the subform above? You can use clojure.walk/macroexpand-all: (clojure.walk/macroexpand-all '(cond (even? 2) :foo (odd?

Re: swap two elements in an arbitrary collection

2009-11-13 Thread Lauri Pesonen
Hi Mark, 2009/11/13 Mark Tomko : > > I notice you used the '->' macro.  Perhaps I'm a little dense, but I > haven't found the documentation for it to be terribly helpful.  Do you > have simple, succinct explanation for what it does? The -> macro calls the given forms with the return value of prev

Re: Help with anonymous functions

2009-10-25 Thread Lauri Pesonen
Hi John, 2009/10/25 jsrodrigues : > > When I try the following: > user=> (into {} (map #([% (* % %)]) [1 2 3 4])) The #(...) form assumes that the is a function call and thus it is implicitly wrapped in parens. That is, #(+ % %) becomes (fn [x] (+ x x)). So in your code the anonymous function bo

Re: Neophyte question

2009-10-21 Thread Lauri Pesonen
2009/10/21 John Harrop : > Like this? > (def hexchar? #{\0 \1 \2 \3 \4 \5 \6 \7 \8 \9 \A \a \B \b \C \c \D \d \E \e > \F \f}) Yep, that's what I had in mind as well, but I got tired of typing ;-) -- ! Lauri --~--~-~--~~~---~--~~ You received this message beca

Re: Neophyte question

2009-10-21 Thread Lauri Pesonen
Hi Mark, 2009/10/21 Mark Nutter : > > (defn blank? [s] (every? #(Character/isWhitespace %) s)) > user=> (defn hexchar? [c] (re-find #"[0-9A-Fa-f]" c)) > user=> (defn hex? [s] (every? #(hexchar? %) s)) > #'user/hex? > nil > user=> (hex? "a") > # cannot be cast to java.lang.CharSequence (NO_S

Re: Java translation problem

2009-10-09 Thread Lauri Pesonen
2009/10/9 tommy c : > > I'm trying to translate a java lucene indexer to clojure. > This java line is bothersome: >  writer = new IndexWriter(dir, new SimpleAnalyzer(), true, > IndexWriter.MaxFieldLength.UNLIMITED); MaxFieldLength is an inner class in IndexWriter and UNLIMITED is a static field

Re: What does this error mean?

2009-10-09 Thread Lauri Pesonen
2009/10/8 John Harrop : >> java.lang.ClassFormatError: Unknown constant tag 52 in class file >> queries__init (Trial.clj:0) > > Almost certainly, it occurs in some part of the code that works on a class's > bytecodes either directly on disk or in the form of an unstructured Java > byte array; hope

Re: Two minor typos in the cheatsheet

2009-10-02 Thread Lauri Pesonen
Hi, 2009/10/2 Miron Brezuleanu : > > Hello, > > I assume this is about the cheatsheet at http://clojure.org/cheatsheet > > The odd/even typos are in the PDF version. > > Some suggestions: add update-in, assoc-in, get-in in the 'Maps' > section;  Add the ignore-next-form #_ reader macro in the rea

Re: How do I access a Java list element?

2009-09-11 Thread Lauri Pesonen
2009/9/11 Richard Newman : > >>> Where I'm stuck >>> is how to get access to the particle names, as I would in the above >>> line of Java code. > > The final bit, once you have an iterator over particles, would be: > > (fn [p] (.getName p)) > > To avoid the use of reflection, you might want explic

Re: How do I access a Java list element?

2009-09-11 Thread Lauri Pesonen
2009/9/11 carey : > (. dataLoader  getEnvironmentParticleSet) > > But what I want is to go through the list that this method returns and > get the name of each particle in the list. > > I now that in Java this would be (inside some form of loop) > > dataLoader.getEnvironmentParticleSet().get(i).ge

Re: minor grievance with arithmetic on characters

2009-09-11 Thread Lauri Pesonen
2009/9/11 Rich Hickey : > > We should fix the doc. Patch welcome for this. Ticket #189 - I've provided a patch following Stephen's suggested doc string. > Rich -- ! Lauri --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: Two possible additions: non-reflective classobject calls & support for map-conj on arrays

2009-09-01 Thread Lauri Pesonen
Hi Karl, 2009/8/31 Krukow : > 2) I can do: > user> (into {} '([:k :v])) > {:k :v} > > This works for two-element vectors. However, I cannot do the same for > two-element arrays: > > user> (def str_array (.split "k=v" "=")) > #'user/str_array > user> (into {} (list str_array)) > ; Evaluation abor

Re: help with clojure + slime

2009-08-30 Thread Lauri Pesonen
2009/8/30 mlm : > (setq swank-clojure-extra- > classpaths >      (list > "/opt/clojure/clojure-contrib/clojure-contrib.jar:/opt/clojure/swan\ > k-clojure/swank/swank.clj")) Try changing the swank-clojure bit to point to the directory rather than the .clj file, i.e. either /opt/clojure/swank-clo

Re: Newbie - the method I cannot call

2009-08-25 Thread Lauri Pesonen
Hi, 2009/8/25 icemaze : > (.open sdl format (* 48000 2 2)) Add a type hint to the sdl operand: (.open #^SourceDataLine sdl fmt (* 48000 2 2)) -- ! Lauri --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure"

Re: Overflow by (inc) and (dec) at integer boundaries?

2009-08-20 Thread Lauri Pesonen
Hi Rich, 2009/8/19 Rich Hickey : > > On Fri, Aug 14, 2009 at 6:28 AM, David Powell wrote: >> >> >>> user=> (.getClass (+ 1 Integer/MAX_VALUE)) >>> java.lang.Long >> >> Also, >> >> user=> (def i (Integer/MAX_VALUE)) >> >> user=> (class (+ 1 i)) >> java.lang.Long >> >> user=> (class (inc i)) >> jav

Re: Augmenting the defn attr-map

2009-08-13 Thread Lauri Pesonen
2009/8/12 Chas Emerick : > > On Aug 12, 2009, at 3:19 PM, Mark Volkmann wrote: > >> I didn't release it was valid to define names with colons in them. >> Maybe that shouldn't be allowed. I'd like to be able to specify type >> hints using UML-like syntax like the second example from Chas which >> w

Commenting Code (Was: Re: Clojure as a First Language)

2009-08-09 Thread Lauri Pesonen
2009/8/8 Luc Prefontaine : > I totally agree no comments is not good at all but JavaDoc style comments in > Clojure ? I pray you all, please stay away of it : I was quite taken by this scheme style guide recently: http://mumble.net/~campbell/scheme/style.txt While I don't agree with all th

Re: Package manager proposal

2009-08-07 Thread Lauri Pesonen
2009/8/6 James Reeves : > > On Aug 6, 8:31 pm, Howard Lewis Ship wrote: >> I'm cringing at the sight of XML here. > > XML is frequently overused, but it is a good format for representing > dense, structured data. For example: > > >   > > > Compared to: > > {:type :repository >  :name "third-par

Re: a better reductions?

2009-08-07 Thread Lauri Pesonen
Hi Stuart, 2009/8/6 Stuart Halloway : > > On the plus side, it appears to be faster (as collections grow large), > and it doesn't "cheat" by introducing an atom. On the minus side it > isn't as pretty as the one in contrib. While maybe not as pretty as the one in contrib, it's not a monster eith

Re: Package manager proposal

2009-08-06 Thread Lauri Pesonen
Hi Meikel, 2009/8/5 Meikel Brandmeyer : > > Well, this is independent of whether you have a C or Java > library. You can install each C library in its own directory > and tell the linker to look there. Then you have basically > a .jar like setup: If you don't tell the linker the right directory >

Re: Clojure as a First Language

2009-08-06 Thread Lauri Pesonen
Seth, 2009/8/6 Seth : > > I hope that learning a Lisp first is a good idea for novice > programmers, because I intend to inflict Clojure on my poor children. > (They didn't take to http://scratch.mit.edu/ and Google's rehash of > BASIC is a non-starter). There was a post recently on LtU about a

Re: Package manager proposal

2009-08-05 Thread Lauri Pesonen
2009/8/4 Meikel Brandmeyer : > > I think, "clojure context" is underestimating things. The high > integration > of external Java libraries makes it necessary that such dependencies > can be handled in the same way. Agreed. I was actually going to write that whatever approach is chosen it must be

Re: Package manager proposal

2009-08-04 Thread Lauri Pesonen
2009/8/4 James Reeves : > > On Aug 4, 12:51 pm, Krešimir Šojat wrote: >> In your project you would create standard ivy.xml and ivysettings.xml >> files as described on Ivy site. Download Ivy (and Ant jars if you will >> create or use Packagers). After that you can retrieve your >> dependencies fr

Re: fibonacci sequence using lazy-cat

2009-07-29 Thread Lauri Pesonen
Hi swaroop, 2009/7/29 swaroop belur : > > fibonacci sequence using lazy-cat : > (def fibs (lazy-cat [0 1]   (map + fibs (rest fibs > > I am trying to understand how this works ..not sure i fully comprehend > it. > > Can anyone please explain how clojure evaluates this. I'll do my best, but I

Re: simple debugging utility

2009-03-24 Thread Lauri Pesonen
2009/3/24 Mark Volkmann : > > Thanks! It looks like I don't need the let now. Does a macro have to > evaluate to one form? For example, this works, but it seems I can't > drop the do. > > (defmacro dump [expr] >  `(do >     (print (quote ~expr)) >     (println " =" ~expr))) How about: (defmacro

Re: Queues

2009-02-03 Thread Lauri Pesonen
2009/2/3 Konrad Hinsen : > > Is there any reason to prefer lists over vectors or vice versa for > implementing queues? It seems that for both lists and vectors, adding > and removing at one end (front for lists, end for vectors) is cheap, > whereas it is expensive at the other end. For queues you

Re: DISCUSS: replace (rand)

2008-12-02 Thread Lauri Pesonen
2008/12/2 Stuart Halloway <[EMAIL PROTECTED]>: > > Cool, that's much better. Can we establish that all (or all important) > Java 5+ VMs use AtomicLong in next? While compare-and-swap is a lot better than a mutex, it's still not free. IIRC a CAS is one (or maybe two) order(s) of magnitude more exp