Re: Datatypes and Protocols update

2010-04-27 Thread Mark Engelberg
Watching Stuart's tutorial, it looks like the automatic factory functions for deftypes have gone away (I'm still working with Clojure 1.1, so haven't had a chance to try the latest changes for myself). I'm going to miss that feature, especially for defrecord, which is now the "common case" construc

Re: tutorial on clojure protocols 1.2

2010-04-27 Thread Konrad Hinsen
On 26 Apr 2010, at 18:20, Stuart Halloway wrote: I have created a short (30 min) tutorial on clojure protocols at http://vimeo.com/11236603 . Hope some of you will find it useful. Nice presentation! I just noticed one inaccuracy: in the comparison between multimethods and protocol functions

Re: Datatypes and Protocols update

2010-04-27 Thread Konrad Hinsen
On 27 Apr 2010, at 09:20, Mark Engelberg wrote: I understand that you can always do "Foo." to construct a Foo record, but these constructors don't act as full-fledged functions, right? No. They are not first-class objects (in fact, not objects at all in the JVM sense), so you can't pass them

Re: ClassCastException using let

2010-04-27 Thread James Reeves
Could you provide the stack trace of the exception? I don't see any obvious problems, but the error may be caused by data you pass into the function. Alternatively perhaps the error is not caused inside let, but whatever consumes the results. Maybe also providing a sample of the raw data would be

Re: Any window user familiar with clojure-contrib development ?

2010-04-27 Thread Chris Perkins
On Apr 26, 9:10 pm, gary ng wrote: > Hi, > > I am wondering if there is any windows user who is familiar with > clojure-contrib project. > > The reason I asked is that I encountered quite some issues when trying to > build my own copy of clojure-contrib(on windows). That includes: > > 1. I cannot

Re: Datatypes and Protocols update

2010-04-27 Thread Rich Hickey
On Apr 27, 2010, at 3:20 AM, Mark Engelberg wrote: Watching Stuart's tutorial, it looks like the automatic factory functions for deftypes have gone away (I'm still working with Clojure 1.1, so haven't had a chance to try the latest changes for myself). I'm going to miss that feature, especially

Re: tutorial on clojure protocols 1.2

2010-04-27 Thread Heinz N. Gies
On Apr 26, 2010, at 18:20 , Stuart Halloway wrote: > I have created a short (30 min) tutorial on clojure protocols at > http://vimeo.com/11236603. Hope some of you will find it useful. Stuart, this was a awsome tutorial, I've never really gasped what protocols are and do from the talks on #cloj

Serializable Collections ?

2010-04-27 Thread Jules
Guys, I've searched the group and cannot find an answer to this one... Why are many of the more common collection types in Clojure not Serializable : Clojure 1.1.0-new-SNAPSHOT user=> (def #^java.io.ObjectOutput os (java.io.ObjectOutputStream. (java.io.FileOutputStream. "/dev/null"))) #'user/os

Re: ClojureCLR multiple .dll files

2010-04-27 Thread rodgertq
I haven't actually tried this with ClojureCLR produced .dlls but you could look at ILMerge as a post build step, see: http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx On Apr 25, 12:10 pm, lucidquiet wrote: > Hello, > > I'm using ClojureCLR, at the moment I've created a couple o

Re: Datatypes and Protocols update

2010-04-27 Thread Konrad Hinsen
On 27.04.2010, at 14:45, Rich Hickey wrote: > I agree. I asked for suggestions for the factory fn in #clojure, but got some > pushback against introducing things in the namespace. I'm still open to > suggestions, here are the issues: > > The generated type name is now imported, so at the very l

Re: Serializable Collections ?

2010-04-27 Thread Brian Hurt
On Tue, Apr 27, 2010 at 9:10 AM, Jules wrote: > Guys, > > I've searched the group and cannot find an answer to this one... > > Why are many of the more common collection types in Clojure not > Serializable : > I have an assemblia ticket open on this issue: https://www.assembla.com/spaces/clojure

Re: tutorial on clojure protocols 1.2

2010-04-27 Thread Christian Guimaraes
Stuart, Great. Congratulations. And I was thinking about one Clojure course using this format. Stay here the sugestion ;-) -- Christian. On Tue, Apr 27, 2010 at 2:07 PM, Heinz N. Gies wrote: > On Apr 26, 2010, at 18:20 , Stuart Halloway wrote: > > > I have created a short (30 min) tutorial on

Defining a namespace inside a let

2010-04-27 Thread David McNeil
I am experimenting with clojure.test and I encountered the following situation which I cannot explain. This code: (println (do (ns ns01 (:use clojure.test)) (deftest test1 nil) (run-tests))) Produces the expected result (note: it runs one test):

Re: Conflicting definition for IPersistentVector

2010-04-27 Thread Dan
On Apr 26, 4:54 pm, Rich Hickey wrote: > On Apr 13, 2010, at 9:37 AM, Dan wrote: > > > I'm a Java developer; I work on a project that has adopted Clojure's > > data structures as a convenient implementation of immutable sets, > > maps, etc.  In attempting to add type parameters to the Clojure > >

finding sequential items from a sequence

2010-04-27 Thread Ralph
Crossposted to stackoverflow. In a Clojure program, I have a sequence of numbers: (2 3 4 6 8 1) I want to find the longest sub-sequence where the items are sequential: (2 3 4) I am assuming that it will involve (take-while ...) or (reduce ...). Any ideas? -- You received this message becaus

Re: Questions about program design

2010-04-27 Thread Miki
Hello Andrew, > So, for people like me, can any of you suggest some transcribed > lectures, screencasts, books, blog posts, or other errata that discuss > the difference between program design in a language like Clojure and > an OO language like Ruby or Java? Two books that helped me are http://m

Insert into an indexed seq

2010-04-27 Thread Sean Devlin
Is there a built in to insert a value into an "indexed" seq? For example: user=> (insert [:a :b :c :d] 2 :q) (:a :b :q :c :d) Not sure if I'm missing something simple... Sean -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, se

Re: Insert into an indexed seq

2010-04-27 Thread Sean Devlin
Also, why does this work: user=> (assoc [:a :b :c :d] 2 :q) [:a :b :q :d] And this doesn't: user=> (dissoc [:a :b :c :d] 2) # Annoying. On Apr 27, 1:24 pm, Sean Devlin wrote: > Is there a built in to insert a value into an "indexed" seq? > > For example: > > user=> (insert [:a :b :c :d] 2 :q)

Re: Insert into an indexed seq

2010-04-27 Thread Chouser
On Tue, Apr 27, 2010 at 1:31 PM, Sean Devlin wrote: > Is there a built in to insert a value into an "indexed" seq? > > For example: > > user=> (insert [:a :b :c :d] 2 :q) > (:a :b :q :c :d) > > Not sure if I'm missing something simple... That's a vector, which cannot efficiently splice internally

Re: Insert into an indexed seq

2010-04-27 Thread Sean Devlin
You're right, inserting into a vector is fundamentally slow. Inserting into a list (must traverse elements) or String (Char Array) isn't any better. I get why Clojure doesn't include certain operations on certain data structures (e.g. assoc on a list), because it's the wrong tool for the job. Howe

Example JAX-WS server code using annotation support

2010-04-27 Thread Richard Newman
I just spent a little time figuring this out, so I figured I'd share. This example shows how to hang annotations onto Clojure code to replicate the equivalent Java web service code produced by NetBeans. It includes exported parameter names, types, and operat

Re: finding sequential items from a sequence

2010-04-27 Thread CuppoJava
Here's an attempt, but it's not my best work. =) (def temp [2 3 4 6 8 1]) (let [l (filter identity (for [[a b c] (map vector temp (rest temp))] (if (= (- b a) 1) a nil)))] (concat l [(+ (last l) 1)])) -Patrick -- You received this message b

Re: finding sequential items from a sequence

2010-04-27 Thread Ralph
I must clarify my question: I need the longest INITIAL sequence where the items are sequential. One solution offered by "cgrand" at stackoverflow is (defn longest-initial-sequence [[x :as s]] (take-while identity (map #(#{%1} %2) s (iterate inc x On Apr 27, 2:59 pm, CuppoJava wrote: > Her

Re: Insert into an indexed seq

2010-04-27 Thread Mark J. Reed
I'm a bit surprised that it's not there already, at least in clojure.contrib, but it's not hard to write, at least for vectors: (defn insert [vec pos item] (apply merge (subvec vec 0 pos) item (subvec vec pos))) On Tue, Apr 27, 2010 at 2:45 PM, Sean Devlin wrote: > You're right, inserting i

Re: Insert into an indexed seq

2010-04-27 Thread Mark J. Reed
On Tue, Apr 27, 2010 at 3:41 PM, Mark J. Reed wrote: > I'm a bit surprised that it's not there already, at least in > clojure.contrib, but it's not hard to write, at least for vectors: > > (defn insert [vec pos item] > (apply merge (subvec vec 0 pos) item (subvec vec pos))) > Er, that should

try-let

2010-04-27 Thread ataggart
Inspired from an earlier discussion, I've written a macro that allows let-style binding values to be try'd, and still available to catch/ finally clauses. E.g.: (try-let [from (API/open from-addr) to (API/open to-addr)] (do-stuff from to) (finally (if to (doto to .flush .close)) (if f

deftype and final classes

2010-04-27 Thread Richard Newman
Further to IRC conversations: I'm attempting to generate a JAX-WS service using Clojure. The main stumbling block was annotations; that's been removed, so I gave it a shot using deftype. My first strike works code-wise, so I sent it to the list earlier today. When it comes to actually inte

Re: Defining a namespace inside a let

2010-04-27 Thread Adrian Cuthbertson
Not sure about your specific case, but when you don't get back expected results it's usually due to the functions called being lazy. Try doall or dorun to force the iterations. -Rgds, Adrian. On Tue, Apr 27, 2010 at 12:25 AM, David McNeil wrote: > I am experimenting with clojure.test and I encou

gen-class, polymorphism, etc.

2010-04-27 Thread Lucas Caballero
Hello, I'm trying to write some Java code that uses reflection to pull some data from clojure generated classes. Do clojure .class, or generated Java class files actually extend the type specified in the extends and implements clauses? That is will they also work polymorphically in normal Java c

Beginner's question regarding implementing a constructor using gen-class

2010-04-27 Thread Gregg Williams
Hi--another example, another failed attempt to do something that looks quite basic (grumble, grumble) ... I'm continuing on my path to learning how to use Clojure with the graphics library Piccolo2D (http://www.piccolo2d.org) by re- implementing some of Piccolo2D's sample programs. Now I'm working