Re: December monads

2008-12-21 Thread Konrad Hinsen
On 20.12.2008, at 22:50, jim wrote: > I also think this would be a great addition to clojure-contrib. Me too. But who decides what goes into clojure-contrib? Rich? > Because of the way most monad tutorials are written, monads seem to be > pretty hard to get your head around. Also, many of the

A Common Lisp format function for Clojure now up

2008-12-21 Thread Tom Faulhaber
Good Evening Clojurians, I have been working on a Clojure implementation of the format function from Common Lisp and it's coming along well enough that I thought I'd share. You can see/download the current state of it in its github project: http://github.com/tomfaulhaber/cl-format/ It's current

Re: How to encapsulate local state in closures

2008-12-21 Thread Mark Engelberg
I misspoke; it's the call to counter that's the problem. Let's say you want to use a counter to count the number of times a ref is set, something like this: (dosync (counter) (ref-set r 1)) If your var-set causes the transaction to retry, an atom-based counter will increment twice. As I unders

Re: How to encapsulate local state in closures

2008-12-21 Thread Parth Malwankar
On Dec 22, 5:45 am, "Mark Engelberg" wrote: > But if mk-counter is called twice because it's retried in part of a > transaction, then you're in big trouble when you use atom.  Better to > use a ref here.  atom needs to be reserved for the very few cases when > retries don't matter (like a cache

Re: How to encapsulate local state in closures

2008-12-21 Thread Parth Malwankar
On Dec 22, 5:24 am, "Brian Doyle" wrote: > I haven't been following the new atom stuff, so I was wondering why atom > would be best in this > situation, vs a ref?  Thanks. Rich discusses the use of atoms, refs and agents in good detail in this thread: http://groups.google.com/group/clojure/msg

Re: How to encapsulate local state in closures

2008-12-21 Thread Stephen C. Gilardi
On Dec 21, 2008, at 7:24 PM, Brian Doyle wrote: I haven't been following the new atom stuff, so I was wondering why atom would be best in this situation, vs a ref? Thanks. The implementation of atoms is supported by the JVM typically using a processor hardware instruction that accomplis

Re: How to encapsulate local state in closures

2008-12-21 Thread Mark Engelberg
But if mk-counter is called twice because it's retried in part of a transaction, then you're in big trouble when you use atom. Better to use a ref here. atom needs to be reserved for the very few cases when retries don't matter (like a cache). --~--~-~--~~~---~--~---

Re: How to encapsulate local state in closures

2008-12-21 Thread Brian Doyle
I haven't been following the new atom stuff, so I was wondering why atom would be best in this situation, vs a ref? Thanks. On Sun, Dec 21, 2008 at 1:03 PM, Parth Malwankar wrote: > > > > On Dec 21, 11:47 pm, chris wrote: > > I would like to be able to encapsulate local state in a closure. > >

Re: Curiosity: why doesn't (count (doall (range 1000000000))) exhaust memory?

2008-12-21 Thread Stephen C. Gilardi
On Dec 21, 2008, at 6:44 PM, Jason wrote: Why doesn't (count (doall (range 100))) cause an out-of memory error? doall says it causes the entire seq to reside in memory at one time, yet: (range n) produces an object that is a seq, not just one that's seq- able. Its "rest" operation i

Curiosity: why doesn't (count (doall (range 1000000000))) exhaust memory?

2008-12-21 Thread Jason
Yet another question, this time just a curiosity. Sorry for the plethora of posts, but I'm trying to make sure I understand lazy seqs properly. Why doesn't (count (doall (range 100))) cause an out-of memory error? doall says it causes the entire seq to reside in memory at one time, yet:

Re: bit-and, bit-or arity question

2008-12-21 Thread Randall R Schulz
On Sunday 21 December 2008 15:14, ntu...@googlemail.com wrote: > Why do "bit-or" and "bit-and" only accept 2 arguments? "or" and "and" > accept an arbitrary number and I think it is useful to modifiy "bit- > or" and "bit-and" to accept 2 or more, for example: > > (defn my-bit-or [x y & rest] > (

Re: SPARQL DSL - a humble request for review and guidance

2008-12-21 Thread Michael Wood
On Sun, Dec 21, 2008 at 7:03 PM, Adam Harrison (Clojure) wrote: [...] > (defmacro where [& triples] > `(let [encode# (fn [x#] (cond (and (symbol? x#) (= (first (name x#)) > \?)) (name x#) > (integer? x#) (str "\"" x# "\"^^xsd:integer") > (

bit-and, bit-or arity question

2008-12-21 Thread ntu...@googlemail.com
Why do "bit-or" and "bit-and" only accept 2 arguments? "or" and "and" accept an arbitrary number and I think it is useful to modifiy "bit- or" and "bit-and" to accept 2 or more, for example: (defn my-bit-or [x y & rest] (reduce #(clojure.lang.Numbers/or %1 %2) (list* x y rest))) What does the

Re: SPARQL DSL - a humble request for review and guidance

2008-12-21 Thread Brian Sletten
Adam, I just joined the list, but I am very interested in working with you on the SPARQL DSL. Let me catch up on what you've written and we'll muddle through it together. Glad to see there are other Clojure-loving SemWeb nerds around here. :) --~--~-~--~~~---~--~-

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Stephen C. Gilardi
On Dec 21, 2008, at 4:43 PM, Stephen C. Gilardi wrote: On Dec 21, 2008, at 4:40 PM, Rich Hickey wrote: If main doesn't match the behavior of Repl and Script in this area when run in repl or script modes respectively, it needs to. Repl calls exit, Script does not. OK, I'll fix that. This is

Re: "Lazy" inconsistency between map and mapcat; lazy concatenation

2008-12-21 Thread Jason
Also, on a related note, lazy-cat always evaluates its first argument: user> (do (lazy-cat (do (prn "1") (list 1)) nil) nil) "1" nil user> (do (lazy-cons (do (prn "1") (list 1)) nil) nil) nil which is confusing given its documentation: user> (doc lazy-cat) - clojure.core

Re: namespace function

2008-12-21 Thread Randall R Schulz
On Sunday 21 December 2008 13:35, Mark Volkmann wrote: > Why do I get an IncompatibleClassChangeError below? I'm using > revision 1180. > > (def my-map {:a 1 :b 2}) > (namespace my-map) > java.lang.IncompatibleClassChangeError (NO_SOURCE_FILE:0) I'm not sure about that specific error, though I'v

Re: namespace function

2008-12-21 Thread Stephen C. Gilardi
On Dec 21, 2008, at 4:35 PM, Mark Volkmann wrote: Why do I get an IncompatibleClassChangeError below? I'm using revision 1180. (def my-map {:a 1 :b 2}) (namespace my-map) java.lang.IncompatibleClassChangeError (NO_SOURCE_FILE:0) I got a more informative message, with the difference perhap

namespace function

2008-12-21 Thread Mark Volkmann
Why do I get an IncompatibleClassChangeError below? I'm using revision 1180. (def my-map {:a 1 :b 2}) (namespace my-map) java.lang.IncompatibleClassChangeError (NO_SOURCE_FILE:0) -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ You received this

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Stephen C. Gilardi
On Dec 21, 2008, at 4:40 PM, Rich Hickey wrote: If main doesn't match the behavior of Repl and Script in this area when run in repl or script modes respectively, it needs to. Repl calls exit, Script does not. OK, I'll fix that. --Steve smime.p7s Description: S/MIME cryptographic signatur

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Rich Hickey
If main doesn't match the behavior of Repl and Script in this area when run in repl or script modes respectively, it needs to. Repl calls exit, Script does not. Rich On Dec 21, 2008, at 4:30 PM, Stephen C. Gilardi wrote: > Based on the bottom of the ruby code example on this page: > > http

Re: SPARQL DSL - a humble request for review and guidance

2008-12-21 Thread Daniel E. Renfer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/21/2008 12:03 PM, Adam Harrison (Clojure) wrote: > > Hi folks, > > First let me say 'Thankyou very much' for Clojure - it has enabled me to > finally take the plunge into learning a Lisp without feeling like I'm > abandoning a ten year inves

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Stephen C. Gilardi
Based on the bottom of the ruby code example on this page: http://rjack.rubyforge.org/jetty/classes/Jetty/ServerFactory.html A first guess is that this would work: (.start server) (.join server) Join will wait for the thread to exit before continuing. That code makes sense if

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Mark McGranaghan
I have another quick observation: The (System/exit 0) bit at the end of the main function changes the behavior of some scripts I have for starting Jetty servers. The scripts basically end with (.start server), were server is a Jetty Server instance, and previously would run until control-C'd from

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Mark McGranaghan
Steve, Your version of repl_ln.clj works for me: 1:1 user=> (+ 1 2) 3 1:2 user=> (throw (Exception. "test")) java.lang.Exception: test (repl-1:2) Thanks again, - Mark On Sun, Dec 21, 2008 at 3:47 PM, Stephen C. Gilardi wrote: > Hi Mark, > > Thanks for your work on polishing up Clojure's entry

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Stephen C. Gilardi
Hi Mark,Thanks for your work on polishing up Clojure's entry point situation.You're welcome. Thanks very much for the feedback.I've applied your patch and tried a series of typical entry pointscenarios; all but one of them worked for me. Just for the record,here is what did work:- Using "-h" to get

Re: gen-class from REPL

2008-12-21 Thread Stuart Sierra
Hi Bill, I think "compile" calls "load-lib", or something like that, so it assumes there's a source file somewhere. -Stuart Sierra On Dec 21, 3:19 pm, ".Bill Smith" wrote: > Is this a valid thing to do from the REPL? > > $ java -jar clojure.jar > Clojure > user=> (ns clojure.examples.hello >

Re: clojure.contrib.enum Exception

2008-12-21 Thread Stuart Sierra
Whoops, looks like contrib.enum doesn't work with the new AOT- compilation. I wrote it, so I'll take a look, but for the mean time... don't use it. :) -Stuart Sierra On Dec 21, 12:56 am, Andrew Baine wrote: > Any help is much appreciated: > > user> (require :verbose 'clojure.contrib.enum) > (

"Lazy" inconsistency between map and mapcat; lazy concatenation

2008-12-21 Thread Jason
Hi, I noticed that while map produces a fully lazy result, mapcat always evaluates the first three terms when it is called, and is lazy thereafter. This can be confusing, and is sometimes not desired behavior. For example, I'm trying to generate a lazy infinite seq corresponding to a tree trave

Re: (Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Mark McGranaghan
Hi Steve, Thanks for your work on polishing up Clojure's entry point situation. I've applied your patch and tried a series of typical entry point scenarios; all but one of them worked for me. Just for the record, here is what did work: - Using "-h" to get help - Using no options to boot into a r

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread Randall R Schulz
On Sunday 21 December 2008 11:33, chris wrote: > ... > > That answers my question. Don't use a namespace, and the keyword is > global. Pass in a namespace, and the keyword is in that namespace. Yes, the default namespace for keywords is different than for symbols, which is why the ::keyword fo

gen-class from REPL

2008-12-21 Thread .Bill Smith
Is this a valid thing to do from the REPL? $ java -jar clojure.jar Clojure user=> (ns clojure.examples.hello (:gen-class)) (defn -main [greetee] (println (str "Hello " greetee "!"))) nil clojure.examples.hello=> #'clojure.examples.hello/-main clojure.examples.hello=> (compile 'clojure.e

Re: clojure.lang.Script

2008-12-21 Thread Parth Malwankar
On Dec 21, 8:21 pm, Emeka wrote: > > java -cp clojure.jar clojure.lang.Script yourapp.clj > > In my SciTe I added  java -cp clojure.jar clojure.lang.Script $(FilePath) > plus others and when I click 'GO' or F5 instead of running the code and > printing result. I have > > > > > java -cp clojure.

Re: How to encapsulate local state in closures

2008-12-21 Thread Parth Malwankar
On Dec 21, 11:47 pm, chris wrote: > I would like to be able to encapsulate local state in a closure. > Specifically, I would like a function that returns an incrementing > integer, thus: > (test_func) > 1 > (test_func) > 2 > What is the best way to go about this?  With local bindings is failing

(Updated) Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-21 Thread Stephen C. Gilardi
The enclosed updated patch: unified-main-2.patch addresses all defects I am aware of in its predecessor. On Dec 17, 2008, at 6:10 PM, Stephen C. Gilardi wrote: On Dec 17, 2008, at 2:27 PM, Rich Hickey wrote: In what way is that the right thing to do? The idea was that the sequence of top

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread chris
user> (namespace :test) nil So it doesn't live in a namespace. But it is a distinct entity; a comparable value. user> (= :test :test) true user> (= :test :bar) false user> (keyword "test") :test user> (namespace (keyword "test")) nil user> (namespace (keyword "test" "user")) "test" user> (name

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread Randall R Schulz
On Sunday 21 December 2008 10:18, chris wrote: > Right, waking up a bit. > > I would like, at some point, to serialize a bunch of structures to a > byte stream. > > They are the mapped structs (struct :data1 :data2). > > Lets say I would like to do this generically, I need a function that > takes

Re: SPARQL DSL - a humble request for review and guidance

2008-12-21 Thread .Bill Smith
> I am now spoiled forever, and although my powers are weak, I realise I > have become one of those smug Lisp types condemned to look down on all > other programming languages for the rest of their lives. Beware, Grasshopper. The world is more complicated than you know. --~--~-~--~~-

How to encapsulate local state in closures

2008-12-21 Thread chris
I would like to be able to encapsulate local state in a closure. Specifically, I would like a function that returns an incrementing integer, thus: (test_func) 1 (test_func) 2 What is the best way to go about this? With local bindings is failing and I can't figure just why... (def test_closure

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread chris
Right, waking up a bit. I would like, at some point, to serialize a bunch of structures to a byte stream. They are the mapped structs (struct :data1 :data2). Lets say I would like to do this generically, I need a function that takes a keyword and returns an integer. I will write out a mapping f

SPARQL DSL - a humble request for review and guidance

2008-12-21 Thread Adam Harrison (Clojure)
Hi folks, First let me say 'Thankyou very much' for Clojure - it has enabled me to finally take the plunge into learning a Lisp without feeling like I'm abandoning a ten year investment in the Java platform and its libraries. I bought 'Practical Common Lisp' about eighteen months ago and read

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread Randall R Schulz
On Sunday 21 December 2008 09:33, chris wrote: > This is not what I would expect: > > user> (== :test :test) > false user=> (doc ==) - clojure.core/== ([x] [x y] [x y & more]) Returns non-nil if nums all have the same value, otherwise false To be clear: == is for numer

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread chris
Ah, user> (= :float :float) true Chris On Dec 21, 10:33 am, chris wrote: > This is not what I would expect: > > user> (== :test :test) > false > > I am trying to use keywords as enumerations to texture types.  I want > to know if two textures are comparable, thus I would expect > (== :rgba :rgb

Behavior of equals (==) w/r/t keywords

2008-12-21 Thread chris
This is not what I would expect: user> (== :test :test) false I am trying to use keywords as enumerations to texture types. I want to know if two textures are comparable, thus I would expect (== :rgba :rgba) to return true. I may have missed something, but it seems like Rich did away with the

Re: class diagram

2008-12-21 Thread Albert Cardona
> Also, is there a Clojure function that outputs all the classes and > interfaces in the inheritance hierarchy of a given class or interface? > Isn't that "ancestors"? user=> (ancestors String) #{java.lang.Object java.lang.CharSequence java.io.Serializable java.lang.Comparable} -- Alber

Re: non-seq collections

2008-12-21 Thread Meikel Brandmeyer
Hi Mark, Am 21.12.2008 um 16:51 schrieb Mark Volkmann: Until this morning I was under the impression that ALL Clojure collections are sequences. Now I understand (from the screencast "Clojure Data Structures - Part 2") that vectors and maps are not and that you need to call "seq" on them to get

Re: non-seq collections

2008-12-21 Thread Randall R Schulz
On Sunday 21 December 2008 07:51, Mark Volkmann wrote: > Until this morning I was under the impression that ALL Clojure > collections are sequences. Sequences are views of collections (sequential ones, if you can believe it!). All collections can be sequenced, but they are not to be equated. >

Re: class diagram

2008-12-21 Thread Randall R Schulz
On Sunday 21 December 2008 07:44, Mark Volkmann wrote: > Somebody created a class diagram for the Java classes and interfaces > in the Clojure implementation, I believe using GraphViz, and I'm > having trouble finding it now. Can someone share the URL? > > Also, is there a Clojure function that ou

Re: class diagram

2008-12-21 Thread Lauri Oherd
It was made by Chouser: http://groups.google.com/group/clojure/browse_thread/thread/c7ae505290cdf59a/742f3b5f740e4592 Lauri On Sun, Dec 21, 2008 at 5:44 PM, Mark Volkmann wrote: > > Somebody created a class diagram for the Java classes and interfaces > in the Clojure implementation, I believe

non-seq collections

2008-12-21 Thread Mark Volkmann
Until this morning I was under the impression that ALL Clojure collections are sequences. Now I understand (from the screencast "Clojure Data Structures - Part 2") that vectors and maps are not and that you need to call "seq" on them to get a sequence representation. What are some situations where

class diagram

2008-12-21 Thread Mark Volkmann
Somebody created a class diagram for the Java classes and interfaces in the Clojure implementation, I believe using GraphViz, and I'm having trouble finding it now. Can someone share the URL? Also, is there a Clojure function that outputs all the classes and interfaces in the inheritance hierarch

Re: clojure.lang.Script

2008-12-21 Thread Emeka
> > > java -cp clojure.jar clojure.lang.Script yourapp.clj > In my SciTe I added java -cp clojure.jar clojure.lang.Script $(FilePath) plus others and when I click 'GO' or F5 instead of running the code and printing result. I have > > java -cp clojure.jar clojure.lang.Script C:\janus\myapp.clj

Re: Clojure vs. CL macros question

2008-12-21 Thread Rich Hickey
On Dec 19, 2:05 pm, Stuart Halloway wrote: > According to Paul Graham's On Lisp, macroexpanders should be purely > functional, and you should not count on how often a macro gets > expanded. This seems like a reasonable restriction for Clojure too. > However, Chouser posted an example that shows

Re: *compile-path* hardwired in compiled Clojure core

2008-12-21 Thread Rich Hickey
On Dec 19, 3:45 pm, Stuart Sierra wrote: > Hi Rich & all, > While compiling Clojure, It seems that *compile-path* is being set to > the absolute path to "classes" within the Clojure source > distribution. That is: > > unzip clojure_20081217.zip > cd clojure > java -jar clojure.jar > Clojure >

Re: clojure.lang.Script

2008-12-21 Thread James Reeves
On Dec 20, 5:07 pm, janus wrote: > I wanted to use clojure.lang.Script in order to use SciTe editor, > however, I am not getting any result. Has anyone used Script before, > if yes, please I need your help. First ,I need direction on how to use > it .Or anyone really used Scite with  Clojure, if

Re: recur rationale?

2008-12-21 Thread verec
> You propose a clever trick, but unfortunately it would require even   > more cleverness. What if foo, bar, and baz live in different   > libraries, and you reload one of the libraries as part of a dynamic   > update at runtime? How would the inline copies know they needed to   > update? Annotat