Re: Please help! Really simple function not working.

2010-08-10 Thread David Sletten
Carlos, I think this is pretty much what you had in mind: (defn count-zeros [l] (cond (empty? l) 0 (zero? (first l)) (inc (count-zeros (rest l))) :else (count-zeros (rest l (count-zeros '(9 8 6 0 1 2 0 5)) = 2 (count-zeros '(9 8 6)) = 0 (count-zeros '()) = 0 Of course the

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 David Sletten da...@bosatsu.net On Aug 10, 2010, at 2:22 AM, Laurent PETIT wrote: You could accomplish pretty much the same thing by defining two versions with different arities: (defn count-zeros ([l] (count-zeros l 0)) ([l result] (cond (empty? l) result

Re: jna Java Native Acess and clojure ....

2010-08-10 Thread mac
I'm the author of clj-native. Currently it only works with Clojure 1.2. In retrospect I should have made a separate branch when dropping 1.1 support. If you need 1.1 support, just tell me and I could make a branch for it since the changes required should be small. /Markus On Aug 9, 5:31 pm,

Re: Please help! Really simple function not working.

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 8:22 am, Laurent PETIT laurent.pe...@gmail.com wrote: Though here, the version with different arities exposes as API for the user the 2-arity version, but it may not make sense for the user of your function to know about this 2-arity version. I personally prefer the first

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Meikel Brandmeyer m...@kotka.de Hi, On Aug 10, 8:22 am, Laurent PETIT laurent.pe...@gmail.com wrote: Though here, the version with different arities exposes as API for the user the 2-arity version, but it may not make sense for the user of your function to know about this

Re: Please help! Really simple function not working.

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 9:36 am, Laurent PETIT laurent.pe...@gmail.com wrote: Interesting ! Though it seems like a repetition in this case ... Indeed. However, eg. with multimethods this a nice-to-know to supply some meaningful argument info. Sincerely Meikel -- You received this message because you

Re: looking for a simpler implementation of a function I'm using

2010-08-10 Thread ngocdaothanh
What I'm looking for is a natural, conceptually clean approach. Erlang programmers do version 2 all the time and it can be call Erlang-style. You should be confident with version 2. Version 2 is cleaner if you write the inner loop as a separate function. -- You received this message because

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Meikel Brandmeyer m...@kotka.de Hi, On Aug 10, 9:36 am, Laurent PETIT laurent.pe...@gmail.com wrote: Interesting ! Though it seems like a repetition in this case ... Indeed. However, eg. with multimethods this a nice-to-know to supply some meaningful argument info. Indeed !

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Laurent PETIT laurent.pe...@gmail.com 2010/8/10 Meikel Brandmeyer m...@kotka.de Hi, On Aug 10, 9:36 am, Laurent PETIT laurent.pe...@gmail.com wrote: Interesting ! Though it seems like a repetition in this case ... Indeed. However, eg. with multimethods this a nice-to-know to

Re: why the def of run-jetty looks like defn #^Server run-jetty

2010-08-10 Thread ngocdaothanh
The main usage (at least for me) is avoiding reflection in the context of direct call to a Java method. if you write: (defn foo [x]   (.clone x)) Thank you for the insightful explanation. -- You received this message because you are subscribed to the Google Groups Clojure group. To post

Re: Please help! Really simple function not working.

2010-08-10 Thread Nicolas Oury
On Tue, Aug 10, 2010 at 2:40 AM, Mark Engelberg mark.engelb...@gmail.com wrote: arbitrary-sized lists is a primary goal.  The posted code (minus the call to recur), is an elegant recursive formulation that is idiomatic in Scheme because Scheme is (typically) implemented in a way that makes

Re: Basic Lisp Compiler: How to tell which functions to compile?

2010-08-10 Thread Nicolas Oury
On Tue, Aug 10, 2010 at 12:43 AM, Jules julesjac...@gmail.com wrote: It is impossible (undecidable) to tell precisely which functions a function will call. Therefore you will need to consider not exactly set of functions that a function will call, but some superset of that. Why not take as

Re: drop-while for noobs

2010-08-10 Thread Michael Wood
On 9 August 2010 22:16, Alan a...@malloys.org wrote: Weird. I wonder if I was using an outdated version of Clojure or (more likely) assumed from (doc drop-while) that it wouldn't handle false the way I wanted. When doc says not nil should I assume it means neither nil nor false, or should the

Re: Please help! Really simple function not working.

2010-08-10 Thread Mark Engelberg
On Tue, Aug 10, 2010 at 1:15 AM, Nicolas Oury nicolas.o...@gmail.com wrote:  So, in this particular case, Scheme does not warranty no exhaustion of resources. Yes, but your recursion depth is limited to the length of the list you are processing. So if you have enough resources to comfortably

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
Hello Mark, 2010/8/10 Mark Engelberg mark.engelb...@gmail.com On Tue, Aug 10, 2010 at 1:15 AM, Nicolas Oury nicolas.o...@gmail.com wrote: So, in this particular case, Scheme does not warranty no exhaustion of resources. Yes, but your recursion depth is limited to the length of the list

Re: Please help! Really simple function not working.

2010-08-10 Thread Nicolas Oury
On Tue, Aug 10, 2010 at 9:55 AM, Mark Engelberg mark.engelb...@gmail.com wrote:  In Clojure, I find stack limitations are a real issue unless I transform the algorithms into a tail-recursive accumulator style. For lists, it's usually not hard.  For trees, it can be a bit of a pain. Try

Re: Please help! Really simple function not working.

2010-08-10 Thread Nicolas Oury
On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT laurent.pe...@gmail.com wrote: Naive question from someone who has not really used Scheme in practice : beyond the memory footprint problem (which may or may not be a problem depending on the memory size of an element in the initial list, and also

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Nicolas Oury nicolas.o...@gmail.com On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT laurent.pe...@gmail.com wrote: Naive question from someone who has not really used Scheme in practice : beyond the memory footprint problem (which may or may not be a problem depending on the

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Laurent PETIT laurent.pe...@gmail.com 2010/8/10 Nicolas Oury nicolas.o...@gmail.com On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT laurent.pe...@gmail.com wrote: Naive question from someone who has not really used Scheme in practice : beyond the memory footprint problem

Re: Please help! Really simple function not working.

2010-08-10 Thread Mark Engelberg
On Tue, Aug 10, 2010 at 2:21 AM, Nicolas Oury nicolas.o...@gmail.com wrote: It would probably be up to twice as slow, I would say. For a list that is continuous in memory and continuations that are allocated perfectly in memory, you would need to go through twice the same amount of memory. (I

Re: Please help! Really simple function not working.

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 11:34 am, Mark Engelberg mark.engelb...@gmail.com wrote: The table shows that the performance of the accumulator-style version of factorial is always worse than that of the original factorial function. I'm a little bit surprised, that people still prefer programs, which are

Re: Please help! Really simple function not working.

2010-08-10 Thread Nicolas Oury
The table show 20!. I am far from being sure of my point, but in a first approximation: Loading a part of memory that is not cached (which will be the case for big lists) is around 300 cycles. An addition in a register is a few cycles, a jump is a few cycles too, at most, (the prediction will be

noob q: infinite loop recur

2010-08-10 Thread chepprey
Dipping my toes for the first time in Clojure. Having some beginner troubles. THIS code works (on the repl, if that matters... also, Clojure 1.2): (defn show [words] (let [word (first words)] (do (println word) (if (nil?

Re: jna Java Native Acess and clojure ....

2010-08-10 Thread Sunil S Nandihalli
Thanks Chouser for your reply .. I was wondering if it is possible to acess c++ code via clj-native .. I only seem to find c-native calls .. do you have a comment on this.. Sunil. On Mon, Aug 9, 2010 at 9:01 PM, Chouser chou...@gmail.com wrote: On Mon, Aug 9, 2010 at 10:55 AM, Sunil Nandihalli

Bug in try/finally?

2010-08-10 Thread Brian Stiles
The following succeeds: (try (prn 1) (finally (prn 2) (doto (System/out) (.print -) (.println - prints: 1 2 -- The following fails (note the odd duplication of 2 in the output): (try (prn 1) (finally (prn 2) (.. (System/out) (print -) (println - prints: 1 2 -2

Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread garf
On occasion the REPL in Eclipse will stop taking input, or will fail to recognize a function I have just defined. Is there a simple way to get the REPL to restart, or break out of its current state? One other question as well, to get the REPL running when I first bring up Eclipse I have a file

Re: jna Java Native Acess and clojure ....

2010-08-10 Thread Sunil S Nandihalli
Thanks Mac for your clarification .. I am using clojure 1.2 .. so should be fine. And I was wondering if I can acess c++ stuff via clj-native .. What are your suggestions? Sunil On Tue, Aug 10, 2010 at 12:45 PM, mac markus.gustavs...@gmail.com wrote: I'm the author of clj-native. Currently it

Re: noob q: infinite loop recur

2010-08-10 Thread Laurent PETIT
Hi, if you recur with rest, you should use (empty?), if you recur with next, you can use (nil?) next is more eager than rest, but in a loop scenario, I generally use next since we'll test for nil in order to know whether to continue to iterate or not. 2010/8/10 chepprey jmess...@cranksters.org

Re: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Laurent PETIT
2010/8/10 garf gary.overg...@gmail.com On occasion the REPL in Eclipse will stop taking input, or will fail to recognize a function I have just defined. Is there a simple way to get the REPL to restart, or break out of its current state? Hi, I don't know why your REPL is not responding

Re: Bug in try/finally?

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 8:36 am, Brian Stiles brian.sti...@gmail.com wrote: The following succeeds: (try   (prn 1)   (finally    (prn 2)    (doto (System/out) (.print -) (.println - prints: 1 2 -- The following fails (note the odd duplication of 2 in the output): (try   (prn 1)  

Re: Bug in try/finally?

2010-08-10 Thread Christian Vest Hansen
The bug has nothing to do with try-finally. Take a look at the macro expansion: user= (macroexpand '(.. (System/out) (print -) (println -))) (. (. (System/out) (print -)) (println -)) You are trying to call 'println on what ever 'print returns. But 'print is a void method. On Tue, Aug 10, 2010

Re: Bug in try/finally?

2010-08-10 Thread Adrian Cuthbertson
Hi Brian, System/out #PrintStream java.io.printstr...@7d59ea8e (System/out) #PrintStream java.io.printstr...@7d59ea8e both return the out PrintStream object, so (.. System/out (print -)) -nil (.. (System/out) (print -)) -nil (.. System/out (print -)) -nil all invoke the print method on the java

Re: noob q: infinite loop recur

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 3:13 pm, Laurent PETIT laurent.pe...@gmail.com wrote: next is more eager than rest, but in a loop scenario, I generally use next since we'll test for nil in order to know whether to continue to iterate or not. I generally use next when I know that I need to realise anyway

Re: noob q: infinite loop recur

2010-08-10 Thread David Sletten
On Aug 9, 2010, at 11:52 PM, chepprey wrote: (defn show [words] (let [word (first words)] (do (println word) (if (nil? word) (println DONE) (recur (rest words))

Re: Bug in try/finally?

2010-08-10 Thread Laurent PETIT
Weird indeed: user= (def a (atom 1)) #'user/a user= (try (prn :test) (finally (swap! a inc) (.foo nil))) :test java.lang.NullPointerException (NO_SOURCE_FILE:0) user= @a 3 I would have expected 2 as a result, in any case ? 2010/8/10 Meikel Brandmeyer m...@kotka.de Hi, On Aug 10, 8:36 am,

Re: Eclipse and Compojure

2010-08-10 Thread Laurent PETIT
2010/8/10 Rasmus Svensson r...@lysator.liu.se I assume the problem is that there are no .class files in the jar. I tried to rebuild the compojure jar using lein jar but still didn't get .class files, even though: Clojure looks for both .class files and .clj files, so you don't need to

Re: Eclipse and Compojure

2010-08-10 Thread Rasmus Svensson
I assume the problem is that there are no .class files in the jar. I tried to rebuild the compojure jar using lein jar but still didn't get .class files, even though: Clojure looks for both .class files and .clj files, so you don't need to compile anything manually. I'm seeing the following

Re: noob q: infinite loop recur

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 3:48 pm, David Sletten da...@bosatsu.net wrote: Notice how Clojure returns two different values here. Other Lisps (such as Common Lisp) define FIRST/REST of the empty list to both be NIL (i.e., the empty list itself). So it is common in other Lisps to test for the end of a

chinese character in hiccup

2010-08-10 Thread limux
hi! I am doing a real-file demo with ring, compojure, hiccup, and database access as well. There is some chinese chararters in the tables. I want to display them by hiccup, but browser display those chinese character as ???. But the prn to console is ok. I am confused since I was a newbie in

Cannot sen msg to #clojure channel

2010-08-10 Thread limux
Why? My nickname in #clojure is limux1972. -- 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

Re: Cannot sen msg to #clojure channel

2010-08-10 Thread Laurent PETIT
You need to register with NickServ, e.g. /msg NickServ identify yourpassword It's a protection so that nobody else uses limux1972 when you're not online. (you also need to register limux1972, but I don't remember how) 2010/8/10 limux liumengji...@gmail.com Why? My nickname in #clojure is

Re: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread garf
thanks for the answer. I suspect that the REPL dieing is justified, as I tend to use the file as workspace with somethings uncompleted, and with my newness to Clojure in general, I am often doing things in ways that are not correct On Aug 10, 8:21 am, Laurent PETIT laurent.pe...@gmail.com wrote:

Re: Please help! Really simple function not working.

2010-08-10 Thread Will M. Farr
Maybe this point about Racket is too off-topic for the list, but: On Aug 10, 2010, at 4:55 AM, Mark Engelberg wrote: Generally speaking, I find I do not have to worry about blowing the stack in Scheme, and as a result, non-tail-call structural recursion (such as the algorithm that kicked off

Re: Please help! Really simple function not working.

2010-08-10 Thread Nicolas Oury
On Tue, Aug 10, 2010 at 11:23 AM, Will M. Farr wmf...@gmail.com wrot Sorry for the digression; I hope people find it interesting. I found it interesting. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Laurent PETIT
2010/8/10 garf gary.overg...@gmail.com thanks for the answer. I suspect that the REPL dieing is justified, as I tend to use the file as workspace with somethings uncompleted, and with my newness to Clojure in general, I am often doing things in ways that are not correct This may explain

Re: chinese character in hiccup

2010-08-10 Thread Joop Kiefte
Try using [:meta {:http-equiv Content-Type :content text/html; charset=utf-8}] inside your [:head] (can this be done with Jetty?) 2010/8/10 limux liumengji...@gmail.com: hi! I am doing a real-file demo with ring, compojure, hiccup, and database access as well. There is some chinese

Re: jna Java Native Acess and clojure ....

2010-08-10 Thread Frederick Polgardy
Access to C/C++ is only available via JNI, which requires a bit of technical understanding about the Java-C bridge. Are you just trying to make use of a C++ library you already have, for which there is no pure Java equivalent? -Fred -- Science answers questions; philosophy questions answers.

How to convert a sequence to a byte[]?

2010-08-10 Thread Piotr 'Qertoip' Włodarek
I need to write raw bytes to the file. I do it with: (.write (FileOutputStream /path) bytes) ...where bytes must be of type byte[]. Please note it cannot be Byte[]. I tried to convert my sequence with both (bytes) and/or (into-array) functions and got frustrated, one example: user=

Re: Bug in try/finally?

2010-08-10 Thread joegg
Laurent, Looking through the output of javap -v, it looks to me like this is roughly what's been emitted (please forgive the mix of clojure and java): try { (prn :test) (swap! a inc) (.foo nil) } finally { (swap! a inc) (.foo nil) } Which explains why @a is 3 -- I'm not sure this is

Re: chinese character in hiccup

2010-08-10 Thread Rasmus Svensson
2010/8/10 limux liumengji...@gmail.com: There is some chinese chararters in the tables. I want to display them by hiccup, but browser display those chinese character as ???. I spoke to him on #clojure and from what I could tell from some experiments I asked him to run: (map int 刘孟江) - (21016

Re: Bug in try/finally?

2010-08-10 Thread joegg
diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/ Compiler.java index f5684f1..af55660 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -1775,7 +1775,7 @@ public static class TryExpr implements Expr{

Re: How to convert a sequence to a byte[]?

2010-08-10 Thread Janico Greifenberg
By into-array default, into-array returns an array of the capital-B Bytes (that's what the cryptic [Ljava.lang.Byte; in the error message means). To get an array of primitive bytes (the class being printed as [B), you can pass the type as additional parameter (into-array Byte/TYPE mybytes) On

Re: How to convert a sequence to a byte[]?

2010-08-10 Thread Piotr 'Qertoip' Włodarek
On Aug 10, 7:19 pm, Janico Greifenberg j...@acm.org wrote: By into-array default, into-array returns an array of the capital-B Bytes (that's what the cryptic  [Ljava.lang.Byte; in the error message means). To get an array of primitive bytes (the class being printed as [B), you can pass the

M-x clojure-mode in Slime REPL disables REPL

2010-08-10 Thread Alexis Rondeau
Hi there, I'm very new to both Clojure and Emacs, but I've come across the following unexpected situation when wanting to activate clojure- mode in my slime REPL: Running Emacs 23 on OS X, installed clojure-mode, slime, slime-repl and swank-clojure via ELPA (the same situation arises when getting

Re: noob q: infinite loop recur

2010-08-10 Thread chepprey
To all - THANKS (especially David Sletten) for the excellent responses! Very helpful. -- 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 -

Re: How to convert a sequence to a byte[]?

2010-08-10 Thread Meikel Brandmeyer
Hi, there is also byte-array: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/byte-array Sincerely Meikel -- 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

Re: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread gammelgedden
Now we are at eclipse / clojure, I ahave had some issues. I love eclipse, have used it a lot with java, but i could not get it working satisfactorily with cloure and ccw. Hopefully unjustified. I am using windows (XP). My issues were that as soon as I had had some compilation error (in ccw) i

Re: Bug in try/finally?

2010-08-10 Thread Chouser
On Tue, Aug 10, 2010 at 1:09 PM, joegg joega...@gmail.com wrote: diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/ Compiler.java index f5684f1..af55660 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -1775,7 +1775,7 @@ public

Re: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Laurent PETIT
Hi, sad you gave up on ccw :-(. Let's address your point, though ... 2010/8/10 gammelgedden gammelged...@gmail.com Now we are at eclipse / clojure, I ahave had some issues. I love eclipse, have used it a lot with java, but i could not get it working satisfactorily with cloure and ccw.

Re: M-x clojure-mode in Slime REPL disables REPL

2010-08-10 Thread Steve Purcell
On 10 Aug 2010, at 19:19, Mike Meyer wrote: On Tue, 10 Aug 2010 09:57:02 -0700 (PDT) Alexis Rondeau alexis.rond...@gmail.com wrote: What I would like to do is to enable clojure-mode when I get my REPL (connected either via swank-clojure-project or lein swank/M-x slime- connect) but whenever

Re: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread gammelgedden
Thanks! I will definitely give it another try :-) -- 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.

Re: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Laurent PETIT
010/8/10 gammelgedden gammelged...@gmail.com Thanks! I will definitely give it another try :-) feedback welcome (especially for things you don't like - and how you would like them to be - ) -- You received this message because you are subscribed to the Google Groups Clojure group. To post

How to construct SetMyType

2010-08-10 Thread Tim Daly
How do I construct SetMyType s = new HashSet(); in clojure? -- 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

Re: Bug in try/finally?

2010-08-10 Thread Chouser
On Tue, Aug 10, 2010 at 2:51 PM, Chouser chou...@gmail.com wrote: That patch seems to essentially reverse this one: http://github.com/clojure/clojure/commit/5e9f2b293b307aa7953cd390360d24549e542b92 ...which suggests to me there must be a better solution, though I don't see yet what it would

Re: How to construct SetMyType

2010-08-10 Thread Laurent PETIT
2010/8/10 Tim Daly d...@axiom-developer.org How do I construct SetMyType s = new HashSet(); in clojure? Can you be more precise about the context of what you're trying to achieve ? 'cause the naive answer to your question is (def s #{}) or (let [s #{}] ...) but I think you have a

Re: chinese character in hiccup

2010-08-10 Thread Rasmus Svensson
I looked into the source of hiccup and tried entering the string 刘孟江 at various places, but I couldn't reproduce the error or find any code that did any form of encoding. When playing around with the repl, I was reminded that JLine (used by lein repl) does not support multibyte encodings

Re: How to construct SetMyType

2010-08-10 Thread Tim Daly
I have java code that reads: SetMyType s = new HashSet(); I don't know how to write the parameter MyType in clojure where MyType is a Java class. Laurent PETIT wrote: 2010/8/10 Tim Daly d...@axiom-developer.org mailto:d...@axiom-developer.org How do I construct SetMyType s = new

Re: How to construct SetMyType

2010-08-10 Thread Nikita Beloglazov
Hi, Tim Can you describe you task? Sets (and other collections) in clojure don't use generics, as I know. You can add element to set and check if set contains element. Why do you need MyType? To allow add only MyType elements in set? On Tue, Aug 10, 2010 at 11:40 PM, Tim Daly

Re: How to construct SetMyType

2010-08-10 Thread Armando Blancas
If you must use Java's HashSet, you can use it untyped: user= (deftype MyType []) user.MyType user= (def my-set (HashSet.)) #'user/my-set user= (.add my-set (MyType.)) true user= (.add my-set (java.util.Date.)) true If you need to enforce the use of a type, use a checked set: user= (def checked

Re: How to construct SetMyType

2010-08-10 Thread Tim Daly
All of the code I'm trying to convert uses generics everywhere. I don't know how to construct a generic in clojure. Is there a syntax for it? For instance, I have a graph of nodes of type Chart. They are stored in the graph where the nodes are kept as: SetChart nodes = Can I construct a type

Re: How to construct SetMyType

2010-08-10 Thread Tim Daly
This code uses the JGraphT graphing package which wants to create a graph where the types of the vertices and edges are generics, as in: JGraphTMyVertexType,MyEdgeType graph = and I'm at a loss for how to instantiate a graph in clojure. Armando Blancas wrote: If you must use Java's

Can't get my nesting right

2010-08-10 Thread Alan
I have the following function as part of a card-game system I'm developing: (defn make-suit [suit owner ranks] {suit (map (partial struct-map card :suit suit :owner owner :rank) ranks)}) (make-suit

Re: How to construct SetMyType

2010-08-10 Thread Alan
Depends on what you mean by that. If you mean, create a hashset for use in clojure that will only accept MyType objects, I'll defer to someone here who knows more clojure than I do, though it looks like metadata preconditions are the way to go. If you mean, create a hashset you can pass to Java

Re: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Alan
Similar experience here. For what it's worth, I found that emacs/swank made my wildest dreams come true - if you're willing to put in the effort to learn emacs, you'll love emacs for clojure as much as you love eclipse for java. On Aug 10, 11:38 am, gammelgedden gammelged...@gmail.com wrote: Now

Re: How to construct SetMyType

2010-08-10 Thread Laurent PETIT
2010/8/10 Tim Daly d...@axiom-developer.org This code uses the JGraphT graphing package which wants to create a graph where the types of the vertices and edges are generics, as in: JGraphTMyVertexType,MyEdgeType graph = and I'm at a loss for how to instantiate a graph in clojure.

Re: How to construct SetMyType

2010-08-10 Thread Meikel Brandmeyer
Hi, Am 10.08.2010 um 23:22 schrieb Tim Daly: This code uses the JGraphT graphing package which wants to create a graph where the types of the vertices and edges are generics, as in: JGraphTMyVertexType,MyEdgeType graph = and I'm at a loss for how to instantiate a graph in clojure.

Re: How to construct SetMyType

2010-08-10 Thread Nikita Beloglazov
If the JGraphT constructor takes say 2 args arg1 and arg2, you'll just write (let [graph (JGraphT. arg1 arg2)] ) and every side will be happy: clojure, and java. And when you need to add vertex or edge you create it and add. If you need to get edge (e.g. getEdge(...) method) you just

Re: Can't get my nesting right

2010-08-10 Thread Rasmus Svensson
2010/8/10 Alan a...@malloys.org: I have the following function as part of a card-game system I'm developing: (defn make-suit  [suit owner ranks]    {suit (map (partial struct-map card                        :suit suit                        :owner owner                        :rank)      

Re: Can't get my nesting right

2010-08-10 Thread Meikel Brandmeyer
Hi, Am 10.08.2010 um 20:56 schrieb Alan: which is exactly what I want. But I have failed countless times to define a make-hand function - I'd like to be able to call (make- hand :west {:spade [9 5], :club [10]}) and get back {:spade ({:suit :spade, :owner :west, :rank 9} {:suit :spade,

Re: How to construct SetMyType

2010-08-10 Thread Mark Engelberg
BTW, when you're done, it would be great if you could post a report about your experience using JGraphT from Clojure. I've been thinking a lot lately about what an ideal graph library would look like in pure Clojure, and it would be interesting to hear how easy/hard it already is to use an

Re: Cannot sen msg to #clojure channel

2010-08-10 Thread Sandeep Puri
first change your nick to whatever you want to register /nick nickname then you can register using /msg NickServ register password em...@address freenode requires you to confirm your registration i think (via a code sent via email) On Aug 10, 7:44 am, Laurent PETIT laurent.pe...@gmail.com

RFC: updated c.c.logging with some breaking changes

2010-08-10 Thread ataggart
I've pushed the changes to my fork of contrib[1] and would like to get feedback before pushing to contrib master. Changes to logging.clj[2]: New features: - Log and LogFactory protocols allow adding new implementations - log macros for using println-style args - log macros for using format-style

Re: lazy-seq realization/retention within futures

2010-08-10 Thread timcharper
On Aug 7, 6:42 pm, Ben Mabey b...@benmabey.com wrote: Hi all, I've run into an issue with a lazy-seq either being prematurely realized or having the head unwittingly retained.  Reading chapter 5 in The Joy of Clojure I realize that I am breaking one of the rules (page 150 in my MEAP