Re: Software Engineering Practices for Marking Algorithms?

2011-03-15 Thread Mark Engelberg
On Tue, Mar 15, 2011 at 11:12 PM, Shantanu Kumar wrote: > Use the node's metadata to annotate :visited as true and re-associate, > and do it recursively (likely with loop recur)? > > Regards, > Shantanu > > Altering metadata is generally a non-destructive operation (with-meta), and alter-meta! onl

Re: Software Engineering Practices for Marking Algorithms?

2011-03-15 Thread Shantanu Kumar
On Mar 16, 9:01 am, CuppoJava wrote: > Hello everyone, > > This has been a long-time software engineering issue that I've never > solved happily. It concerns implementing marking algorithms without > making a kludge of your software structure. > > eg. Say I have a binary graph: > Where each node

Re: Software Engineering Practices for Marking Algorithms?

2011-03-15 Thread Ken Wesson
On Wed, Mar 16, 2011 at 12:01 AM, CuppoJava wrote: > If someone knows of a better way of implementing these "marking" > algorithms, or a nice way of organizing these "marker" fields, I would > love to hear your workarounds. HashSets of visited Nodes. Test with contains?. -- You received this me

Re: Software Engineering Practices for Marking Algorithms?

2011-03-15 Thread Mark Engelberg
Using the traditional visited flag approach, your program will fail if two threads try to print the same tree structure at the same time. I personally have found the hash table approach to be very effective. It uses space, but the space can be garbage collected as soon as you're finished with the

Software Engineering Practices for Marking Algorithms?

2011-03-15 Thread CuppoJava
Hello everyone, This has been a long-time software engineering issue that I've never solved happily. It concerns implementing marking algorithms without making a kludge of your software structure. eg. Say I have a binary graph: Where each node in the graph is like this: class Node{ Node[] child

Re: How to read this sample code?

2011-03-15 Thread Ken Wesson
(when pred (foo) (bar)) just calls foo and then bar if pred evaluates to logical true, and falls through otherwise. There's no parentheses around the pred, so it just looks up pred without trying to call it as a function. So, it's not pred's return value it's conditioning on, but pred's own va

Re: clj-string template

2011-03-15 Thread Shantanu Kumar
Hi Himangshu, You would notice that the functions *get-view-from-classpath* and * get-view-from-dir* already use a template group called "default" under the hood. As a consequence, you can use nested/sub templates (example in URL below) with the current version. Does this solve your use case? htt

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Ken Wesson
On Tue, Mar 15, 2011 at 12:58 PM, Armando Blancas wrote: > Another choice is to construct shapes as closures with auto-dispatch. > So a circle could be made thus, with no data structure per se: > > (defn make-circle [x y r] >  (fn [method] >    (case method >      :draw (fn [color] ...) >      :ro

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Ken Wesson
On Mon, Mar 14, 2011 at 11:15 PM, Daniel Solano Gomez wrote: > This method works fairly well, and you can even use it to define > protocols for types you don't control, such as classes from a Java API. > > If you need some more complicated form of dispatch for polymorphism, > there is the multimet

How to read this sample code?

2011-03-15 Thread Christian
I'm reading "Programming Clojure" and came across this snippet of code: (defn indexed [coll] (map vector (iterate inc 0) coll)) (defn index-filter [pred coll] (when pred (for [[idx elt] (indexed coll) :when (pred elt)] idx))) I'm having a hard time understanding this. What exactly is 'when

Re: [ANN] fs - file system utilities for Clojure

2011-03-15 Thread siyu798
Hi Miki, We are planning to use this file system utilities, and we need a function to get file extension. Currently we're using apache common for that, but we want to get rid of apache common altogether. Can you add this functionality to the fs.clj? Thx Si Yu -- You received this message b

Re: New Release of the Clojure Debugging Toolkit

2011-03-15 Thread George Jahad
odd. try adding that jar to your classpath, and see if that fixes it. if not, run "jar -tf" on the jar file to dump the table of contents on that tools.jar file and email it to me and i'll see if i can figure out what is going on. On Mar 15, 7:34 pm, Jeff Bordogna wrote: > George, >    Thanks

Re: New Release of the Clojure Debugging Toolkit

2011-03-15 Thread Jeff Bordogna
George, Thanks for the response. I'm using openjdk and it lives: file:usr/lib/jvm/java-6-openjdk/jre/../lib/tools.jar (and the format function worked to find that as well). Anything I need to change wrt that? Thanks, Jeff -- You received this message because you are subscribed to the

Re: New Release of the Clojure Debugging Toolkit

2011-03-15 Thread George Jahad
couple of thoughts: cdt uses the jdk's tools.jar for access to the java debug interface, (jdi). it's expecting it here: (format "file:///%s/../lib/tools.jar" (System/getProperty "java.home")) do you have such a file there? if not, do you have a tools.jar file anywhere else? which jdk are you

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-15 Thread Armando Blancas
> Yes, I know. It disproved the suggestion that it was expanding macros > there *before* checking for special symbols. That was precisely my > point with that demonstration. I must have misread your comments. > When the macro expands into a special form, or a form involving a > special subform, t

Re: clojure not using CPU on binarytree benchmark

2011-03-15 Thread Nick Zbinden
I have to give some more background on this. Me and a friend are doing this for school we never did anything like it so we just make up as we go. My task is to write (at this point I changed to objective to improving the existing programm) the programm. His task was to do all the mesurements. I jus

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-15 Thread Ken Wesson
On Tue, Mar 15, 2011 at 11:17 AM, Armando Blancas wrote: >> If so, it's only the subforms not in operator position that get >> macroexpanded first. Otherwise >> >> user=> (defmacro qqq [] 'if) >> #'user/qqq >> user=> ((qqq) (even? 42) "boo!") >> #> in this context (NO_SOURCE_FILE:607)> >> >> would

Re: (.contains (transient #{}) 17) ==> true!?!

2011-03-15 Thread Alan
On Mar 14, 2:10 pm, Ken Wesson wrote: > On Mon, Mar 14, 2011 at 4:41 PM, Alan wrote: > > Thanks Ken, I found this too when I saw Tassilo's problem on irc > > (didn't notice it was on ML as well). I was going submit a patch for > > this, but if you've already done so let me know and I won't. > > I

Re: Strange Loop 2011 - St. Louis - Sept 18-20

2011-03-15 Thread Nick Zbinden
Man that look awesome not a single thing I would wanne miss. On Mar 15, 9:16 pm, Alex Miller wrote: > I just put up a blog entry with some updated info on Strange Loop > 2011:http://thestrangeloop.com/blog/11/03/15/strange-loop-2011-update > > Lots more to come, but perhaps of interest to this gr

Re: Monad Lessons

2011-03-15 Thread Prashanth Menon
I'd love to attend as well :P - Prashanth On Sun, Mar 13, 2011 at 10:49 PM, kkw wrote: > Hi Brian, > >Thanks for craeting the videos. They've been the most helpful > monad tutorial I've ever followed. I'm looking forward to the next > video! Keep up the good work. > > Kevin > > On Mar 13, 1

Re: ANN: Clojure Toolbox (Early Beta)

2011-03-15 Thread James Reeves
On 15 March 2011 18:26, Mibu wrote: > Great site! Clean, simple, and very useful. Thanks :) > There's a missing 'n' at the end of the link to ring-basic-authentication. Fixed. > The "Beta" label doesn't mean what it used to mean. Today, it's unflattering > and unnecessary to have it on display

Strange Loop 2011 - St. Louis - Sept 18-20

2011-03-15 Thread Alex Miller
I just put up a blog entry with some updated info on Strange Loop 2011: http://thestrangeloop.com/blog/11/03/15/strange-loop-2011-update Lots more to come, but perhaps of interest to this group, *Rich Hickey* is the first confirmed keynote speaker (more in the works)... Workshops: - Hilary Mason

Re: clojure not using CPU on binarytree benchmark

2011-03-15 Thread Timothy Baldridge
> By the way, I have submitted several Clojure programs to the web site, and am > happy to hear of someone else interested in finding faster Clojure programs > for those problems.  I definitely do not wish to discourage your efforts.  I > ask these questions because I'd like to help you get to a

Re: clojure not using CPU on binarytree benchmark

2011-03-15 Thread Andy Fingerhut
But aren't your Clojure memory use measurements significantly lower than those published on that web site? They show the program using over 500 Mbytes. They also show 100% CPU utilization for 1 core machines, and a total of a bit over 100% on 4 core machines. That seems quite different from wh

Re: clojure not using CPU on binarytree benchmark

2011-03-15 Thread Nick Zbinden
My programm finishes but its just slower. The prgramm I ran is simular (i changed the -main a little bit) but ran it with the same parameters java -server -jar Clojure_Programm_uberjar. Im pretty sure what I messured is correct because it reflects the messurments on the shootout. On Mar 15, 7:06

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Alan
On Mar 15, 10:50 am, Mark Engelberg wrote: > On Tue, Mar 15, 2011 at 10:40 AM, Alan wrote: > > Seconded. I often know ahead of time I'll want to extend to > > multimethods eventually, but sometimes I don't. Because multimethods, > > protocols, and plain-old-functions look the same to the caller,

Re: ANN: Clojure Toolbox (Early Beta)

2011-03-15 Thread Mibu
Great site! Clean, simple, and very useful. There's a missing 'n' at the end of the link to ring-basic-authentication. The "Beta" label doesn't mean what it used to mean. Today, it's unflattering and unnecessary to have it on display. Thanks for doing this. You're awesome! -- You received thi

Re: clojure not using CPU on binarytree benchmark

2011-03-15 Thread Andy Fingerhut
Well, if the default max heap of your JVM is not enough to run the program successfully to completion, then I don't think that you will be very happy in getting the program to complete :-) Which JVM are you using, by the way? And what is the full command line you are using for the Java program

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Mark Engelberg
On Tue, Mar 15, 2011 at 10:40 AM, Alan wrote: > Seconded. I often know ahead of time I'll want to extend to > multimethods eventually, but sometimes I don't. Because multimethods, > protocols, and plain-old-functions look the same to the caller, you > can write your code whatever way is most stra

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Alan
On Mar 15, 10:30 am, Daniel Solano Gomez wrote: > In the end, the it all depends on what fits best with what you are > doing.  One approach is to simply avoid using multimethods or > polymorphism as you start developing.  Instead, you can use a custom > dispatch using if or cond in your polymorphi

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Luiz Augusto Moreira Costa
Hi stu, take a look in clojure protocols. I think that this can help you. http://clojure.org/protocols Luiz Costa On Mon, Mar 14, 2011 at 11:54 PM, stu wrote: > Hi, > > I'd like to create a simple library of drawable shapes: lines,

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Daniel Solano Gomez
On Tue Mar 15 09:21 2011, Alan wrote: > On Mar 14, 8:15 pm, Daniel Solano Gomez wrote: > > I believe there are two approaches to doing this in Clojure: > > > > 1. Multimethods:http://clojure.org/multimethods > > 2. Protocols:http://clojure.org/Protocols > > > > Of the two, as of Clojure 1.2, proto

Re: New Release of the Clojure Debugging Toolkit

2011-03-15 Thread Jeff Bordogna
I'm on Ubuntu and getting this same error. I can load up the repl no problem (tried with java command, and also with lein swank/slime), but after setting my port on M-x cdt, I get the following in gud-clojure.main: Current directory is ~/ Clojure 1.2.0 user=> java.lang.ClassNotFoundException: c

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Alan
On Mar 14, 7:54 pm, stu wrote: > Hi, > > I'd like to create a simple library of drawable shapes: lines, circles > and rectangles.  I've placed each type of shape in its own namespace > with functions that operate on that shape kind: > > (ns myshapes.line) > > (defn line ... creates new line ...) >

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Alan
Wow, it's like I'm reading Let Over Lambda all over again :) On Mar 15, 9:58 am, Armando Blancas wrote: > Another choice is to construct shapes as closures with auto-dispatch. > So a circle could be made thus, with no data structure per se: > > (defn make-circle [x y r] >   (fn [method] >     (ca

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Armando Blancas
Another choice is to construct shapes as closures with auto-dispatch. So a circle could be made thus, with no data structure per se: (defn make-circle [x y r] (fn [method] (case method :draw (fn [color] ...) :rotate (fn [degrees] ...) :r (fn [] r) :x (fn [] x) :

serial-port

2011-03-15 Thread Sam Aaron
Hi there, I just thought I'd announce serial-port, a small library I put together based on my Monome and Arduino work: https://github.com/samaaron/serial-port http://clojars.org/serial-port It depends on rxtx22 which is a small Clojar which packages RxTx 2.2 binaries which can be found here:

Re: clojure not using CPU on binarytree benchmark

2011-03-15 Thread Nick Zbinden
Hi, I did not mention that earlier but the benchmark sais no change in heapsize. See here: http://shootout.alioth.debian.org/u32/performance.php?test=binarytrees Does Clojure just have a much smaller heapsize in the standart case? On Mar 15, 5:19 am, Andy Fingerhut wrote: > On a MacBook Pro w

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Alan
On Mar 14, 8:15 pm, Daniel Solano Gomez wrote: > I believe there are two approaches to doing this in Clojure: > > 1. Multimethods:http://clojure.org/multimethods > 2. Protocols:http://clojure.org/Protocols > > Of the two, as of Clojure 1.2, protocols are the preferred way of doing > things.   Wha

Re: Multiple replacements in string using a map

2011-03-15 Thread Aaron Cohen
On Mon, Mar 14, 2011 at 2:17 PM, Daniel Solano Gomez wrote: > On Mon Mar 14 13:02 2011, shuaybi2 shuaybi2 wrote: >> I have a string such as: >> >> "select * from account where acctId = _ACCT-ID_ and acctTyp = _ACCT-TYP_" There are several clojure libraries that exist to improve the ease and safet

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-15 Thread Armando Blancas
> If so, it's only the subforms not in operator position that get > macroexpanded first. Otherwise > > user=> (defmacro qqq [] 'if) > #'user/qqq > user=> ((qqq) (even? 42) "boo!") > # in this context (NO_SOURCE_FILE:607)> > > would instead produce "boo!", as (qqq) would be expanded to if and > then

Re: clj-ldap - Clojure LDAP client

2011-03-15 Thread Saul Hazledine
On Mar 15, 11:14 am, Paul Dorman wrote: > Hi Saul, > > I'm happy to wait until Friday, but check your request queue before > you make the change yourself as I may submit one. I've made the change > on my own fork, but I've only changed the function definition from > private to public; I haven't lo

Re: clj-ldap - Clojure LDAP client

2011-03-15 Thread Saul Hazledine
On Mar 15, 11:16 am, Jozef Wagner wrote: > Hi, > > Could you please license clj-ldap under open source license? > > JW Its in the project.clj but I'll make it clearer in the README. (defproject clj-ldap "0.0.3" :description "Clojure ldap client" :url "https://github.com/alienscience/clj-ldap

Re: clj-ldap - Clojure LDAP client

2011-03-15 Thread Paul Dorman
Hi Saul, I'm happy to wait until Friday, but check your request queue before you make the change yourself as I may submit one. I've made the change on my own fork, but I've only changed the function definition from private to public; I haven't looked into the changes required for testing and docum

Re: clj-ldap - Clojure LDAP client

2011-03-15 Thread Jozef Wagner
Hi, Could you please license clj-ldap under open source license? JW -- 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

Re: clj-ldap - Clojure LDAP client

2011-03-15 Thread Saul Hazledine
On Mar 15, 1:30 am, Paul Dorman wrote: > Hi Saul, > > I would like to implement a LDAP authentication in Clojure, based > around clj-ldap. Do you think it is necessary for the bind-request > function to be private? In LDAP v3 bind requests can be sent at any > time during a connection, so I can ru

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-15 Thread Meikel Brandmeyer
Hi, On 15 Mrz., 08:17, Dominikus wrote: > Interestingly, macroexpand does not work on your qqq-macro either: > > user=> (macroexpand '((qqq) (even? 42) "boo!")) > ((qqq) (even? 42) "boo!") > > That's weird. You can't return macros as values. user=> (defmacro foo [x y] `(println ~x ~y)) #'user/

Re: DDJ for Clojure/Lisp/FP

2011-03-15 Thread patrickdlogan
The ACM published Lisp Pointers, I think from around 1988 to 1995. That was along these lines of a semi-formally peer-reviewed journal. They are in the ACM Digital Library. If you have access, they might serve as inspiration for overall flow and/or specific kinds of articles. -- You received t

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-15 Thread Dominikus
You are right, Ken. I was a little bit sloppy regarding macro expansion. The macroexpand1 method (line 5275) called by analyzeSeq quits immediately, if the operator is a special symbol. Thus, 'if' cannot be overwritten by a macro as you demonstrated with your if- defmacro example, only the use of a