Re: Dividing list by predicate

2010-05-23 Thread Michael Gardner
Thanks for the tips, guys. I'll go with seq-utils/separate, as I don't really need the extra performance; it was more of an aesthetic thing. Still, it seems like separate should be written to evaluate its predicate only once for each item in the list. -- You received this message because you a

weird repl + classloader behavior

2010-05-23 Thread Brent Millare
Why does dereferencing clojure.lang.Compiler/LOADER change in different calls in the repl? For example, Clojure 1.2.0-master-SNAPSHOT user=> (dotimes [x 10] (java.lang.Thread/sleep 500) (prn (.deref (clojure.lang.Compiler/LOADER # # # # # # # # # # nil user=> (dotimes [x 10] (java.lang.Thread/

NulPointerException when calling 'println' in 'if'

2010-05-23 Thread Timothy Washington
I wave a strange NullPointerException when I call (println "Some string"). It seems similar to this problem on Stackoverflow, but the 'do' solution doesn't seem to work for me

Re: any downside to putting everything into CLASSPATH?

2010-05-23 Thread Stuart Campbell
> > JVM newbie question here. Aside from the clojure & clojure-contrib jars, is > there any downside to automatically setting up my CLASSPATH so that all jars > on my box are available - even if I might only be using 1 or 2 for the code > I'm working on at the moment? > The problem with such a sch

Re: do clojure and la(tex) have something in common ?

2010-05-23 Thread Mike Meyer
On Sun, 23 May 2010 06:55:50 -0700 (PDT) faenvie wrote: > today i read this statement in a blog-post: > > "... remarkably (La)TeX is much better suited for composing and > distributing most types of documents than any other modern > word processor on the market that I am aware of. Just like > pr

Re: Dividing list by predicate

2010-05-23 Thread gammelgedden
I implemented something like that. my goal was to avoid the predicate being called twice, but apart from that it has some overhead. (defn- apl-compr- "the apl compress operator: 0 1 1 0 1 / 1 2 3 4 5 -> 2 3 5 implemented in clojure (apl-compr- [false true true false true] '(1 2 3 4 5)) -> (2

Re: Having trouble with a genetic program

2010-05-23 Thread Lee Spector
This will be easier if you use a utility to insert a new subtree at a particular position in an existing subtree -- that is, to return a new subtree with the insertion. Then to do mutation just use this utility to insert a newly generated subtree at some randomly chosen index. Following is cod

Re: Using Java's 'this' keyword

2010-05-23 Thread Timothy Washington
Right you are. Cheers Tim On Sun, May 23, 2010 at 4:51 PM, Jay Fields wrote: > I believe the error message is because there is no apply() method that > takes no arguments, and (.. node getLoad apply this ) is trying to do this > (in java): node.getLoad().apply().this() > > I think you want (..

Re: Using Java's 'this' keyword

2010-05-23 Thread Jay Fields
I believe the error message is because there is no apply() method that takes no arguments, and (.. node getLoad apply this ) is trying to do this (in java): node.getLoad().apply().this() I think you want (.. node getLoad (apply this)) Cheers, Jay On May 23, 2010, at 4:39 PM, Timothy Washing

Using Java's 'this' keyword

2010-05-23 Thread Timothy Washington
Hi there, I'm trying to get Java's '*this*' passed as a variable to clojure's sugared Java integration. All's fine until the end of line 43. I've tried '*this*' and *(proxy-super)*, on a lamb, but no dice. 42 (if (not= (. node getLoad ) nil) ;; Java equivalent - *if(node.getLoad()

Re: finding combinations given a coll and selection of n

2010-05-23 Thread Kasim
Thanks, how could I miss checking the contrib library! I was actually trying to implement the combination logic that I did in Scala a while back. Here is the scala code: object Combination { def combine[T](n:Int,list:List[T]):List[List[T]]= n match { case 0 => List(List())

Re: Dividing list by predicate

2010-05-23 Thread B Smith-Mannschott
On Sun, May 23, 2010 at 21:21, Michael Gardner wrote: > I need to use a predicate to divide one list into two, one containing all > values for which the predicate is true, and the other with all remaining > values. I can do this easily by filtering twice, once with the predicate and > once with

Re: Dividing list by predicate

2010-05-23 Thread Joost
On May 23, 9:21 pm, Michael Gardner wrote: > I need to use a predicate to divide one list into two, one containing all > values for which the predicate is true, and the other with all remaining > values. I can do this easily by filtering twice, once with the predicate and > once with its comple

Dividing list by predicate

2010-05-23 Thread Michael Gardner
I need to use a predicate to divide one list into two, one containing all values for which the predicate is true, and the other with all remaining values. I can do this easily by filtering twice, once with the predicate and once with its complement, but is there some core or contrib function tha

do clojure and la(tex) have something in common ?

2010-05-23 Thread faenvie
today i read this statement in a blog-post: "... remarkably (La)TeX is much better suited for composing and distributing most types of documents than any other modern word processor on the market that I am aware of. Just like programming languages tend to converge towards Lisp because it got thing

Re: reducing multiple sets

2010-05-23 Thread mikel
Thanks - I can see I have still got a way to go. mike On May 23, 2:38 am, Michael Gardner wrote: > On May 22, 2010, at 10:00 AM, mikel wrote: > > > Trying to get from here: > > #{#{[3 2] [5 4] [3 3] } #{[4 3] [5 4] [3 3] } #{[3 2] [2 2] [3 3] } } > > to here: > > #{[3 2] [5 4] [4 3] [2 2] [3 3] }

any downside to putting everything into CLASSPATH?

2010-05-23 Thread Imran Rafique
JVM newbie question here. Aside from the clojure & clojure-contrib jars, is there any downside to automatically setting up my CLASSPATH so that all jars on my box are available - even if I might only be using 1 or 2 for the code I'm working on at the moment? Does the jvm do any expensive initialisa

Having trouble with a genetic program

2010-05-23 Thread krsnewwave
Hello everyone! I am having trouble with genetic programming. I am trying to construct a random population of trees representing functions. The following is how I do my random trees: (defn makerandomtree-10 [pc maxdepth maxwidth fpx ppx] (if-let [output (if (and (< (rand) fpx) (> maxdepth 0))

Re: Datatypes and Protocols update

2010-05-23 Thread Pedro Teixeira
On Apr 27, 9:45 am, Rich Hickey wrote: > On Apr 27, 2010, at 3:20 AM, Mark Engelberg wrote: > > > > > > > Watching Stuart's tutorial, it looks like the automaticfactory > > functions for deftypes have gone away (I'm still working with Clojure > > 1.1, so haven't had a chance to try the latest cha

Re: Coercing a map to a record

2010-05-23 Thread Pedro Teixeira
On May 22, 12:03 am, Ben Mabey wrote: > James Reeves wrote: > > Hi folks, > > > I've been experimenting with the new type system in Clojure 1.2, but > > I've hit something of a problem. If I define a record: > > > user=> (defrecord Foo []) > > user.Foo > > > Then I can coerce a map into a type Fo

Re: Error when tried to compile with C-c C-k in emacs.

2010-05-23 Thread Joost
On May 18, 9:38 pm, Robbie Vanbrabant wrote: > - use slime-connect and say yes on this: versions differ: nil (slime) vs. > 20100404 (swank) continue? > - works > > For completeness, I started from an emacs-starter-kit installation and then > installed swank-clojure and SLIME using ELPA. Removing s

Problem using :require :as

2010-05-23 Thread borgees
I'm trying to use the units library but am running into issues testing the example posted here: http://onclojure.com/2010/03/23/computing-with-units-and-dimensions/ I've reproduced the issue in leiningen My example is a file called helloworld.clj: (clojure.core/use 'nstools.ns) (ns+ helloworld

Re: My first clojure program - A swing app to display graphs

2010-05-23 Thread Meikel Brandmeyer
Hi, On Sat, May 22, 2010 at 09:09:18PM -0700, enjoying the view wrote: > Who's in charge of swing-utils? I just thought they might like to add > the add-component-listener to the package. Stephen C. Gilardi. scgilardi at gmail However you'll have to sign a CA before you are allowed to contribut

Re: Error when tried to compile with C-c C-k in emacs.

2010-05-23 Thread Ramakrishnan Muthukrishnan
On Sun, May 23, 2010 at 10:08 AM, Chris McClellen wrote: > I only got it to half work.  Using elpa, have done the same as > others.  Using mvn w/clojure plugin to do "mvn clojure:swank"; > changed to use swank 1.2.1. > > C-c C-k works fine... > > C-c C-c bombs with Java.lang.exception (No such nam