Extending deref

2008-12-11 Thread Mark Engelberg
If you wanted to extend deref to new types, is there any way to do that? For example, deref of a delay could be equivalent to a force. Or deref of a Future could invoke the Future's get method. This would give you the handy @ reader macro for things that frequently need to be forced to evaluate

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Mon Key
> Clojure does not allow for programmer-defined > reader macros (unlike other lisps). I know this has been touched upon last Spring - and Stu Halloway refs at least one discussion of this in his book. >From a practical standpoint I am beginning to understand more why the choice was made to not s

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Mon Key
> Clojure does not allow for programmer-defined > reader macros (unlike other lisps). I know this has been touched upon last Spring - and Stu Halloway refs at least one discussion of this in his book. >From a practical standpoint I am beginning to understand more why the choice was made to not s

Re: frequency of each unique item in collection

2008-12-11 Thread mago
Slightly shorter version: (defn frequencies "Returns a map from distinct items in coll to the number of times they appear." [coll] (reduce (fn [counts x] (merge-with + counts {x 1})) {} coll)) On Dec 11, 9:14 am, Stuart Sierra wr

Re: re-seq and other functions

2008-12-11 Thread Stephen C. Gilardi
In the latter case the result is a seq containing a single element: the vector. There is nothing to sort/it us sorted. --Steve On Dec 12, 2008, at 12:14 AM, Oscar Picasso wrote: > > user> (sort (re-seq #"\w+" "the quick brown fox")) > ("brown" "fox" "quick" "the") > > but > user> (sort (r

Re: defining keywords ?

2008-12-11 Thread Mon Key
cool. was wondering if this was possible the other day myself :) Good to know RH & crew have accounted for this possibility already. s_P On Dec 11, 10:08 pm, Chouser wrote: > On Thu, Dec 11, 2008 at 7:49 PM, Robert Koberg wrote: > > > Hi, > > > Would it be desirable to further define keywords

Re: Running out of memory when using filter?

2008-12-11 Thread Mark Engelberg
On Mon, Dec 8, 2008 at 6:51 PM, Rich Hickey wrote: I don't have the latest build of Clojure with atoms, so I reimplemented Rich's filter solution using refs, turning: > (defn filter > [pred coll] > (let [sa (atom (seq coll)) > step (fn step [] > (when-let [s @sa

re-seq and other functions

2008-12-11 Thread Oscar Picasso
user> (sort (re-seq #"\w+" "the quick brown fox")) ("brown" "fox" "quick" "the") but user> (sort (re-seq #"q(u(i))?" "the quick brown fox")) (["qui" "ui" "i"]) Why it's not sorted on the later case? --~--~-~--~~~---~--~~ You received this message because you are

Venkat Subramaniam to Speak on Debugging Ajax, Agile Development, Test Driven Development in .NET, Programming Groovy

2008-12-11 Thread Shaguf
Venkat Subramaniam to Speak on Debugging Ajax, Agile Development, Test Driven Development in .NET, Programming Groovy Great Indian Developer Summit 2009 – India’s Biggest Gathering of Software Developers Bangalore, November 24, 2008: Developing Ajax applications is a lot of fun, up until things

Apache Tapestry Creator to Speak on Clojure, Tapestry 5

2008-12-11 Thread Shaguf
Apache Tapestry Creator to Speak on Clojure, Tapestry 5 Bangalore, December 10, 2008: If you are a Java developer building web- based applications and tired of the countless frameworks that promise you a slick UI fast but fail to live up to their promise, then switch to Apache Tapestry to get mor

Re: Swing GUI Builder and Clojure

2008-12-11 Thread wubbie
Hi, The same hello world did not work for me. The error msgs are: (defn hello-world [] (qt4 (let [app (QCoreApplication/instance) button (new QPushButton "Go Clojure Go")] (.. button clicked (connect app "quit()")) (doto button (resize 250 100) (setFont (new Q

Re: Purpose of memfn?

2008-12-11 Thread Chouser
On Thu, Dec 11, 2008 at 7:44 PM, Oscar Picasso wrote: > > (map (memfn toUpperCase) ["a" "short" "message"]) > -> ("A" "SHORT" "MESSAGE") > > But one could already write: > > (map #(.toUpperCase %) ["a" "short" "message"]) > -> ("A" "SHORT" "MESSAGE") > > Are they cases where we cannot use the sec

Re: Purpose of memfn?

2008-12-11 Thread Stuart Halloway
I like the second form better, and may remove memfn from the book entirely. Stuart > On Programming Clojure I read: > >> The method-as-function idiom is a common one, so Clojure provides >> the memfn macro to wrap methods for you: > > (map (memfn toUpperCase) ["a" "short" "message"]) > -> ("A"

Purpose of memfn?

2008-12-11 Thread Oscar Picasso
On Programming Clojure I read: > The method-as-function idiom is a common one, so Clojure provides > the memfn macro to wrap methods for you: (map (memfn toUpperCase) ["a" "short" "message"]) -> ("A" "SHORT" "MESSAGE") But one could already write: (map #(.toUpperCase %) ["a" "short" "message"]

Re: defining keywords ?

2008-12-11 Thread Chouser
On Thu, Dec 11, 2008 at 7:49 PM, Robert Koberg wrote: > > Hi, > > Would it be desirable to further define keywords such that it allows a > special kind of namespacing. > > * This could allow for more efficient (for the user) and targeted > navigation over large, nested collections. > * It would a

Re: XML Namespaces :xmlns, was Re: xml/parse

2008-12-11 Thread Robert Koberg
Hi, Given an XML structure like: http://purl.org/dc/elements/1.1/"; > http://www.w3.org/1999/xhtml";> A HEAD Title A BODY Title http://www.w3.org/1999/xhtml";> A HEAD Title A BODY Title which will be parsed by clojure.xml/parse and converted into a nested c

Re: jEdit Mode for Clojure

2008-12-11 Thread Daniel Spiewak
I merged in all the interesting stuff from David Moss's Clojure jEdit mode. We do highlight things in very different colors, but all of the elements that his recognizes are also recognized by mine now. Also, I fixed the annoying issue with def: (def this)(def that) The above now highlights cor

Re: why can't I set! stuff in user.clj?

2008-12-11 Thread Stephen C. Gilardi
On Dec 11, 2008, at 7:24 PM, Rich Hickey wrote: I am interested in the issues you are trying to address, and thanks for volunteering! Excellent. You're welcome. I'd like to try to focus our efforts on release 1.0. Sounds good. Towards that end, it would be nice if your repl code got mor

Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-12-11 Thread mosi
My apologies, found the error. It was the linux setup. The portmap daemon was interfering with the swank server. If the portmap is stopped, everything works fine. Running everything as a root? I like to live on the edge of a cliff, gives me a nice buzz high ;-) You don`t? Bye, mosi On Dec 12, 1:

defining keywords ?

2008-12-11 Thread Robert Koberg
Hi, Would it be desirable to further define keywords such that it allows a special kind of namespacing. * This could allow for more efficient (for the user) and targeted navigation over large, nested collections. * It would allow for mixing related data that might need to be treated in dif

Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-12-11 Thread Bill Clementson
Hi Matt, On Thu, Dec 11, 2008 at 4:22 PM, mosi wrote: > > it seems I found the tick with swank-clojure, slime and emacs. > > Swank/clojure works only if the user is not root. (Or so it seems on > my linux setup) Why would you want to run swank-clojure as root? That would be extremely dangerous.

Re: why can't I set! stuff in user.clj?

2008-12-11 Thread Rich Hickey
On Dec 10, 2008, at 1:50 PM, Stephen C. Gilardi wrote: > > On Dec 10, 2008, at 8:51 AM, Stuart Halloway wrote: > >> Thanks for the info. Is this limitation of user.clj arbitrary, or >> motivated by some concern that the average Clojure user should know >> about? Is the a reason not to load the

Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-12-11 Thread mosi
Hi Bill, it seems I found the tick with swank-clojure, slime and emacs. Swank/clojure works only if the user is not root. (Or so it seems on my linux setup) Following your instructions on http://bc.tech.coop/blog/081023.html if the user is root, swank-clojure spawns a server listening on a given

Retired: clojure.contrib.pred and clojure.contrib.memoize

2008-12-11 Thread Stephen C. Gilardi
I removed the "pred" and "memoize" libs from clojure.contrib today. The most useful functions formerly in pred and the only function in memoize are now defined in clojure.core. --Steve smime.p7s Description: S/MIME cryptographic signature

Re: memory issue with nth

2008-12-11 Thread Rich Hickey
On Dec 11, 5:56 pm, Rich Hickey wrote: > On Dec 11, 2:28 pm, "Christian Vest Hansen" > wrote: > > > Wo-hoo! I found a fix. > > > I think it is only a JVM issue to the extent that the 1.6 JVM might be > > able to mask the bug by doing escape analysis or some such other > > magic, but that dosn'

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Randall R Schulz
On Thursday 11 December 2008 15:24, Dave Griffith wrote: > ... > On the downside, you can't tell until runtime whether a given function > call has an acceptable arity, which pretty much any other popular > language can check at edit-time. Given that function definitions are closed, it's eminentl

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Dave Griffith
My view is that Lisps have very a simple syntax, achieved at the cost of moving a fair amount of error checking until runtime. If you ignore reader macros, you can tell if a Clojure expression is well- formed by just keeping a count of open parentheses, which is about the least amount of state

Re: Strings as functions of maps

2008-12-11 Thread Rich Hickey
On Dec 11, 4:37 pm, Stefan Rusek wrote: > If we have the following map: > > (def m {:key 1 'sym 2 "str" 3}) > > The following are equivalent: > > (:key m) > (m :key) > > As are the following: > > ('sym m) > (m 'sym) > > I think the commutativity of maps with symbols and keywords is a > valuable

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Rich Hickey
On Dec 11, 5:03 pm, Daniel Eklund wrote: > > I've been reading the latest chapter from Stuart's book, Chapter 7: > > Macros, and he makes this statement: > > > "Clojure has no special syntax for code. Code is simply Clojure data. > > This is true for normal functions, but also for special forms

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Dave Newton
--- On Thu, 12/11/08, Paul Barry wrote: > syntactic sugar is not syntax? I think that depends on which particular nits are being picked. Is it strictly true that Clojure has "no syntax"? Meh--probably not. (defun foo [bar] ...) has more unique characters than (defun foo (bar) ...) or (define (

Re: memory issue with nth

2008-12-11 Thread Rich Hickey
On Dec 11, 2:28 pm, "Christian Vest Hansen" wrote: > Wo-hoo! I found a fix. > > I think it is only a JVM issue to the extent that the 1.6 JVM might be > able to mask the bug by doing escape analysis or some such other > magic, but that dosn't mean that the bug isn't there. > > It's a super-simp

Re: memory issue with nth

2008-12-11 Thread Paul Mooser
Nice job finding it ...! Once I could not reproduce it on JDK 6, I stopped looking for a real answer. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googl

Re: Why allow both ({:map 'example} :map) and (:map {:map 'example})?

2008-12-11 Thread Stephen C. Gilardi
On Dec 11, 2008, at 3:29 PM, Aaron Cohen wrote: Isn't it just asking for confusion? I really like that maps are functions of their keys though. It's nice to be able to use (:key some-argument) if some-argument might be nil. (:key nil) => nil (a useful answer) (nil :key) => IllegalArgumen

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Randall R Schulz
On Thursday 11 December 2008 13:50, Paul Barry wrote: > On Dec 11, 4:44 pm, Randall R Schulz wrote: > > All these things are syntactic sugar. Shorthand ways to write > > things that have vanilla S-Expression counterparts. Again, I would > > not call them syntax. > > syntactic sugar is not syntax?

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Stuart Halloway
Randall, Well said, and I need to find a place to make this explanation in the book prior to chapter 7. :-) Stuart > On Thursday 11 December 2008 13:37, Paul Barry wrote: >> I've been reading the latest chapter from Stuart's book, Chapter 7: >> Macros, and he makes this statement: >> >> "Cloj

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Daniel Eklund
> I've been reading the latest chapter from Stuart's book, Chapter 7: > Macros, and he makes this statement: > > "Clojure has no special syntax for code. Code is simply Clojure data. > This is true for normal functions, but also for special forms and > macros. Consider a language with syntax, su

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Randall R Schulz
On Thursday 11 December 2008 13:47, Sean Spencer wrote: > That was one of the best explanations of code as data I've ever read. > Kudos! Thanks. You forced me to look up the reference to which I alluded: On Thursday 11 December 2008 06:32, evins.mi...@gmail.com wrote: > Subject: Re: In core stru

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Paul Barry
On Dec 11, 4:44 pm, Randall R Schulz wrote: > All these things are syntactic sugar. Shorthand ways to write things > that have vanilla S-Expression counterparts. Again, I would not call > them syntax. syntactic sugar is not syntax? --~--~-~--~~~---~--~~ You recei

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Sean Spencer
That was one of the best explanations of code as data I've ever read. Kudos! On Thu, Dec 11, 2008 at 4:44 PM, Randall R Schulz wrote: > > On Thursday 11 December 2008 13:37, Paul Barry wrote: > > I've been reading the latest chapter from Stuart's book, Chapter 7: > > Macros, and he makes this st

Re: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Randall R Schulz
On Thursday 11 December 2008 13:37, Paul Barry wrote: > I've been reading the latest chapter from Stuart's book, Chapter 7: > Macros, and he makes this statement: > > "Clojure has no special syntax for code. Code is simply Clojure data. > This is true for normal functions, but also for special for

Re: jEdit Mode for Clojure

2008-12-11 Thread Randall R Schulz
On Thursday 11 December 2008 12:54, Daniel Spiewak wrote: > > Where do we find your latest version? Or do you want / need to > > refine it further? > > I'm constantly messing around with it and trying to make it a little > better. The very latest version is always here: > http://github.com/djspie

Strings as functions of maps

2008-12-11 Thread Stefan Rusek
If we have the following map: (def m {:key 1 'sym 2 "str" 3}) The following are equivalent: (:key m) (m :key) As are the following: ('sym m) (m 'sym) I think the commutativity of maps with symbols and keywords is a valuable and good thing. I realize that the String class doesn't implement th

Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Paul Barry
I've been reading the latest chapter from Stuart's book, Chapter 7: Macros, and he makes this statement: "Clojure has no special syntax for code. Code is simply Clojure data. This is true for normal functions, but also for special forms and macros. Consider a language with syntax, such as Java. .

Re: XML Namespaces :xmlns, was Re: xml/parse

2008-12-11 Thread Robert Koberg
> Apologies for responding to myself, but maybe an example might help (inline below) >> >> Hi again, >> >> I see the default ContentHandler implementation does not handle XML >> Namespaces. Is that the case or does the :xmlns symbol > > I meant keyword (I think) here. For example, say I have

Re: jEdit Mode for Clojure

2008-12-11 Thread Daniel Spiewak
> Where do we find your latest version? Or do you want / need to refine it > further? I'm constantly messing around with it and trying to make it a little better. The very latest version is always here: http://github.com/djspiewak/jedit-modes/tree/master/clojure.xml Daniel --~--~-~--~--

Re: jEdit Mode for Clojure

2008-12-11 Thread Daniel Spiewak
> Hi, just saw this thread. I had made some modifications to the edit mode and > uploaded it for inclusion (as a patch) > here:http://sourceforge.net/tracker/index.php?func=detail&aid=2201893&grou... > . > > I haven't checked the status in a while as my internet is very intermittent > ATM. Please

Re: jEdit Mode for Clojure

2008-12-11 Thread Randall R Schulz
On Thursday 11 December 2008 12:54, Daniel Spiewak wrote: > > Where do we find your latest version? Or do you want / need to > > refine it further? > > I'm constantly messing around with it and trying to make it a little > better. The very latest version is always here: > http://github.com/djspie

Re: XML Namespaces :xmlns, was Re: xml/parse

2008-12-11 Thread Robert Koberg
On Dec 11, 2008, at 3:44 PM, Robert Koberg wrote: > > Hi again, > > I see the default ContentHandler implementation does not handle XML > Namespaces. Is that the case or does the :xmlns symbol I meant keyword (I think) here. For example, say I have /xml/ like: {:tag :my-root, attrs {:xmlns:x

XML Namespaces :xmlns, was Re: xml/parse

2008-12-11 Thread Robert Koberg
Hi again, I see the default ContentHandler implementation does not handle XML Namespaces. Is that the case or does the :xmlns symbol provide some meaning to the (nested) collection(s)? Is there such a thing as namespacing a collection that would be based on the xmlns? thanks, -Rob --~--~-

Re: Java interop question

2008-12-11 Thread Brian Doyle
This article has a good example using the proxy function. http://gnuvince.wordpress.com/2008/11/18/fetching-web-comics-with-clojure-part-2/ On Thu, Dec 11, 2008 at 1:22 PM, Randall R Schulz wrote: > > On Thursday 11 December 2008 11:31, Mark Engelberg wrote: > > I understand how Clojure lets yo

Re: xml/parse

2008-12-11 Thread Robert Koberg
On Dec 11, 2008, at 3:25 PM, Shawn Hoover wrote: > On Thu, Dec 11, 2008 at 3:01 PM, Robert Koberg wrote: > > Hi, (very new to clojure, emacs and lispish things) > > I am using the latest downloadable clojure (rather than SVN, which I > do have and see it is a bit different) in Aquamacs. I have

Re: Why allow both ({:map 'example} :map) and (:map {:map 'example})?

2008-12-11 Thread Rich Hickey
On Dec 11, 3:29 pm, "Aaron Cohen" wrote: > Isn't it just asking for confusion? > > I really like that maps are functions of their keys though. If you want to pull the same key from a bunch of maps, being able to map the key is handy. Rich --~--~-~--~~~---~--~~

Why allow both ({:map 'example} :map) and (:map {:map 'example})?

2008-12-11 Thread Aaron Cohen
Isn't it just asking for confusion? I really like that maps are functions of their keys though. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegro

Re: xml/parse

2008-12-11 Thread Robert Koberg
On Dec 11, 2008, at 3:23 PM, Kevin Downey wrote: > your problem is ' > ' makes xml/parse a symbol and stops evaling it to a function > symbols are callable like keywords so if you have a hash with symbols > as keys you can > ('a {'a 1 'b 2}) -> 1 > > so ('xml/parse "/Users/me/correct/path/to/my.

Re: xml/parse

2008-12-11 Thread Shawn Hoover
On Thu, Dec 11, 2008 at 3:01 PM, Robert Koberg wrote: > > Hi, (very new to clojure, emacs and lispish things) > > I am using the latest downloadable clojure (rather than SVN, which I > do have and see it is a bit different) in Aquamacs. I have installed > the clojure mode and am using it with inf

Re: xml/parse

2008-12-11 Thread Kevin Downey
your problem is ' ' makes xml/parse a symbol and stops evaling it to a function symbols are callable like keywords so if you have a hash with symbols as keys you can ('a {'a 1 'b 2}) -> 1 so ('xml/parse "/Users/me/correct/path/to/my.xml") is trying to lookup 'xml/parse in "/Users/me/correct/path/t

Re: Java interop question

2008-12-11 Thread Randall R Schulz
On Thursday 11 December 2008 11:31, Mark Engelberg wrote: > I understand how Clojure lets you consume Java objects, and pass > Clojure objects to Java programs. > > However, it is not uncommon for Java libraries to be designed in such > a way that you need to create a subclass of something in the

Re: jEdit Mode for Clojure

2008-12-11 Thread David Moss
Hi, just saw this thread. I had made some modifications to the edit mode and uploaded it for inclusion (as a patch) here: http://sourceforge.net/tracker/index.php?func=detail&aid=2201893&group_id=588&atid=300588 . I haven't checked the status in a while as my internet is very intermittent ATM. Ple

Re: Learning Clojure

2008-12-11 Thread rb
On Dec 11, 7:06 am, Alex Burka wrote: > To the debate on whether there should be examples early in the text,   > here are my two cents: > > When I click on something called "Learning [programming language]" I   > like to see a representative example of the syntax early on. If   > there's just t

xml/parse

2008-12-11 Thread Robert Koberg
Hi, (very new to clojure, emacs and lispish things) I am using the latest downloadable clojure (rather than SVN, which I do have and see it is a bit different) in Aquamacs. I have installed the clojure mode and am using it with inferior-lisp to see output. When looking at the source for the

Java interop question

2008-12-11 Thread Mark Engelberg
I understand how Clojure lets you consume Java objects, and pass Clojure objects to Java programs. However, it is not uncommon for Java libraries to be designed in such a way that you need to create a subclass of something in the library in order to make use of the library. I don't understand wh

Re: memory issue with nth

2008-12-11 Thread Christian Vest Hansen
Wo-hoo! I found a fix. I think it is only a JVM issue to the extent that the 1.6 JVM might be able to mask the bug by doing escape analysis or some such other magic, but that dosn't mean that the bug isn't there. It's a super-simple little thing, and I can't imagine a CA is needed to apply it. P

Re: jEdit Mode for Clojure

2008-12-11 Thread Randall R Schulz
On Thursday 11 December 2008 10:34, Daniel Spiewak wrote: > It's been too long since I've looked at this thread... > > I took a look at the mode you linked. My mode is quite a bit more > powerful, particularly with the changes I added today. ... Where do we find your latest version? Or do you w

Re: In core structure editor, anyone?

2008-12-11 Thread TNeste
On Dec 10, 2:15 pm, Simon Brooke wrote: > I note people seem mainly to be using Emacs as an editing/development > environment for Clojure. But as people keep pointing out, Clojure is > homoiconic; the canonical source of a function is not a stream of > bytes read from a file, but is a structure

Re: jEdit Mode for Clojure

2008-12-11 Thread Daniel Spiewak
Oh, also I should mention that I found the magic incantation to make auto-indentation work perfectly. It handles multiple unindents just fine now. Daniel On Dec 11, 12:34 pm, Daniel Spiewak wrote: > It's been too long since I've looked at this thread... > > I took a look at the mode you linked

Re: jEdit Mode for Clojure

2008-12-11 Thread Daniel Spiewak
It's been too long since I've looked at this thread... I took a look at the mode you linked. My mode is quite a bit more powerful, particularly with the changes I added today. The linked mode does do some highlighting of special forms like @[...] that mine doesn't do yet, mainly because I didn'

Re: Patch: precompiling Clojure core sources in Ant build script

2008-12-11 Thread MattyDub
Well, I had the .clj files in my clojure.jar, and clojure.jar is on slime-search-paths, but I still wasn't getting M-. to work with clojure's functions and macros. I added the source files to my classpath, and I get them now. Also, I updated clojure and swank-clojure this morning, so it looks

Re: memory issue with nth

2008-12-11 Thread Paul Mooser
I think this might just be a JVM version issue. I can reproduce this issue with a 1.5 JVM, but I can't reproduce it with 1.6. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, sen

Re: Learning Clojure

2008-12-11 Thread Brian Will
Tim, just go ahead and make any changes you like. If I don't like them, I can always revert ;) Actually, I'm sure anything you add we can find a place for, but like I said, that would likely be a separate example page in most cases. Thanks, Randall, I mention keywords-as-functions where I talk ab

Re: The return of the monads: lessons learned about macros

2008-12-11 Thread Konrad Hinsen
Jim, thanks for your comments! > First, the function 'group' that you define seems to be the same as > Clojure's 'partition' function. Indeed. I have spent some time checking if something like this exists already, but I didn't consider "partition" as a name! > Second, when I tried to load mo

Re: In core structure editor, anyone?

2008-12-11 Thread falcon
Can't say I understood all of it (being a LISP noob) but appreciate the explanation. Does the following fit into the current discussion? Barista editor: http://faculty.washington.edu/ajko/barista.shtml Barista editor is based on Citrus http://faculty.washington.edu/ajko/citrus.shtml The citru

Re: The return of the monads: lessons learned about macros

2008-12-11 Thread jim
Konrad, I haven't had a chance to look at this in depth but I did see two things. First, the function 'group' that you define seems to be the same as Clojure's 'partition' function. Second, when I tried to load monads, I get the following error. java.lang.ExceptionInInitializerError (monads.cl

Re: Learning Clojure

2008-12-11 Thread Randall R Schulz
On Thursday 11 December 2008 07:41, samppi wrote: > Great article, but I'm not sure this part in the keyword section is > correct: > > "Keywords exist simply because, as you'll see, it's useful to have > names in code which are symbol-like but not actually symbols. > Keywords have no concept of be

Re: Learning Clojure

2008-12-11 Thread samppi
Great article, but I'm not sure this part in the keyword section is correct: "Keywords exist simply because, as you'll see, it's useful to have names in code which are symbol-like but not actually symbols. Keywords have no concept of being namespace qualified as they have nothing to do with names

Re: frequency of each unique item in collection

2008-12-11 Thread Stuart Sierra
I've added a slightly modified version to clojure.contrib.seq-utils: (defn frequencies "Returns a map from distinct items in coll to the number of times they appear." [coll] (reduce (fn [counts x] (assoc counts x (inc (get counts x 0 {} coll)) -Stuart Sierra

Re: frequency of each unique item in collection

2008-12-11 Thread Dave Griffith
Yup, five bugs by my count. Not bad for a one-liner. More coffee necessary. Same algorithm, but tested. (defn frequencies [coll] (reduce (fn [map val] (assoc map val (if (contains? map val) (+ 1 (get map val)) 1))) {} coll) ) On Dec 11, 9:52 am, Randall R Schulz <[EMAIL PROTECTED]> wro

Re: frequency of each unique item in collection

2008-12-11 Thread Stuart Sierra
On Dec 11, 9:21 am, bOR_ <[EMAIL PROTECTED]> wrote: > I thought I remembered there was a method in the api somewhere that > would count the frequency of each unique item in a collection, but I > can't find it anymore. What would be a brief way to write that in > clojure? I think what you want is:

Re: frequency of each unique item in collection

2008-12-11 Thread Randall R Schulz
On Thursday 11 December 2008 06:33, Dave Griffith wrote: > On Dec 11, 9:21 am, bOR_ <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > I thought I remembered there was a method in the api somewhere that > > would count the frequency of each unique item in a collection, but > > I can't find it anymore.

Re: Is it possible to tell programatically if I'm in a transactional context?

2008-12-11 Thread Dave Griffith
Excellent! This is a great way of making code fail-fast for a class of bugs that would normally only occur under load (i.e. at the worst possible time). --Dave Griffith --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: In core structure editor, anyone?

2008-12-11 Thread Stuart Sierra
On Dec 11, 9:32 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I don't know whether Rich regards the text of a Clojure program as the > source, or whether he thinks of the source as the data structure > created by the reader when it reads the text. In Common Lisp and some > older dialects, i

Re: frequency of each unique item in collection

2008-12-11 Thread Mark McGranaghan
I don't recall a histogram-like method, though I may just be forgetting. (defn frequencies [coll] (reduce (fn [map val] (assoc map val (inc (get map val 1 {} coll)) On Thu, Dec 11, 2008 at 9:33 AM, Dave Griffith <[EMAIL PROTECTED]> wrote: > > > (defn frequencies [coll] >

Re: frequency of each unique item in collection

2008-12-11 Thread Dave Griffith
(defn frequencies [coll] (reduce (fn [map val] (assoc map val (if (contains map val) (get map val) 1)) #{}) ) On Dec 11, 9:21 am, bOR_ <[EMAIL PROTECTED]> wrote: > Hi all, > > I thought I remembered there was a method in the api somewhere that > would count the frequency of each uniq

Re: Is it possible to tell programatically if I'm in a transactional context?

2008-12-11 Thread Rich Hickey
On Dec 8, 7:44 pm, Dave Griffith <[EMAIL PROTECTED]> wrote: > The basic use case is as a guard for I/O, to prevent them from from > filling the disk/spamming the network accidentally in case of > transaction live-lock. Probably a bit more paranoia than is idiomatic > in the dynamically-typed wo

Re: In core structure editor, anyone?

2008-12-11 Thread evins.mi...@gmail.com
On Dec 10, 2:59 pm, falcon <[EMAIL PROTECTED]> wrote: > Could you describe in-core editing a bit more?  Sounds interesting. The canonical structure editor (not "structured editor") is probably Interlisp-D's SEDIT, or its predecessor DEDIT. (See http://bitsavers.org/pdf/xerox/interlisp/3102300_i

frequency of each unique item in collection

2008-12-11 Thread bOR_
Hi all, I thought I remembered there was a method in the api somewhere that would count the frequency of each unique item in a collection, but I can't find it anymore. What would be a brief way to write that in clojure? (In ruby: array.inject(Hash.new(0)) {|hash,key| hash[key] += 1 ; hash}) --

Re: Clojure Code Analysis Tools

2008-12-11 Thread Peter Wolf
Hi Darren, Work continues. Merlyn has invited me to take over admin of the code. I have taken Merlyn's code as a base, and am fleshing it out. Currently, I am struggling though the lack of documentation and examples for building a custom language plugin. I have implemented a Lexer, and am

Re: why can't I set! stuff in user.clj?

2008-12-11 Thread Stuart Halloway
+1. I would love to see a one-file story. Stu > On Dec 10, 2008, at 1:50 PM, Stephen C. Gilardi wrote: > >> - I think init.clj and repl-init.clj would be good additions to >> what we have now. I'll be happy to write the code if it's welcome. > > Alternatively, we could make those hooks be func

Re: Learning Clojure

2008-12-11 Thread janus
Timothy, Your post is a great one indeed , you have developed a template that anyone could use to introduce Clojure. I would implore to fresh out thoughts and deepen it for all to enjoy. Emeka --~--~-~--~~~---~--~~ You received this message because you are subsc

Re: Dr. Dobbs: "It's Time to Get Good at Functional Programming"

2008-12-11 Thread Michael Wood
On Wed, Dec 10, 2008 at 11:28 PM, Randall R Schulz <[EMAIL PROTECTED]> wrote: > > Hi, > > I just found this article on Dr. Dobbs' Web site. It's dated Dec 3rd of > this year: > > - "It's Time to Get Good at Functional Programming" > Subtitle: "Is it Finally Functional Programming's Turn?" >

Re: throw-if with no exception class

2008-12-11 Thread Rich Hickey
On Dec 10, 10:52 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote: > On Dec 10, 2008, at 4:38 AM, Ralf Bensmann wrote: > > > Being a Java trainer for a long time, we talk with students about > > the "handle-or-declare rule" in Java and the two types of > > exceptions: "checked" (declared) and

The return of the monads: lessons learned about macros

2008-12-11 Thread Konrad Hinsen
A while ago I uploaded an implementation of monads in Clojure to the group's file section. I have now replaced it by a more or less complete rewrite. This rewrite was motivated by one serious problem with the original implementation, plus a number of minor points that I was not happy with. I have

Re: Learning Clojure

2008-12-11 Thread Alex Burka
To the debate on whether there should be examples early in the text, here are my two cents: When I click on something called "Learning [programming language]" I like to see a representative example of the syntax early on. If there's just text as far as the eye can see (that is, the first

Apache Tapestry Creator to Speak on Clojure, Tapestry 5

2008-12-11 Thread Shaguf
Apache Tapestry Creator to Speak on Clojure, Tapestry 5 Bangalore, December 10, 2008: If you are a Java developer building web- based applications and tired of the countless frameworks that promise you a slick UI fast but fail to live up to their promise, then switch to Apache Tapestry to get mor

Re: Clojure Code Analysis Tools

2008-12-11 Thread [EMAIL PROTECTED]
On Dec 2, 4:52 pm, Peter Wolf <[EMAIL PROTECTED]> wrote: > > I vote that we take Merlyn's code as a base and put it on SourceForge.   > I'll add my Lexer and Parser and work on formatting, parens matching and > coloring.  Erik can add his REPL and completion stuff. > > However, I think it would be

Re: throw-if with no exception class

2008-12-11 Thread Ralf Bensmann
Just throwing "Exception" is discouraged in Java, because its the supertype checked and unchecked exceptions. I often saw a JVM die of an unproper exception handling -- mainly when NullPointerExceptions were involved. So we are on the JVM, want Java interop and so my isistent recommendation is to u