Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Andreas Kostler
I am :) That's why I started this discussion. On 15/03/2011, at 2:30 PM, Gregg Williams wrote: > Let me introduce myself. I was senior editor at BYTE magazine from > 1979 to 1988, where I wrote many cover-story articles, developed/ > edited innumerable articles, and was responsible for a number o

Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Gregg Williams
Let me introduce myself. I was senior editor at BYTE magazine from 1979 to 1988, where I wrote many cover-story articles, developed/ edited innumerable articles, and was responsible for a number of issue themes (including the IBM PC, FORTH, and Lisp (Feb. 1988)). From there, I went to Apple (1988-1

Re: clojure not using CPU on binarytree benchmark

2011-03-14 Thread Andy Fingerhut
On a MacBook Pro with 2.4 GHz Intel Core 2 Duo and 3 GB of RAM (although the program only used about half a gig at most), that program finished in about 33 seconds, using 38.5 sec of user + system CPU time. The average CPU utilization was 126% (all of one CPU core, and 26% of another, on averag

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

2011-03-14 Thread Mark Engelberg
If the set of types is closed and will not be extended by users, there's nothing wrong with just writing your own dispatch using cond, something like: (defn draw [shape] (cond (triangle? shape) (draw-triangle shape) (circle? shape) (draw-circle shape) ...)) Then just write your

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

2011-03-14 Thread Daniel Solano Gomez
On Mon Mar 14 19:54 2011, stu wrote: > The problem I have is with the myshapes.picture/draw function. As a > Clojure newb I keep wanting to think of this like a polymorphic > function in the O-O world that relies on each sequence member having a > draw function. > > What's the idiomatic way of han

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

2011-03-14 Thread stu
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 ...) (defn draw ... draws a line ...) To keep thin

Re: Clojure Editor

2011-03-14 Thread Lee Spector
The Clojure mode activates for me, and I get a little bit syntax coloring, autocompletion, and () matching. But I don't get language aware indentation. Should I, or isn't this supported? (It's a really important feature IMHO.) Also, no matching of [] or {} (less important for me). Thanks, -L

Re: clj-ldap - Clojure LDAP client

2011-03-14 Thread Paul Dorman
Hi Saul, thanks for writing this. Embarrassingly I wasn't even aware of the UnboundID LDAP SDK, so it's great to find two useful things I can use right away! I would like to implement a LDAP authentication in Clojure, based around clj-ldap. Do you think it is necessary for the bind-request functi

clojure not using CPU on binarytree benchmark

2011-03-14 Thread Nick Zbinden
Hi, I'm working with binarytree benchmark from the Language Shotout. http://shootout.alioth.debian.org/u64/program.php?test=binarytrees&lang=clojure&id=5 Its basiclly a port from the java version. http://shootout.alioth.debian.org/u64/program.php?test=binarytrees&lang=java&id=2 The Problem with

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 6:32 PM, Dominikus wrote: > I did some investigations on the code in Compiler.java. There is an > IPersistentMap called 'specials' (line 95, Clojure 1.2) that maps > symbols like 'if' to parsers like IfExpr.Parser(); obviously, these > are the parsers recognizing special fo

Logging input

2011-03-14 Thread ataggart
I'm going to be working on clojure.tools.logging [1] (formerly clojure.contrib.logging) over the next few days. If you use the original api [2], or plan on using the one in development [3], and have any feedback, please open a jira ticket or post a reply. [1] https://github.com/clojure/tools.log

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Dominikus
I did some investigations on the code in Compiler.java. There is an IPersistentMap called 'specials' (line 95, Clojure 1.2) that maps symbols like 'if' to parsers like IfExpr.Parser(); obviously, these are the parsers recognizing special forms. Method analyzeSeq (line 5347) tries macro expansion f

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

2011-03-14 Thread Ken Wesson
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 don't have a CA so no, I haven't. Go ahead. --

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Timothy Baldridge
Yes, I think if you dig down into the Compiler.java code (that's where I assume this issue comes from) you'll probably find your answer. Recently in a blog entry Eric Lippert (one of the developers of C#) handled this exact subject. There are some 'bugs' in languages that exist, not because the de

Re: Multiple replacements in string using a map

2011-03-14 Thread semperos
There is also this contrib code which facilitates string interpolation: http://clojure.github.com/clojure-contrib/strint-api.html But I second Ken's concern about SQL injection attacks. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Laurent PETIT
2011/3/14 Dominikus > This was also my best guess, Timothy and Stuart, but it does not > explain why a redefined 'if' (or a competing symbol binding, Stuart?) > in the REPL leads to > > user=> if > # > My best guess is because it's not in a callable position (ie not the first element of a list.

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

2011-03-14 Thread Alan
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. On Mar 14, 12:37 pm, Ken Wesson wrote: > On Mon, Mar 14, 2011 at 4:13 PM, Tassilo Horn wrote: > > Hi

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

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 4:13 PM, Tassilo Horn wrote: > Hi all, > > I've implemented IEditableCollection support for ninjudd's > PersistentOrderedSet.  But when using that, my application delivered > wrong results.  See <87hbb6c4qf@member.fsf.org> and follow-ups. > > I was able to track it down

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Dominikus
This was also my best guess, Timothy and Stuart, but it does not explain why a redefined 'if' (or a competing symbol binding, Stuart?) in the REPL leads to user=> if # while 'if' within a list form does not: user=> (if 3) java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:74) I think

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

2011-03-14 Thread Tassilo Horn
Hi all, I've implemented IEditableCollection support for ninjudd's PersistentOrderedSet. But when using that, my application delivered wrong results. See <87hbb6c4qf@member.fsf.org> and follow-ups. I was able to track it down to the strangeness in the subject: (.contains (transient (hash

Re: IEditableCollection support for Justin Balthrop's PersistentOrderedSet

2011-03-14 Thread Tassilo Horn
Tassilo Horn writes: Hi again, > Now I've spotted the problem, although I don't know how to fix it yet. > The problem is that my implementation doesn't work with LazySeqs. A > minimal example at the REPL is that: > > funql.test.core> (into (ordered-set) (take 10 (iterate inc 0))) > #{} > > Here

Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Martin DeMello
On Mon, Mar 14, 2011 at 5:23 PM, Andreas Kostler wrote: > Something along those lines. The key would be to have low publication latency > e.g. articles undergo a initial review in a matter of hours so it > still has the blog vibe to it but undergo stricter quality control. The Monad Reader [http

Re: Multiple replacements in string using a map

2011-03-14 Thread Ken Wesson
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_" >> >> I have a map such as: >> >> {:_ACCT-ID_ 9876 :_ACCT-TYP "B"} >> >> I wa

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 5:11 AM, Dominikus wrote: > But I can call the redefined 'if' only with a qualified symbol name > > user=> (user/if 3) > 9 Or using apply: user=> (apply if [3]) 9 You can even just rename it: user=> (let [a if] (a 3)) 9 Cute, but you probably shouldn't be doing this in

Re: Multiple replacements in string using a map

2011-03-14 Thread Daniel Solano Gomez
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_" > > I have a map such as: > > {:_ACCT-ID_ 9876 :_ACCT-TYP "B"} > > I want to write a clojure function that will take the string and map as

Multiple replacements in string using a map

2011-03-14 Thread shuaybi2 shuaybi2
I have a string such as: "select * from account where acctId = _ACCT-ID_ and acctTyp = _ACCT-TYP_" I have a map such as: {:_ACCT-ID_ 9876 :_ACCT-TYP "B"} I want to write a clojure function that will take the string and map as a parameter and return me the string with all values from the map sub

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Stuart Sierra
Yes, with one correction: Clojure is not an interpreter. The Clojure compiler treats certain symbols specially, such as `if`, `do`, and `def`. You cannot redefine these symbols. -Stuart Sierra clojure.com -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: IEditableCollection support for Justin Balthrop's PersistentOrderedSet

2011-03-14 Thread Tassilo Horn
Tassilo Horn writes: Hi again, > I use Justin Balthrop's (ninjudd) nice ordered-set library [fn:1] in > my application. Because I frequently merge several sets using `into', > I wondered if I could get a performance win if PersistentOrderedSet > would support going transient by implementing the

Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Alex Miller
I have written a long-form article on zippers and tree-editing in Clojure under contract for CQ. I talked to Peter a few weeks ago and he is still working on the first issue. Hopefully it will emerge. :) Alex On Mar 13, 9:28 pm, Andreas Kostler wrote: > On 14/03/2011, at 12:05 PM, Alan Dipert

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Timothy Baldridge
I think it's probably this way because if is built right into the interpreter. So probably the symbol resolution goes something like this, in the compiler: if symbol is in special forms then emit special form else emit call to user function Many of the built-in functions (even the fn symbol) are

Re: clj-string template

2011-03-14 Thread himangshu hazarika
hi Shantanu, i ll answer pt 2 first, I was referring to IDE. regarding groups,We have a use case of subtemplates. I have used clj-stringtempalte to render all emails and likewise for our organisation. So, sometimes we need to add st components inside the master template. For now, i am directly acc

Evaluation of Symbol Bindings vs. Special Forms

2011-03-14 Thread Dominikus
I'm not sure I fully understand symbol resolution and the evaluation strategy of symbol bindings and special forms in Clojure 1.2. Let's say I bind 'if' (usually being a special form) to a function: user=> (defn if [x] (* x x)) #'user/if However, calling 'if' with an unqualified name does not wo

Re: Clojure Editor

2011-03-14 Thread WoodHacker
The file you need should be there. First look under the Document/ Language Support menu item. You should see and entry for Clojure. Try checking it.The syntax file is called clojure.bflang2 and it should be in a Bluefish directory somewhere on your system. I am using a MAC, so the file is

Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Andreas Kostler
Something along those lines. The key would be to have low publication latency e.g. articles undergo a initial review in a matter of hours so it still has the blog vibe to it but undergo stricter quality control. On 14/03/2011, at 8:57 PM, Nick Zbinden wrote: > This sounds very good. It would hav

IEditableCollection support for Justin Balthrop's PersistentOrderedSet

2011-03-14 Thread Tassilo Horn
Hi all, I use Justin Balthrop's (ninjudd) nice ordered-set library [fn:1] in my application. Because I frequently merge several sets using `into', I wondered if I could get a performance win if PersistentOrderedSet would support going transient by implementing the IEditableCollection interface by

Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Nick Zbinden
This sounds very good. It would have to be start up with one topic (lisp or FP) and if the system worked you could add more topics. The length could be like steve yeggy blogposts or like the ibm ähh articals (http://www.ibm.com/developerworks/java/library/j-clojure- protocols/). On Mar 14, 11:12 

Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Andreas Kostler
On 14/03/2011, at 8:00 PM, Saul Hazledine wrote: > On Mar 14, 3:41 am, Andreas Kostler > wrote: >> >> Maybe this group could finally get the ball rolling...Surely a collection of >> highly talented individuals could initiate a forum for >> technical exchange at the level Peter suggests (somewh

Re: DDJ for Clojure/Lisp/FP

2011-03-14 Thread Saul Hazledine
On Mar 14, 3:41 am, Andreas Kostler wrote: > > Maybe this group could finally get the ball rolling...Surely a collection of > highly talented individuals could initiate a forum for > technical exchange at the level Peter suggests (somewhere between a blog and > a book) - basically the level DDJ

Re: borneo - Clojure wrapper for Neo4j, a graph database.

2011-03-14 Thread Jeff Rose
On Mar 13, 5:55 pm, Jozef Wagner wrote: > On Thursday, March 10, 2011 12:50:13 PM UTC+1, Jeff Rose wrote: > > > Out of curiosity, why did you go with Neo4j rather than using jiraph? > > (https://github.com/ninjudd/jiraph)  I used neo4j in the past, and if > > I remember right my main annoyance w

Re: intersection and union on sequences/lists

2011-03-14 Thread Ken Wesson
(defn bag-of [coll] (apply bag coll)) just so we have analogues of both vec and vector here. -- 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 moderate

Re: intersection and union on sequences/lists

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 4:12 AM, Alan wrote: > By the way, thanks for the very thorough Bag implementation. Your > implementations of the very detailed things that people wish Clojure > had are always interesting reading. You're welcome. I solved the count problem independently, but thanks for t

Re: intersection and union on sequences/lists

2011-03-14 Thread Alan
By the way, thanks for the very thorough Bag implementation. Your implementations of the very detailed things that people wish Clojure had are always interesting reading. On Mar 14, 12:49 am, Ken Wesson wrote: > > Well, except that count and empty are broken for some reason: > > > user=> (.count

Re: intersection and union on sequences/lists

2011-03-14 Thread Ken Wesson
Here is a bag implementation: (defprotocol SetOps (disjoin* [this obj]) (has* [this obj]) (total [this obj]) (counts [this])) (defn disjoin ([s] s) ([s obj] (disjoin* s obj)) ([s obj & more] (apply disjoin (disjoin s obj) more))) (defn difference ([s] s) ([s other]

Re: intersection and union on sequences/lists

2011-03-14 Thread Ken Wesson
On Mon, Mar 14, 2011 at 3:49 AM, Ken Wesson wrote: >> Well, except that count and empty are broken for some reason: >> >> user=> (.count (Bag. {} 0)) >> 0 >> user=> (count (Bag. {} 0)) >> 1 >> >> I don't understand what's causing this, but empty bags are always >> returning a count of 1 (and false

Re: intersection and union on sequences/lists

2011-03-14 Thread Ken Wesson
> Well, except that count and empty are broken for some reason: > > user=> (.count (Bag. {} 0)) > 0 > user=> (count (Bag. {} 0)) > 1 > > I don't understand what's causing this, but empty bags are always > returning a count of 1 (and false from empty?) although the .count > method correctly returns

Re: intersection and union on sequences/lists

2011-03-14 Thread Alan
clojure.lang.RT.count checks whether the object being counted implements Counted, and only calls .count on it if so. IPersistentCollection does not implement Counted, so it calls (seq) on your object and walks over it to get the count. You return (mapcat ...), when asked for a seq, which is fully l

Re: intersection and union on sequences/lists

2011-03-14 Thread Christian Schuhegger
You're right. Your version does what I want. Actually I've just seen that common lisps behaviour in the case of duplicates is undefined: http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node152.html I was certain that it behaved the way your intersect behaves. -- You received this message because yo

Re: Clojure load-file command (+ Aquamacs, Bluefish)

2011-03-14 Thread Larry Travis
Ken: There are a lot of things to like about Aquamacs, and its creator David Reitter deserves high praise as of course do the Emacs creators on whose shoulders he stands. The problem we have raised here is, for the present at least, the only complaint I have about Aquamacs. And there is probab