Re: Clojure blog post about laziness

2009-01-10 Thread Mark Engelberg
Thanks Rich. I definitely appreciate the fuller explanation. It helped me understand what you've already tried, and what factors led to your design decision. You've given me a lot to think about. --~--~-~--~~~---~--~~ You received this message because you are su

Re: Method overloading anomaly. (specifically ArrayList/remove)

2009-01-10 Thread Christophe Grand
CuppoJava a écrit : > That workaround works nicely for now. I think though that this problem > can potentially be the source of many hard-to-find bugs though. ie.. > like in my second example, the vector of ArrayLists. > You can ask to be warned: user=> (set! *warn-on-reflection* true) true use

Re: adding line number while reading a file

2009-01-10 Thread Emeka
(map vector (iterate inc 0) "foo") Emeka --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to c

Re: adding line number while reading a file

2009-01-10 Thread GS
> Next, instead of filter, you probably want doseq. The filter function > filters a collection according to a predicate. The doseq function > applies a function with side effects (such as println) to each item in > a collection. > > (with-open [rdr (reader "executors.clj")] >   (doseq [[line inde

Re: In core structure editor, anyone?

2009-01-10 Thread roman
Here is a link to an article comparing structure editors with other approaches to code editing. Seems apropos to this discussion. http://web.media.mit.edu/~lieber/Lieberary/Softviz/CACM-Debugging/Already-Full/Already-Full.html Also, anyone wanting to play with Interlisp's structure editor can d

XML Pretty Printer

2009-01-10 Thread James Reeves
I've written a small XML pretty printing library that may be useful for debugging XHTML or XML outputs, especially those generated from libraries like clj-html or compojure.html. Usage is straightforward: => (use 'ppxml) nil => (ppxml "Hello") Hello I've uploaded the library to the g

java static method call anomaly

2009-01-10 Thread gammelgedden
Hi, thanks for a great language and discussion group ! I got an error calling a static method on a java class using the new calling form. I am using the december release of Clojure from the download page (on windows XP, java 6) Is this a bug, or is it a difference between (.method Class) and (.

pre newbie entrance

2009-01-10 Thread e
Thanks in advance, and feel free to ignore ... if this sounds too much like I'm being lazy or too complainy. It's not at all a very well organized post. Consider it a sort of "raw" impression, having checked out some of the movies, some of the docs, and the "getting started" link. I'm also not

Re: pre newbie entrance

2009-01-10 Thread James Reeves
On Jan 10, 4:54 pm, e wrote: > Concretely, this would mean following the "Getting Started" > instructions on clojure.org.  Then seeing what there is to see . . . I > assume some sort of command line for doing "REPL" will come up as it > says? The Wiki covers getting started in much more detail:

Re: adding line number while reading a file

2009-01-10 Thread James Reeves
On Jan 10, 1:17 pm, GS wrote: > > (with-open [rdr (reader "executors.clj")] > >   (doseq [[line index] (zip-index (line-seq rdr))] > >     (.println System/out (str (inc index) " " line > > Why would you use Java's (.println System/out ...) instead of > (println ...)? Because println is, I t

Re: pre newbie entrance

2009-01-10 Thread e
ah, this is useful, too: http://clojure.org/compilation On Jan 10, 12:39 pm, James Reeves wrote: > On Jan 10, 4:54 pm, e wrote: > > > Concretely, this would mean following the "Getting Started" > > instructions on clojure.org.  Then seeing what there is to see . . . I > > assume some sort of c

Re: pre newbie entrance

2009-01-10 Thread Eric Lavigne
> > > Concretely, this would mean following the "Getting Started" > instructions on clojure.org. Then seeing what there is to see . . . I > assume some sort of command line for doing "REPL" will come up as it > says? > Yes, "Getting Started" will show you how to start the REPL. I think that's nea

Re: java static method call anomaly

2009-01-10 Thread Meikel Brandmeyer
Hi, Am 10.01.2009 um 17:28 schrieb gammelgedden: Is this a bug, or is it a difference between (.method Class) and (. Class (method)) that tricks me here? I'm not sure about the protected stuff, since I don't have a Java background. But for the Clojure side: static Java methods are called usin

Re: java static method call anomaly

2009-01-10 Thread CuppoJava
Hi gammelgedden, I've also just recently figured out the reasoning behind Clojure's (Class/staticMethod) notation. (.newInstance TransformerFactory) This notation always expects the second argument to be an object of some sort. This means that TransformerFactory is actually being resolved as a C

Re: Method overloading anomaly. (specifically ArrayList/remove)

2009-01-10 Thread CuppoJava
After a bit more experimenting, I found the following workaround to be suitable for the time-being in case anyone else is having similar troubles. (defn arraylist_remove [#^ArrayList list index] (.remove list (int index))) --~--~-~--~~~---~--~~ You received this

Re: SLIME: trouble with java.lang.OutOfMemoryError

2009-01-10 Thread Paul Mooser
After talking to Jeffrey Chu, it seems like what is actually happening is possibly fairly obvious (in retrospect) - the java process runs out of heap space, and there's not even enough memory to keep swank- clojure working properly. Jeffrey tried some examples with just a plain REPL (without SLIME

Re: Clojure blog post about laziness

2009-01-10 Thread Justin Henzie
>From my limited understanding it seems that a lazy data structure must at some point reify and therefore be cached, to my mind, the alternative is better describes as a stream or generator. That is not to say that said stream is not the source of the reification but that it might be better to k

Re: SLIME: trouble with java.lang.OutOfMemoryError

2009-01-10 Thread Christian Vest Hansen
I don't think it is possible to define a way to deal with heap saturation that is general enough to cover all programs written in Clojure, and therefor I don't think this is something that the Clojure runtime should deal with at all. Personally, I only know of two ways to handle OutOfMemoryErrors

Re: Ugly Sudoku solver

2009-01-10 Thread Tzach
Thanks Konrad A very elegant solution. 40 years of laziness, and I finally realize what a great feature the lazy evaluation is ;) Tzach On Jan 9, 3:30 pm, Konrad Hinsen wrote: > On Jan 9, 2009, at 13:18, Tzach wrote: > > > > > The main functionsudokuis recursive: > > 1. Getting asudokuboard as

Re: SLIME: trouble with java.lang.OutOfMemoryError

2009-01-10 Thread e
i wondered about this when I was asking about eclipse analogies. The vm that runs a program that you are writing should have nothing to do with the vm your editor is using. Maybe there should be some way for the actual running program to be in one VM, and then the REPL communicates to it via RMI

Re: java static method call anomaly

2009-01-10 Thread gammelgedden
Thanks, for your responses I have to read a bit more on that, I am not sure i fully understand, but I see that your suggestions work :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to t

Re: SLIME: trouble with java.lang.OutOfMemoryError

2009-01-10 Thread Luc Prefontaine
Try this: http://github.com/djspiewak/jedit-modes/tree/master/clojure.xml I work with Eclipse on a daily basis because of the java code base I have to deal with but it was asking my computer to carry an elephant until... I got my hands on a quad-core with 6 Gig of RAM and I had loaded in RAM at b

Re: SLIME: trouble with java.lang.OutOfMemoryError

2009-01-10 Thread Paul Mooser
Yeah, I'm not really sure how I think the problem would be ideally solved. It would just be nice for an interactive programming environment to be able to recover from all exceptions that happen at a higher level than the VM itself. On Jan 10, 12:20 pm, "Christian Vest Hansen" wrote: > I don't th

Re: SLIME: trouble with java.lang.OutOfMemoryError

2009-01-10 Thread e
thanks for the encouragement. As for eclipse, I just don't get the same feeling. I love the cntl- space and cntl-\ things that stub out your code (not just for dot completion). . . complete with cells for variables that repeat in the template (yeah they probably took this from emacs, but I can a

Re: SLIME: trouble with java.lang.OutOfMemoryError

2009-01-10 Thread e
exactly. . . .but I bet a lot of people would just reply that this is not possible to address since the REPL is the one and only vm. Disclaimer, I'm only guessing at that, too. I don't understand any of this, yet. But if that's the case, fix that. Have the REPL send messages to the vm that's ru

Re: SLIME: trouble with java.lang.OutOfMemoryError

2009-01-10 Thread Paul Mooser
If I'm not mistaken, this is fairly close to how SLIME works, when connected to a remote VM. The remote VM is running some server code which allows it to communicate with SLIME, which is running inside of emacs. On Jan 10, 2:15 pm, e wrote: > exactly. . . .but I bet a lot of people would just re

Simple Data Structure Question

2009-01-10 Thread CuppoJava
Hello, I'm stumped as to how I create a mutually referential data structure in Clojure. My compsci is fuzzy. I don't know if what I'm trying to do is possible. Any insight would be helpful. I have a function that creates a Person, given his name and a list of friends. (defn new_person [name & fr

Re: SLIME: trouble with java.lang.OutOfMemoryError

2009-01-10 Thread e
seems like enclosjure addresses a bunch of my problems/questions. It also seems to work like we wanted SLIME to work, more or less . . .where you attach to the vm that's used for execution . . . only you attach to the REPL, I think, which still accomplishes the goal of keeping the editor separate

Re: Simple Data Structure Question

2009-01-10 Thread Stuart Sierra
Hi Patrick, Here's one way to do it: (defn new-person [name] (ref {:name name, :friends #{}})) (defn are-friends [a b] (dosync (commute a assoc :friends (conj (:friends @a) b)) (commute b assoc :friends (conj (:friends @b) a (def bill (new-person "Bill")) (def bob (new-person "Bo

Re: Simple Data Structure Question

2009-01-10 Thread Mark Fredrickson
I suggest moving friendship outside of the objects themselves. (defn person [name] {:name name}) (def bob (person "Bob")) (def bill (person "Bill)) (def *friends* {bob bill}) now friends is a map of who likes whom. Then you can implement (defn friend? [p1 p2] (or (= p1 (*friends* p2)) (= p2 (*

Re: Simple Data Structure Question

2009-01-10 Thread CuppoJava
Thank you for the replies. My actual problem is a bit more convoluted, so I can't separate the issue like in Mark's solution very easily. Stuart's solution is more general, and I think I can apply that in a straight-forward way. Thanks. ps: I'm doing a bit of reading about mutually-recursive data

Re: Simple Data Structure Question

2009-01-10 Thread Mark Engelberg
On Sat, Jan 10, 2009 at 6:57 PM, CuppoJava wrote: > ps: I'm doing a bit of reading about mutually-recursive data > structures on the net. Is Lisp's letrec supposed to handle this > situation? > > It would be handy just to be able to do: > > (letrec [bob (create_person "bob" bill) > bill

non recursive impl in presence of persistence?

2009-01-10 Thread e
I'm just trying to understand basic stuff. say I have a local list called "myList" (assigned using 'let' . . . should I have used something else?) Who cares what's in it. Maybe I set it up from a list comprehension from some input to my function. I have no idea how to iteratively mess with it s

Re: non recursive impl in presence of persistence?

2009-01-10 Thread Eric Lavigne
> > > I have no idea how to iteratively mess with it since everything is > persistent. Ok, like, say it's a list of lists and I am going to be > merging the lists, like Tarjan's mergesort from some book from > college. > Sorting is done much more easily with recursion than with iteration. However

Re: non recursive impl in presence of persistence?

2009-01-10 Thread Nick Vogel
Ok, first of all, here's how I translated that python code: (defn msort [myList] (if (> (count myList) 1) (let [l1 (first myList) l2 (second myList)] (recur (concat (drop 2 myList) (my-merge l1 l2 (first myList))) The main thing that might need explaining is the recur, which b

Re: non recursive impl in presence of persistence?

2009-01-10 Thread Nick Vogel
By the way just to clarify, the use of recur is iterative, it's just written in clojure in its recursive form. On Jan 11, 1:32 am, "Nick Vogel" wrote: > Ok, first of all, here's how I translated that python code: > > (defn msort [myList] >   (if (> (count myList) 1) >     (let [l1 (first myList)

Re: Ugly Sudoku solver

2009-01-10 Thread Tzach
Following your good advice, I also update the next-cell function to work in a lazy way instead of sorting the values of the entire board. The full source bellow. Next phase: GUI. ;; sudoku solver by Tach ;; with the help of Konrad (defn print-board [board] "Pretty print the sudoku board" (dos