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, Chous

Re: Please help! Really simple function not working.

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 8:22 am, Laurent PETIT 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 > approach (with a priva

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Meikel Brandmeyer > Hi, > > On Aug 10, 8:22 am, Laurent PETIT 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

Re: Please help! Really simple function not working.

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 9:36 am, Laurent PETIT 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 are subscribed to the

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 > Hi, > > On Aug 10, 9:36 am, Laurent PETIT 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 ! -- You received this messa

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Laurent PETIT > 2010/8/10 Meikel Brandmeyer > >> Hi, >> >> >> On Aug 10, 9:36 am, Laurent PETIT 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.

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

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 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 stack limitations (mostl

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 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 your superset all fun

Re: drop-while for noobs

2010-08-10 Thread Michael Wood
On 9 August 2010 22:16, Alan 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 doc for d

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 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 hold and manipulate th

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
Hello Mark, 2010/8/10 Mark Engelberg > On Tue, Aug 10, 2010 at 1:15 AM, Nicolas Oury > 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 e

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 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 CPS+trampoline It is mo

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 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 > depending on wheth

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Nicolas Oury > On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT > 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

Re: Please help! Really simple function not working.

2010-08-10 Thread Laurent PETIT
2010/8/10 Laurent PETIT > > > 2010/8/10 Nicolas Oury > > On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT >> 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 memo

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 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 assume that the m

Re: Please help! Really simple function not working.

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 11:34 am, Mark Engelberg 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 only sometimes not brok

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 go

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? wor

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 wrote: > On Mon, Aug 9, 2010 at 10:55 AM, Sunil Nandihalli > wrote: > > Hel

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:

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 th

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 wrote: > I'm the author of clj-native. > Currently it only works with Clojure 1.

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 > Dipping my toes for

Re: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Laurent PETIT
2010/8/10 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? > Hi, I don't know why your REPL is not responding anymore, and maybe we sh

Re: Bug in try/finally?

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 8:36 am, Brian Stiles 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

Re: Bug in try/finally?

2010-08-10 Thread Adrian Cuthbertson
Hi Brian, System/out # (System/out) # 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 PrintStream object and correctly return nil as does... (.print System/o

Re: noob q: infinite loop recur

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 3:13 pm, Laurent PETIT 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 soon. As Laurent said: th

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 wo

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 > Hi, > > On Aug 10, 8:36 am, Brian Stil

Re: Eclipse and Compojure

2010-08-10 Thread Laurent PETIT
2010/8/10 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 any

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 follo

Re: noob q: infinite loop recur

2010-08-10 Thread Meikel Brandmeyer
Hi, On Aug 10, 3:48 pm, David Sletten 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 > list using the

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 Cloju

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 unsub

Re: Cannot sen msg to #clojure channel

2010-08-10 Thread Laurent PETIT
You need to register with NickServ, e.g. /msg NickServ identify 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 > Why? My nickname in #clojure is limux1972. > > -- > You received this

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 wrote: > 2010/8/10 garf > > >

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

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 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 clojure@googlegroups.com

Re: Eclipse Clojure REPL dies (newbie)

2010-08-10 Thread Laurent PETIT
2010/8/10 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 > This may explain that. FYI, there's

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 : > hi! > > I am doing a real-file demo with ring, compojure, hiccup, and database > access as well. > There is some chinese chararters in the tabl

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. O

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 in

Re: chinese character in hiccup

2010-08-10 Thread Rasmus Svensson
2010/8/10 limux : > 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 23391 27743) =>

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{ gen.visitT

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 Tue

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 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 type as addi

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 - plea

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 p

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

2010-08-10 Thread Mike Meyer
On Tue, 10 Aug 2010 09:57:02 -0700 (PDT) Alexis Rondeau 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 I do M-x clojure-mode, the REPL stops (I think) > evaluating. While t

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 go

Re: Bug in try/finally?

2010-08-10 Thread Chouser
On Tue, Aug 10, 2010 at 1:09 PM, joegg 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 static class

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 > 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.

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 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 I do M-x clojure-

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 > > 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 to this group, sen

How to construct Set

2010-08-10 Thread Tim Daly
How do I construct Set 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 first po

Re: Bug in try/finally?

2010-08-10 Thread Chouser
On Tue, Aug 10, 2010 at 2:51 PM, Chouser 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 be. Ok, i

Re: How to construct Set

2010-08-10 Thread Laurent PETIT
2010/8/10 Tim Daly > How do I construct > Set 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 usecase in mind I'm not clearling

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 (includ

Re: How to construct Set

2010-08-10 Thread Tim Daly
I have java code that reads: Set s = new HashSet(); I don't know how to write the parameter in clojure where MyType is a Java class. Laurent PETIT wrote: 2010/8/10 Tim Daly > How do I construct Set s = new HashSet(); in clojure? Can you be more

Re: How to construct Set

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 wrote: > I have jav

Re: How to construct Set

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 che

Re: How to construct Set

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: Set nodes = Can I construct a type hint ^S

Re: How to construct Set

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: JGraphT graph = and I'm at a loss for how to instantiate a graph in clojure. Armando Blancas wrote: If you must use Java's HashSet, you can use it untyp

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 :spad

Re: How to construct Set

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 ob

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 wrote: > Now we are at  eclipse /

Re: How to construct Set

2010-08-10 Thread Laurent PETIT
2010/8/10 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: > > JGraphT graph = > > and I'm at a loss for how to instantiate a graph in clojure. Tim, Generics in java are there only for ma

Re: How to construct Set

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: > > JGraphT graph = > > and I'm at a loss for how to instantiate a graph in clojure. Just leave away

Re: How to construct Set

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 ju

Re: chinese character in hiccup

2010-08-10 Thread Joop Kiefte
What do you get if you use the meta-line with GBK encoding? if that gives the right output, it is an input problem (i.e. the input is not UTF-8). 2010/8/10 Rasmus Svensson : > 2010/8/10 limux : >> There is some chinese chararters in the tables. I want to display them >> by hiccup, but browser disp

Re: Can't get my nesting right

2010-08-10 Thread Rasmus Svensson
2010/8/10 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) >            

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 :s

Re: How to construct Set

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 existin

Re: Cannot sen msg to #clojure channel

2010-08-10 Thread Sandeep Puri
first change your nick to whatever you want to register /nick then you can register using /msg NickServ register freenode requires you to confirm your registration i think (via a code sent via email) On Aug 10, 7:44 am, Laurent PETIT wrote: > You need to register with NickServ, e.g. > /msg N

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 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 version): avoid bind

Re: chinese character in hiccup

2010-08-10 Thread Nebojsa Stricevic
Hi, This looks similar like problem that I had with Clojure + Compojure + Enlive and Serbian characters. I'm not sure if this is true, but maybe solution to my problem can be helpful. Read this mailing list thread: http://tiny.cc/3cmrx Greets, -- Nebojša Stričević -- You received this message