Re: Should I better use a state monad (and how)?

2012-04-15 Thread Nicolas Buduroi
I couldn't resist writing some more macros!

(defmacro << [k-or-ks f]
  `(fn [state#]
 (update-in state#
~(if (vector? k-or-ks)
   k-or-ks
   (vector k-or-ks))
~f)))

(defn >>* [state form]
  (condp = (first form)
'>>> `(fn [~state] ~@(rest form) ~state)
'<<< `(fn [~state] ~@(rest form))
form))

(defmacro >> [state & forms]
  (reduce #(list (if (#{'<< 'fn 'fn*
'clojure.core/fn
'clojure.core/fn*} (first %2))
   %2
   `(fn [s#] ~%2 s#)) %)
  (conj (map (partial >>* state) forms)
state)))

With those the resulting code looks pretty clean and remain purely 
functional:

  (next-phase [state]
(>> state
  (stop-timer)
  (<< :phases #(conj (vec (rest %)) (first %)))
  (>>> (log :info "change phase to %s" (-> state :phases first key)))
  (<<< (start-phase state

Now, I'd need to find better names!

On Sunday, April 15, 2012 11:25:21 PM UTC-4, Nicolas Buduroi wrote:
>
> I'm working on a turn-based game and I'm looking for a good way to manage 
> states. In the game each turn is composed of multiple phases. I started by 
> using atoms for the phases field (this is a sequence of functions) in a 
> record and realized that it wouldn't be ideal to keep track of states in 
> the case where I'd need to keep a snapshot of every phases. Here's the 
> original code I had:
>
> (defrecord Game [phases]
>   (next-phase [this]
> (stop-timer)
> (swap! phases #(conj (vec (rest %)) (first %))) 
> (log :info "change phase to %s" (key (first @phases)))
> (start-phase this))
>
> I then started to think that this would be a good opportunity to use a 
> state monad. I've tried to reimplement the above code using the algo.monads 
> library but the result was less than satisfactory (probably due to my own 
> shortcoming), here's the monadic version:
>
> (defrecord Game [phases]
>
>   (next-phase [this]
> (->
>  ((domonad state-m
> [_ (fn [s] (stop-timer) [s s])
>  _ (update-state
> (fn [s]
>   (update-in s [:phases]
>  #(conj (vec (rest %)) (first %)
>  _ (fn [s]
>  (log :info "change phase to %s" (key (first (:phases s [s 
> s])]
> nil)
>   state)
>  second
>  start-phase))
>
> As my code probably doesn't need the full power of the state monad, I 
> tried to write a lighter-weight version using the following macro:
>
> (defmacro >> [& state-and-forms]
>   (reduce #(list (if ('#{fn fn*} (first %2))
>%2
>`(fn [s#] ~%2 s#)) %)
>   state-and-forms))
>
> Which let me write:
>
>   (next-phase [state]
> (>> state
>  (stop-timer)
>  (fn [s] (update-in s [:phases] #(conj (vec (rest %)) (first %
>  #(do (log :info "change phase to %s" (key (first (:phases % %)
>  #(start-phase %)))
>
> With some more helper macro this version looks promising. In the end I 
> wonder if there's some Clojure feature I'm overlooking or if I should 
> rethink the whole solution? Is there a better way to accomplish this?
>
>
>

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Should I better use a state monad (and how)?

2012-04-15 Thread Nicolas Buduroi
On Monday, April 16, 2012 12:08:30 AM UTC-4, kovasb wrote:
>
> You can try using the in-memory version of Datomic.
>
> Besides keeping track of the state at every point, it can help with
> the reasoning about what should happen next for each state change.
>

Hum, I hadn't though about using a service like Datomic at all, but I'm not 
sure it fill the bill has it looks like a very heavyweight solution. I'm 
not even sure where to start to understand what Datomic is! 

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Should I better use a state monad (and how)?

2012-04-15 Thread Nicolas Buduroi
I'm working on a turn-based game and I'm looking for a good way to manage 
states. In the game each turn is composed of multiple phases. I started by 
using atoms for the phases field (this is a sequence of functions) in a 
record and realized that it wouldn't be ideal to keep track of states in 
the case where I'd need to keep a snapshot of every phases. Here's the 
original code I had:

(defrecord Game [phases]
  (next-phase [this]
(stop-timer)
(swap! phases #(conj (vec (rest %)) (first %))) 
(log :info "change phase to %s" (key (first @phases)))
(start-phase this))

I then started to think that this would be a good opportunity to use a 
state monad. I've tried to reimplement the above code using the algo.monads 
library but the result was less than satisfactory (probably due to my own 
shortcoming), here's the monadic version:

(defrecord Game [phases]

  (next-phase [this]
(->
 ((domonad state-m
[_ (fn [s] (stop-timer) [s s])
 _ (update-state
(fn [s]
  (update-in s [:phases]
 #(conj (vec (rest %)) (first %)
 _ (fn [s]
 (log :info "change phase to %s" (key (first (:phases s [s s])]
nil)
  state)
 second
 start-phase))

As my code probably doesn't need the full power of the state monad, I tried 
to write a lighter-weight version using the following macro:

(defmacro >> [& state-and-forms]
  (reduce #(list (if ('#{fn fn*} (first %2))
   %2
   `(fn [s#] ~%2 s#)) %)
  state-and-forms))

Which let me write:

  (next-phase [state]
(>> state
 (stop-timer)
 (fn [s] (update-in s [:phases] #(conj (vec (rest %)) (first %
 #(do (log :info "change phase to %s" (key (first (:phases % %)
 #(start-phase %)))

With some more helper macro this version looks promising. In the end I 
wonder if there's some Clojure feature I'm overlooking or if I should 
rethink the whole solution? Is there a better way to accomplish this?


-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Logic puzzle: send more money performance

2012-04-12 Thread Nicolas Buduroi
Hi, I translated[1]the solution to the "send more money" logic puzzle from
the cKanren paper in core.logic and I was wondering about its expected
performance. I wasn't patient enough to run it without giving it some
clues, giving it the S E N D digits make it run in around 36s on my
machine, but then giving it just three digits make it goes on for minutes.

So I'm curious about how much time would be needed to run this solution
without any clues. Is its performance expected or I've made some kind of
mistake? Also does anyone know of ways to optimize this code?

[1]: https://gist.github.com/2364695

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: A simple (and naive) online whiteboard using Aleph & ClojureScript

2012-03-31 Thread Nicolas Buduroi
On Saturday, March 31, 2012 7:35:03 PM UTC-4, jun lin wrote:
>
> Maybe you can create an online demo site?
>
 
Yes good idea, I'll try to get it running on Heroku tomorrow.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

A simple (and naive) online whiteboard using Aleph & ClojureScript

2012-03-31 Thread Nicolas Buduroi
Hi everyone, I've been experimenting with ClojureScript and Aleph lately
and made this sample application. It's a naive implementation of an online
whiteboard. It's under a hundred line of code so it's a quick read:

https://github.com/budu/board

The Clojure web development story is getting better and better everyday,
bit thanks to everyone involved!

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure-opennlp

2012-02-12 Thread Nicolas Buduroi
Just for the record, it seems this issue has been fixed today:

https://github.com/dakrone/clojure-opennlp/commit/887add29a1fbc3b4aac7d12f5cbc52c43c6a7dcd

Try out the  the new 0.1.8 version.


On Feb 11, 9:20 am, "Jim foo.bar"  wrote:
> HI everyone,
>
> I was just wondering whether anyone has used the clojure-opennlp
> wrapper for multi-word named entity recognition (NER)? I am using it
> to train a drug finder from my private corpus and even though i get
> correct behavior when using the command line tool of apache openNLP
> when trying to use the API i only get single-words entities
> recognised!!! I've opened up a thread in the official mailing list
> because initially i thought there was a genuine problem with openNLP
> but since the command line tool does exactly what i want i'm starting
> to think that it might not be openNLP's fault but either in my code or
> in the clojure wrapper...
>
> I've followed both the official tutorials and the wrapper
> documentation and thus i am doing everything as instructed...
> I know the name finder expects tokenized sentences and i am indeed
> passing tokenized sentences like this:
>
> (defn find-names-model [text]
> (map #(drug-find (tokenize %))
>              (get-sentences text)))
>
> It is very strange because i am getting back "Folic" but not "Folic
> acid" regardless of using the exact same model i used with the command
> line tool...
>
> Any help will be greatly appreciated...
> Regards,
> Jim

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Clojure/ClojureScript code and refs

2011-12-20 Thread Nicolas Buduroi
I'm thinking about writing some code that would better be
transactional and thus use refs in a multi-threaded environment like
Clojure. But then it would also be nice to be able to run that code as
ClojureScript code (which obviously doesn't support refs) so I'm
wondering if anybody has worked on that kind of problem. Would
encapsulating refs operations inside macros that detect if refs are
available and if not would fall back to a simple atom (ignoring
transactional stuff and replacing alter/commute by swap!) be a good
way?

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


What is the cost of calling require for something that already have been loaded?

2011-11-12 Thread Nicolas Buduroi
I'm using a function in Lobos to automatically load the backend code
associated to a specific database and wonder if I should track what is
loaded to avoid repeatedly calling `require`? This isn't an issue
currently as performance isn't a problem for this library, but this
might change in the future.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Waiting for swank-clojure to be ready.

2011-10-03 Thread Nicolas Buduroi
Thanks, this was really helpful. Here's what my shortcut looks like now:

(global-set-key
 [f8]
 '(lambda () (interactive)
(start-process "swank-clojure"
   "*swank-clojure*"
   "~/.lein/bin/swank-clojure")
(set-process-filter (get-buffer-process "*swank-clojure*")
(lambda (process output)
  (when (string-match "Connection opened on" output)
(slime-connect "localhost" "4005")
(with-current-buffer (slime-output-buffer t)
  (setq default-directory root))
(set-process-filter process nil))


On Mon, Oct 3, 2011 at 8:33 PM, Phil Hagelberg  wrote:

> On Mon, Oct 3, 2011 at 5:12 PM, Nicolas Buduroi 
> wrote:
> > Hi, I'm currently redoing my Clojure setup and I wonder how to make Emacs
> > wait for swank-clojure to be ready before calling slime-connect.
>
> You can use M-x clojure-jack-in, but that only works for Leiningen
> projects out of the box. The other place I'd look is M-x
> durendal-jack-in, which was its mostly-deprecated precursor. It has a
> less comprehensive bootstrap mechanism, but if you've already got
> slime-repl installed then that shouldn't be an issue.
>
> https://github.com/technomancy/durendal/blob/master/durendal.el#L82
>
> -Phil
>
> --
> 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
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Waiting for swank-clojure to be ready.

2011-10-03 Thread Nicolas Buduroi
Hi, I'm currently redoing my Clojure setup and I wonder how to make Emacs 
wait for swank-clojure to be ready before calling slime-connect. I've added 
a shortcut to start swank-clojure:

(global-set-key
 [f8]
 '(lambda () (interactive)
(start-process "swank-clojure"
   "swank-clojure"
   "~/.lein/bin/swank-clojure")
;; should wait for swank-clojure to be ready
(slime-connect "127.0.0.1" "4005")))

but I don't have any idea how to do the waiting part.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Monadic implementation of the Shunting-yard algorithm

2011-05-03 Thread Nicolas Buduroi
I've refactored your code into this: https://gist.github.com/954579

On Tuesday, 3 May 2011 15:02:02 UTC-4, odyssomay wrote:
>
> I wrote a simple implementation: 
> http://gist.github.com/953966<https://gist.github.com/953966>
> (only supports operators)
> It's not very elegant (I don't know how to use fnparse..), but it is 
> functional. 
> What it does is find out what the next element in the operator stack and 
> the out stack should be, and then recursively update the stacks and output 
> the finished out stack.
>
> As I said I don't know how to use fnparse and therefore I couldn't really 
> understand your code.
> Either way I hope that this code helps in some way.. ;) 
>
> Jonathan
>
> On Tue, May 3, 2011 at 2:23 AM, Nicolas Buduroi  wrote:
>
>> Hi, I'm working on my parsing skills using fnparse 2.2.7 and have written 
>> the following implementation of the Shunting-yard algorithm:
>>
>> https://gist.github.com/952607
>>
>> I plan to make a lightning talk about monadic parser at the next Bonjure 
>> meeting and I'd like to hear what people here think about that 
>> implementation first.
>>
>> It is more imperative that I would like, but that is the nature of this 
>> algorithm I think. Would a non-monadic implementation would be better in 
>> some ways? How would you make this code more flexible, faster and/or 
>> cleaner? Is there a more functional way of writing it?
>>
>> Thanks in advance for any comments!
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
>
>

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Monadic implementation of the Shunting-yard algorithm

2011-05-03 Thread Nicolas Buduroi
One small question, how would you modify your version to output 
s-expressions?

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Monadic implementation of the Shunting-yard algorithm

2011-05-03 Thread Nicolas Buduroi
On Tuesday, 3 May 2011 15:02:02 UTC-4, odyssomay wrote:
>
> I wrote a simple implementation: 
> http://gist.github.com/953966
> (only supports operators)
> It's not very elegant (I don't know how to use fnparse..), but it is 
> functional. 
> What it does is find out what the next element in the operator stack and 
> the out stack should be, and then recursively update the stacks and output 
> the finished out stack.
>
> As I said I don't know how to use fnparse and therefore I couldn't really 
> understand your code.
> Either way I hope that this code helps in some way.. ;)
>

This is great, hadn't thought about using a protocol for this!

I'll improve both versions to be able to compare them on equal ground and to 
see how they cope with adding more features. Although in the end, I think 
the recursive one will be faster while the monadic one will be more 
composable,

 Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Monadic implementation of the Shunting-yard algorithm

2011-05-02 Thread Nicolas Buduroi
Hi, I'm working on my parsing skills using fnparse 2.2.7 and have written
the following implementation of the Shunting-yard algorithm:

https://gist.github.com/952607

I plan to make a lightning talk about monadic parser at the next Bonjure
meeting and I'd like to hear what people here think about that
implementation first.

It is more imperative that I would like, but that is the nature of this
algorithm I think. Would a non-monadic implementation would be better in
some ways? How would you make this code more flexible, faster and/or
cleaner? Is there a more functional way of writing it?

Thanks in advance for any comments!

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.contrib.sql => clojure.java.jdbc - looking for feedback!

2011-04-27 Thread Nicolas Buduroi
On Tue, Apr 26, 2011 at 2:16 PM, lispnik  wrote:

> ...Liquibase so I can get rollbacks and branching easily.
>

Off-topic question: What does branching mean in the context of Liquidbase?


> I suggest not getting into the SQL in sexps/naming strategies business.
> That kind of thing doesn't really fall under the scope of JDBC, which
> clojure.java.jdbc should be modeled around.
>

I'm with you on that one.


> The row as a structmap works well. 90% of the time I use use "select
> foo_bar as \"foo-bar\"..." to get a Clojure-ish map key.  Other 10% I might
> also have to apply a transformation to the row, especially when working with
> legacy databases.  I thought having something like:
>
>(with-query-results rs transform-fn ["
> ..." params...]
>  (first rs))
>
> So that by the time I call (first rs), transform has already been applied,
> but (map transform-fn rs) is trivial enough also.



Is that good enough for you:

https://github.com/clojure/java.jdbc/issues/7#issuecomment-1060402

I could always add an extra optional argument to with-query-results.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.contrib.sql => clojure.java.jdbc - looking for feedback!

2011-04-25 Thread Nicolas Buduroi
On Mon, Apr 25, 2011 at 12:23 PM, Michael  wrote:

> I was wondering if c.j.jdbc could provide some help in composing sql
> fragments, but I'm not sure what form it should take or if core
> clojure would suffice. We would have looked into ClojureQL, but it
> doesn't directly support Oracle. Would also be curious to know how
> people use clojure to compose sql fragments.
>

For Lobos I've written a compiler which transform an AST into SQL DDL
statements. You can have a look at the compiler here:

https://github.com/budu/lobos/blob/master/src/lobos/compiler.clj

It's based on the legacy ClojureQL project, I've written some helpers but
it's mostly using Clojure string facilities. So I'm not sure it would be a
good idea to include such helpers inside c.j.j, outside the as-identifier
function here:

http://dev.clojure.org/jira/browse/CLJ-778

As for the new ClojureQL project, it would certainly be feasible to add
support for Oracle, but I find it hard to work with its current "simplified"
compiler. I've tried to add stropping to ClojureQL multiple times, but gave
up in the end.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Intro to Live Programming with Overtone

2011-04-24 Thread Nicolas Buduroi
Overtone really looks awesome, looking forward to use it! Thanks for the 
video.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.contrib.sql => clojure.java.jdbc - looking for feedback!

2011-04-23 Thread Nicolas Buduroi
On Saturday, 23 April 2011 17:33:48 UTC-4, Sean Corfield wrote:
>
> Well, not all DB stropping approaches are simply (str q ident q) -

there's also select [name] from [table] style quoting and that part is 

DB vendor specific I believe?


Oh yeah, I forgot SQL Server again! 

(with-quoted-identifiers \" escape-fn ...)
(with-quoted-identifiers [\[ \]] escape-fn ...)

Else there's just MySQL which use the backquote "`" and, if I'm not 
mistaken, modern SQL Server versions also accept the double-quote.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.contrib.sql => clojure.java.jdbc - looking for feedback!

2011-04-23 Thread Nicolas Buduroi
On Saturday, 23 April 2011 16:15:57 UTC-4, Sean Corfield wrote:
>
> Should [:some-schema :a-table] become "some_schema.a_table"?
>
> How do people want to handle mixed case entity names? Do we want
> something like Hibernate Naming Strategies?
>
I hadn't thought about naming strategies that could be a great idea! It 
would the best for everybody and it wouldn't impose some arbitrary name 
transformation. It could be implementation as a simple macro:

(with-naming-strategy #(string/replace ...)
   ...)
 
After rethinking about quoted identifiers, I realized they would probably 
need an extra argument to escape the quotes found inside an identifier if 
there are some.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.contrib.sql => clojure.java.jdbc - looking for feedback!

2011-04-23 Thread Nicolas Buduroi

>
> I'm going to be working on clojure.java.jdbc, with Steve Gilardi, and
> I'd like to get people's feedback on what you like / what you don't
> like / what you need changed or added in clojure.contrib.sql so that
> clojure.java.jdbc can become what the community wants for 1.3.0.


What I would like to see added is a global connection mechanism like in 
ClojureQL and Lobos. We could even add a connection pool behind the scene.

Then there's support for quoted identifiers, maybe something like:

  (with-quoted-identifiers \" ...)

And for qualified identifiers we could let c.j.j accept vectors of 
identifiers so that [:some_schema :a_table] would become 
"some_schema.a_table".

I could provide an implementation if you'd like.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ANN: pallet.thread-expr, a macro lib for use with -> argument threading

2011-04-22 Thread Nicolas Buduroi
This is a very interesting set of macros, I'll certainly use some of them. 
In fact I think this library should at least make it to clojure.contrib!

BTW, there's a small error in the when-not-> docstring, the result should be 
1.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

ANN: Lobos 0.7, a SQL database schema manipulation library

2011-04-19 Thread Nicolas Buduroi
Hi, I've released version 0.7 of Lobos today, enjoy it. I've posted a more 
comprehesive announcement on the new Lobos Google Group:

https://groups.google.com/forum/#!topic/lobos-library/mTL9HLiHOrA

If you have questions, suggestions, comments or insults please post them 
there. 

For those who hadn't heard about Lobos before this post (most of you I 
suppose) feel free to visit one of the following link:

Website: http://budu.github.com/lobos/index.html
GitHub Repo: https://github.com/budu/lobos
Google Group: http://groups.google.com/group/lobos-library

Future announcements will be only posted on the Lobos Google Group.

Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reading back record instances

2011-01-23 Thread Nicolas Buduroi
I've been using records extensively lately and I think they are a
really great addition to Clojure. One problem I'm facing tough is to
read them back once printed to a file (or anything else). All others
Clojure data structures are supported by the reader, but not records.

One way to do this would be to write my own printer to output
constructor forms for the given records. That should be working as the
current implementation returns the keys in order. Am I missing
something? Is there a better way?

Regards, budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


What's the best way to hide transaction error output from contrib.sql

2011-01-14 Thread Nicolas Buduroi
By design contrib.sql, when executing a batch of commands, uses
transaction and if an exception is raised, it is printed to the error
output stream. This is very practical but when you are using such code
in a test that is meant to throw an exception it adds a lot of noise
to the tests output. I was thinking about solving this by redirecting
the error output stream, but then it might hide some errors I'd like
to know about. Does anyone have a better solution to this (minor)
issue?

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: REPL+Laziness: the worst combination ever!

2011-01-08 Thread Nicolas Buduroi
On Jan 8, 12:25 pm, Brian Goslinga  wrote:
> I find that if your code is functional, laziness works quite well
> (except for the rare expensive function + chunking problem).
>
> Perhaps your code isn't very functional? (your mention of binding
> suggests that)

That's a valid observation, most of the time I hit that kind of
problems, I'm using code that really isn't functional. But the reason
it's not functional is mainly to make it more practical while used at
the REPL, so I've mostly fallen victim to a catch-22!

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: REPL+Laziness: the worst combination ever!

2011-01-08 Thread Nicolas Buduroi
Didn't knew about scope, it looks like an interesting feature. Still
as you point this is pretty much a problem BKAC!

On Jan 8, 12:33 pm, Stuart Halloway  wrote:
> One goal of resource scopes [1] is to help with scoping activities at the 
> REPL. That said, I think this is a "ramping up" problem -- I rarely if ever 
> hit it anymore.
>
> Stu
>
> [1]http://dev.clojure.org/display/design/Resource+Scopes
>
> > I've been doing a lot of Clojure lately and, of all thing,
> > collection's laziness coupled with a REPL is what makes me loose the
> > most time. I really love having laziness built-in by default and I'm a
> > REPL-driven development addict, but sometimes I just loose minutes (if
> > not hours) chasing imaginary bugs that in the end only were a misuse
> > of laziness at the REPL. Still, I can't think of any way of fixing
> > this problem other than writing on top of my monitor: "If it doesn't
> > make sense it's certainly because of laziness". I wonder what other
> > people think about this problem?
>
> > P.S.: While writing this I just got an idea, but I'm not really sure
> > it's a good one. Would it be wise to make the binding macro force
> > evaluation of its body? That would be the most common mistake I make.
>
> > --
> > 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 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
>
>

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


REPL+Laziness: the worst combination ever!

2011-01-07 Thread Nicolas Buduroi
I've been doing a lot of Clojure lately and, of all thing,
collection's laziness coupled with a REPL is what makes me loose the
most time. I really love having laziness built-in by default and I'm a
REPL-driven development addict, but sometimes I just loose minutes (if
not hours) chasing imaginary bugs that in the end only were a misuse
of laziness at the REPL. Still, I can't think of any way of fixing
this problem other than writing on top of my monitor: "If it doesn't
make sense it's certainly because of laziness". I wonder what other
people think about this problem?

P.S.: While writing this I just got an idea, but I'm not really sure
it's a good one. Would it be wise to make the binding macro force
evaluation of its body? That would be the most common mistake I make.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: ClojureQL 1.0.0 now released

2011-01-05 Thread Nicolas Buduroi
Congratulation, you've finally made it!

P.S.: Nice job on the website!

On Jan 5, 9:14 am, LauJensen  wrote:
> Hey everybody,
>
> Just a quick heads up that ClojureQL 1.0.0 is now released. All
> interfaces should be final and there are no known bugs. Works out of
> the box with PostgreSQL and MySQL but the compiler is a multimethod so
> you can implement your own backend if you need to work with other
> database backends. If you do so, please consider contributing it to
> ClojureQL :)
>
> All the info is found onhttp://www.clojureql.orgbut for those of you
> who haven't tried it out yet, I recommend watching this (dated) 
> video:http://vimeo.com/16958466
>
> Big thanks to everybody who has helped make this happen,
> Lau

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Working with protocols

2010-12-22 Thread Nicolas Buduroi
On Dec 22, 1:03 pm, David Nolen  wrote:
> (Foo.) is a Java method call determined at compile-time. If you change the
> definition of the Foo type/record, create-foo will be out of date. Default
> constructor fns could alleviate this but I think some design/modularity
> issues need to be hashed out.

Yes, I've realized this when developing this project. At first, it was
less modular and I encountered much more of such issues. I also used
`immigrate` previously and that was causing troubles not only with
protocols, but with multimethods also. In the end there still appears
to be some problems while developing protocol based code in a REPL-
driven fashion. I was hoping I did something wrong that somebody could
point out.

P.S.: It makes me wonder if there's some improvements that can be done
to make that type of coding more REPL friendly.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Working with protocols

2010-12-22 Thread Nicolas Buduroi
Hi, I've been working lately on my first project (https://github.com/
budu/lobos) that use protocols. Up until now, it's been quite
infuriating, I can't stop getting seemingly random "No implementation
of method" exceptions and I really don't understand why.

For example here's what happened this morning. In this project I have
a Creatable protocol that contains only one method: create. It is
currently implemented by two records: Table and Schema. I realized I
hadn't updated the example in the readme file and while testing that
code it threw an error because I changed stuff yesterday and the
object passed to the create method was a function. I call it a second
time, after fixing (at the REPL) that mistake, and there was a bug in
my code when calling create on a MapEntry instead of a Table. I fixed
(in the file) that issue and after that all I get when trying out the
same call is "No implementation of method" for the Schema class. I
review the code (it should work), try stuff and here's the really
strange thing:

user> (create (schema :test {}) nil)
#:lobos.ast.CreateSchemaStatement{:cnx nil, :sname :test, :elements
()}
user> (create (sample-schema) nil)
; Evaluation aborted.
user> (type  (schema :test {}))
lobos.schema.Schema
user> (type (sample-schema))
lobos.schema.Schema

I wasn't able to narrow down what is the problem exactly. The only way
I found to fix that kind of problem is the kill the JVM and restart
the whole thing. This is just one example, a lot of similar situations
happened during the past few days. It may be related more to my
development environment or the way I'm using it. I'm using Clojure 1.2
and swank-clojure 1.2.1 in Emacs from which I connect to a swank
instance launched from Leiningen. I'm using the REPL to test my code
and after I've changed a file I use slime-eval-buffer. I wonder if
there's some general issues with this setup or advices on working with
protocols that can help me?

Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Catching ClassNotFoundException.

2010-12-16 Thread Nicolas Buduroi
Cool, that explain everything. Thanks

On Dec 16, 4:40 am, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 16.12.2010 um 04:16 schrieb Nicolas Buduroi:
>
> > So we could always use RT/classForName to detect what classes are
> > available. Do you think the extend-type thrown exception can possibly
> > be fixed or is it a fundamental limitation?
>
> I think the problem here is „when“ not „where.“ The „extend-type“ exception 
> is thrown when the expression is compiled because the compiler tries to 
> resolve the class. But the try catch is not in effect at that time: it just 
> gets compiled! Using RT/classForName moves the class resolution to the 
> runtime and everything works fine.
>
> You could do something like (try (load "file/with/extend-type") (catch 
> ClassNotFoundException uhOh ...)).
>
> Sincerely
> Meikel

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Catching ClassNotFoundException.

2010-12-15 Thread Nicolas Buduroi
Yeah, while doing more testing it seems to depend from where the
ClassNotFoundException is thrown. What I was trying to do at first is
to call extend-type on a Java class only if it exists. Surrounding
extend-type by a try..catch clause doesn't work here. So I tried to
simply type:

user> (try org.postgresql.PGConnection (catch ClassNotFoundException
e :catched))
; Evaluation aborted.

And, as you see, the try..catch didn't work either. But I just found
out that when using Clojure internal classForName method it can be
catched:

user> (try (clojure.lang.RT/classForName
"org.postgresql.PGConnection" ) (catch ClassNotFoundException
e :catched))
:catched

So we could always use RT/classForName to detect what classes are
available. Do you think the extend-type thrown exception can possibly
be fixed or is it a fundamental limitation?

On Dec 15, 9:27 pm, Stuart Halloway  wrote:
> Can you post an example?
>
> (try
>  (throw (ClassNotFoundException. "What makes you say that?"))
>  (catch ClassNotFoundException e
>    (println (.getMessage e
>
> > Hi, is there a way of catching ClassNotFoundException? Using
> > try..catch doesn't work!
>
> > Thanks
>
> > --
> > 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 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
>
>

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Catching ClassNotFoundException.

2010-12-15 Thread Nicolas Buduroi
Hi, is there a way of catching ClassNotFoundException? Using
try..catch doesn't work!

Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ANN: clj-help 0.2.0 released

2010-12-15 Thread Nicolas Buduroi
It appears I've forgotten to include some essential information to
this announcement! ;-)

git repo: https://github.com/budu/clj-help

leiningen: [clj-help "0.2.0"]

On Dec 15, 6:23 pm, Nicolas Buduroi  wrote:
> Hi, I've been using this small project to get some help while working
> at the REPL. It's a macro that regroups into one command a set of
> useful functions from contrib libraries while auto-quoting it's
> arguments. It's quite simple to use, after loading it "(use 'clj-
> help)", you only have to type "(help)" to print it's usage:
>
> Usage: (help  ...)
>   macro - Pretty prints the macro expansion of the given form.
>   clean - Remove a namespace (and used vars) from the given namespace,
> or *ns* if none.
>   source - Prints a string of the source code for the given symbol
>   show - Prints all instance members of the given class with an
> optional int, string or regex selector.
>   info - Analyzes the given s-expr and prints the class of the value
> it returns.
>   dir - Prints a sorted directory of public vars in the given
> namespace, or *ns* if none.
>   cp - Prints all files in the classpath, accept 'jars' or 'dirs' as
> optional argument.
>   pp - Evaluates the given form and pretty prints its result.
>   docs - Prints documentation for the public vars in the given
> namespace, or *ns* if none.
>
> Most of these already existed in the previous version. This time, I've
> added the "clean" query which remove a namespace and all it's used
> vars from a specified namespace. It can be useful while experimenting
> back and forth between two version of a same API and you used "use"
> for some reason.
>
> If you have any repetive REPL idioms which you think could be
> generally useful, I would be pleased to add it. Any ideas, corrections
> or comments would be welcome.
>
> Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


ANN: clj-help 0.2.0 released

2010-12-15 Thread Nicolas Buduroi
Hi, I've been using this small project to get some help while working
at the REPL. It's a macro that regroups into one command a set of
useful functions from contrib libraries while auto-quoting it's
arguments. It's quite simple to use, after loading it "(use 'clj-
help)", you only have to type "(help)" to print it's usage:

Usage: (help  ...)
  macro - Pretty prints the macro expansion of the given form.
  clean - Remove a namespace (and used vars) from the given namespace,
or *ns* if none.
  source - Prints a string of the source code for the given symbol
  show - Prints all instance members of the given class with an
optional int, string or regex selector.
  info - Analyzes the given s-expr and prints the class of the value
it returns.
  dir - Prints a sorted directory of public vars in the given
namespace, or *ns* if none.
  cp - Prints all files in the classpath, accept 'jars' or 'dirs' as
optional argument.
  pp - Evaluates the given form and pretty prints its result.
  docs - Prints documentation for the public vars in the given
namespace, or *ns* if none.

Most of these already existed in the previous version. This time, I've
added the "clean" query which remove a namespace and all it's used
vars from a specified namespace. It can be useful while experimenting
back and forth between two version of a same API and you used "use"
for some reason.

If you have any repetive REPL idioms which you think could be
generally useful, I would be pleased to add it. Any ideas, corrections
or comments would be welcome.

Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any demand for ClojureCLR support under slime / emacs?

2010-12-13 Thread Nicolas Buduroi
I'm interested, can't provide much programming help in this area
tough. I could always help test it.

On Dec 12, 6:36 pm, Mike K  wrote:
> I really, really want ClojureCLR to play nice with emacs the way
> Clojure does.  I've looked at the swank-clojure sources, but I really
> don't know enough about the Clojure and ClojureCLR internals to make
> much headway with this project.  Still, I'd love to help out in any
> way that I can.
>
> Is anyone else out there interested in such a project?
>
>    Mike

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Leiningen 1.2.0 released!

2010-07-18 Thread Nicolas Buduroi
That's really awesome.

I'd like to know more about the support for working on multiple
projects.

On Jul 18, 5:40 pm, Phil Hagelberg  wrote:
> I just pushed out a new release of Leiningen, a Clojure build tool,
> with lots of help from many contributors.
>
> This fixes the longstanding repl version bug, expands the flexibility
> of plugins, adds support for working on multiple projects in parallel,
> and greatly improves the documentation.
>
> Users of 1.1.0 can upgrade with "lein upgrade". Otherwise download the
> script fromhttp://github.com/technomancy/leiningen/raw/stable/bin/lein,
> place it on your $PATH and make it executable, and then run "lein
> self-install" to get going. New users should check out the new
> Tutorial:http://github.com/technomancy/leiningen/blob/master/TUTORIAL.md
>
> A complete list of the new features and bug fixes can be found 
> athttp://github.com/technomancy/leiningen/blob/master/NEWS
>
> Enjoy!
> -Phil

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Questions about destructuring maps.

2010-07-11 Thread Nicolas Buduroi
Hi, Clojure destructuring is really awesome, but I came up with a use
case for maps that isn't supported right now as far as I know.
Currently you can get the keys that you want using the :keys keyword
and the whole map using :as.

user> (let [{:keys [a b c] :as all} {:a 1 :b 2 :c 3 :d 4}]
  (println all)
  (println a b c))
{:a 1, :b 2, :c 3, :d 4}
1 2 3

My problem is that I'd like to get a map with the keys that haven't
been destructured by the :keys keyword, something like:

user> (let [{:keys [a b c] :as all :rest rst} {:a 1 :b 2 :c 3 :d 4}]
  (println all)
  (println rst)
  (println a b c))
{:a 1, :b 2, :c 3, :d 4}
{:d 4}
1 2 3

Do you think that implementing such a feature into the core/
destructure function is feasible? Is there anybody else needing it?

Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


About wrapping Java libraries.

2010-06-10 Thread Nicolas Buduroi
Hi, I've been working on some Java libraries wrappers lately and came
up with patterns on how to clojurize them. I'm wondering if you guys
got other such patterns?

Here's what I came up with:

(import 'java.lang.reflect.Modifier)

(defn clojurize-name [name]
  (apply str
(interpose "-"
  (map #(.toLowerCase %)
(re-seq #"\w[a-z]+" name)

(defn clojurize-constant-name [name]
  (.replace
   (.toLowerCase (str name)) "_" "-"))

(defn enum->map [names constants]
  (into {} (map #(vector (keyword (clojurize-constant-name %1)) %2)
names
constants)))

(defn get-static-fields [klass]
  (filter #(Modifier/isStatic (.getModifiers %))
  (.getFields klass)))

(defn wrap-enum [klass]
  (if (isa? klass Enum)
(let [cs (.getEnumConstants klass)]
  (enum->map (map str cs) cs))
(let [cs (get-static-fields klass)]
  (enum->map (map #(.getName %) cs)
 (map #(.get % nil) cs)

(defn call-method [name obj & args]
  (apply list (symbol (str "." name)) obj args))

(defmacro wrap-methods-into [obj klass & [flter rename]]
  (let [methods (filter (eval flter)
(.getDeclaredMethods (resolve klass)))]
(reduce #(into %1 (let [name (.getName %2)]
{((eval rename) name)
 (call-method name obj)}))
{}
methods)))

(defn getter? [method]
  (and (= 0 (count (.getParameterTypes method)))
   (re-seq #"get[A-Z$]" (.getName method

(defmacro wrap-getters-with [obj klass]
  `(wrap-methods-into ~obj ~klass
  getter?
  (comp keyword
(fn [s#] (.replace s# "get-" ""))
clojurize-name)))

I use this code mainly to write a Java Sound API wrapper, here's some
examples:

(def float-controls (wrap-enum javax.sound.sampled.FloatControl$Type))

user> (pprint float-controls)
{:balance #,
 :reverb-return #,
 :master-gain #,
 :aux-return #,
 :pan #,
 :reverb-send #,
 :sample-rate #,
 :aux-send #,
 :volume #}

and...

(defn format-info [audio-format]
  (into (wrap-getters-with audio-format
javax.sound.sampled.AudioFormat)
{:endianness (if (.isBigEndian audio-format)
   :big-endian
   :little-endian)}))

user> (pprint (-> "g:/test.mp3" ->stream ->format format-info))
{:channels 2,
 :frame-rate 38.28125,
 :frame-size -1,
 :sample-rate 44100.0,
 :sample-size-in-bits -1,
 :encoding #,
 :endianness :big-endian}

I'm still not sure about how to properly name the macros, if anybody
got a better idea, I sure want to ear it.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Any Clojure job out there?

2010-04-19 Thread Nicolas Buduroi
On Apr 19, 9:52 am, Joel Gluth  wrote:
> On Apr 18, 11:23 pm, Steven Shaw  wrote:
>
> In particular, I'd be thinking that places who use Hadoop (and similar
> things) would be the kind of jobs to look at, with a view to bringing
> your new favourite language in through the back door.

Yes, that seems to be a common way of getting Clojure in! I'm just
starting to look at Hadoop though, still lots to learn.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: New Recruit

2010-04-18 Thread Nicolas Buduroi
Welcome aboard!

On Apr 18, 10:54 am, llcawthorne  wrote:
> Hello!
>
> I normally lurk on lists a bit before introducing myself (if I ever
> introduce myself), but I just wanted to say hello; especially since it
> tends to take a little bit to ascertain the norms on any given list,
> but what the heck, eh?
>
> I saw Aaron Bedra's presentation on Clojure at the POSSCON in
> Columbia, and decided I could no longer put off learning more about
> Clojure.
>
> Clojure, Clojure-contrib, Compojure and Incanter installed easily
> enough on my machines last night after the conference.  Incanter looks
> neat; I always meant to learn R when I took STAT 509 (Statistics for
> Engineers) but never got around to it, and it was not required by the
> course.
>
> I am a student with a bit of experience in Haskell and Scheme and have
> used more than I care to of Java due to the cirriculum, so Clojure
> seems to roll up a lot of this previous work into a package and push
> in some as yet to be .  In my free time over the summer I hope to
> continue my explorations solo, keep an eye on the list, and maybe end
> up bugging y'all with questions when I run into them.
>
> Lewis Cawthorne
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Any Clojure job out there?

2010-04-18 Thread Nicolas Buduroi
Hi, I've been having lots of fun in the past months working in Clojure
only on my own time and wonder if there's opportunities to be paid for
it. Our community is growing everyday and I've heard that Clojure is
being more and more used in the real world. So, is there any job
opening for us Clojurians?

P.S.: I don't want this post to be just for me, so I encourage you to
post job offers from anywhere even if you're not searching for
telecommuters. BTW, I'm in Montreal.

Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Forms to strings

2010-04-14 Thread Nicolas Buduroi

On Apr 14, 11:44 am, Sean Devlin  wrote:
> Why are you using quasi-quote?

D'oh! For no reason at all, damn I feel stupid, lol! Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

To unsubscribe, reply using "remove me" as the subject.


Re: Forms to strings

2010-04-14 Thread Nicolas Buduroi
On Apr 14, 11:12 am, Sean Devlin  wrote:
> user=> (str '(is this what you mean?))
> "(is this what you mean?)"

No, more like this:

user=> (str `(str "foo"))
"(clojure.core/str \"foo\")"

I would like to get: "(str \"foo\")"

BTW, I'm not asking for code to do that, just if there's some options
or hidden functionality that would switch off full-qualification.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

To unsubscribe, reply using "remove me" as the subject.


Forms to strings

2010-04-14 Thread Nicolas Buduroi
Hi, I've got a simple question: When converting a form to a string the
resolved symbols are fully qualified, is there a way to get the string
with just the symbols?

Thanks

- budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

To unsubscribe, reply using "remove me" as the subject.


Redesigning ClojureQL's Frontend

2010-02-22 Thread Nicolas Buduroi
As most of you already probably know, there's a big rework of
ClojureQL's frontend. The development is now more focused on this
redesign and lots of great ideas have been found. Yet, it's always
good to get more inputs as this library will certainly become a common
tools for all Clojurians. The code is a work in progress, but you can
see where things are going in CQL's Wiki:

http://www.gitorious.org/clojureql/pages/FrontendReworked
http://www.gitorious.org/clojureql/pages/DdlFrontendReworked
http://www.gitorious.org/clojureql/pages/DataTypes

I'll be starting work on how to abstract data types tomorrow, so this
page is still empty. Meikel also created a group, so that we don't add
too much noise on this one:

http://groups.google.com/group/clojureql

- budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Montreal Clojure User Group

2010-02-22 Thread Nicolas Buduroi
I've accepted the invitation to the Blog. Still, I don't think it
could replace a discussion group or mailing list. I wonder what means
other groups or using to coordinate their meeting?

On Feb 22, 12:09 pm, Jeff Heon  wrote:
> Coffee sounds great.
>
> I'm from the suburbs, but I work downtown.
>
> Maybe even a lunch would be feasible.
>
> Not to pollute the Clojure group, I set up a temporary blog for us 
> :http://mcug.blogspot.com/
>
> On Feb 21, 11:20 pm, Dan  wrote:
>
> > Should we go for a coffee to meet each other or something?
>
>

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Montreal Clojure User Group

2010-02-21 Thread Nicolas Buduroi
On Feb 21, 12:55 pm, Jeff Heon  wrote:
> Would Montreal Clojurians be interested in starting a Clojure group?
>
> Or do you all piggyback on the Montreal/Scheme Lisp User Group?

That's a great idea, I'm in! I'd say that the Montreal Scheme/Lisp
User Group doesn't seems to be quite active. I wonder how many of us
are in Montreal or the surrounding region?

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Help! Clojuresque build failed

2010-02-12 Thread Nicolas Buduroi
I'm not sure about this one but I'll guess that your setup can't
compile Groovy scripts. I can't help you there as I didn't installed
it myself.

By the way, you don't need to build clojuresque, Gradle will take care
of downloading it if specified as a dependency. Look at the
build.gradle config file in ClojureQL repository. Post the exception
you're getting if you're having problems running "gradle build" on
ClojureQL instead.

On Feb 12, 6:27 pm, "sailormoo...@gmail.com" 
wrote:
> Hi:
>
>   I am not familiar with gradle, but I cannot build clojuresque, so I
> cannot build clojureql.
> The log building clojuresque is as follows :
>
>   Thanks for any help.
>
> D:\tools\clojuresque>gradle build
> :compileJava
> :compileGroovy
> 07:19:24.781 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:antlib:org.apac
> he.tools.ant] Could not load definitions from resource org/apache/
> tools/ant/antl
> ib.xml. It could not be found.
> 07:19:24.796 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter - Class
> org.codehaus.g
> roovy.ant.Groovyc loaded from parent loader (parentFirst)
> 07:19:24.796 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -  +Datatype
> groovyc o
> rg.codehaus.groovy.ant.Groovyc
> 07:19:24.828 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter - fileset:
> Setup scann
> er in dir D:\tools\clojuresque\src\main\groovy with
> patternSet{ includes: [] exc
> ludes: [] }
> 07:19:24.843 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:groovyc] clojur
> esque\ClojureCompileTask.groovy omitted as D:\tools\clojuresque\build
> \classes\ma
> in\clojuresque\ClojureCompileTask.class is up to date.
> 07:19:24.843 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:groovyc] clojur
> esque\ClojurePlugin.groovy omitted as D:\tools\clojuresque\build
> \classes\main\cl
> ojuresque\ClojurePlugin.class is up to date.
> 07:19:24.843 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:groovyc] clojur
> esque\ClojurePluginConvention.groovy omitted as D:\tools\clojuresque
> \build\class
> es\main\clojuresque\ClojurePluginConvention.class is up to date.
> 07:19:24.843 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:groovyc] clojur
> esque\ClojureSourceSet.groovy omitted as D:\tools\clojuresque\build
> \classes\main
> \clojuresque\ClojureSourceSet.class is up to date.
> 07:19:24.843 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:groovyc] clojur
> esque\DefaultClojureSourceSet.groovy omitted as D:\tools\clojuresque
> \build\class
> es\main\clojuresque\DefaultClojureSourceSet.class is up to date.
> 07:19:24.843 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:groovyc] clojur
> esque\ClojureCompileTask.groovy skipped - don't know how to handle it
> 07:19:24.843 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:groovyc] clojur
> esque\ClojurePlugin.groovy skipped - don't know how to handle it
> 07:19:24.843 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:groovyc] clojur
> esque\ClojurePluginConvention.groovy skipped - don't know how to
> handle it
> 07:19:24.843 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:groovyc] clojur
> esque\ClojureSourceSet.groovy skipped - don't know how to handle it
> 07:19:24.843 [main] DEBUG o.g.a.i.p.ant.AntLoggingAdapter -
> [ant:groovyc] clojur
> esque\DefaultClojureSourceSet.groovy skipped - don't know how to
> handle it
> :processResources
> :classes
> :compileTestJava
> :compileTestGroovy
> :processTestResources
> :testClasses
> :test
>
> BUILD SUCCESSFUL

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Applying arguments to Java methods.

2010-02-06 Thread Nicolas Buduroi
On Feb 5, 9:44 pm, nchubrich  wrote:
> Is there ever any reason to use memfn as opposed to ordinary
> functions, i.e.
>
> (def div (fn [x y] (.divide x y)))

You should normally use the doted notation. I used it while
experimenting with a macro that wrap Java classes, but it isn't the
right way to that after all. So I really don't know of any use for it.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Applying arguments to Java methods.

2010-02-05 Thread Nicolas Buduroi
On Feb 5, 4:20 pm, ataggart  wrote:
> You could also use memfn.

Exactly what I wanted!

> Though it requires reflection.  To deal with that you could make your
> own type-hinted function:

That's a good point. I've finally gave up using apply (well, the
version based on Rich code above) on methods because of it. That was
just experimental code anyway.

Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Applying arguments to Java methods.

2010-02-05 Thread Nicolas Buduroi
Hi, I'm searching for a way of applying a sequence of arguments to a
Java method, but haven't found anything yet. Tried to write a macro
for it and don't even see how that would be possible. Is there a way
to do that?

Thanks

- budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: ClojureQL insert data from map

2010-01-27 Thread Nicolas Buduroi
On Jan 27, 9:43 am, Roman Roelofsen 
wrote:
> when querying data in clojureql, the result is a list of maps. I often
> directly return this list (or a map) from my "db-logic" functions
> because my domain logic operates on these maps. However, I am not able
> to go the other way around, e.g. take the map and tell clojureql to
> insert/update a table row...

+1, while experimenting with ClojureQL, I've came the same conclusion.
I've updated the lighthouse ticket for the insert rework to include
your suggestion:

http://clojureql.lighthouseapp.com/projects/34981-clojureql/tickets/35-rework-insert

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
On Jan 18, 10:55 pm, Tom Hicks  wrote:
> Hey, congratulations on finding and fixing the problem!
>
> And thanks for the great link to the zipper explanationzippers
> were
> at the top of my list to learn (seriously). Did you catch this other
> useful
> link (in the comments of the article you provided)?
>
> http://okmij.org/ftp/Computation/Continuations.html#zipper
>
> This guy has a wealth of great information and references
> to related topics.

Yes, I already knew about Oleg's FTP site, a timeless resource about
lots of (strange) programming concept. Didn't visited for a long time.

- budu
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
I've now changed my test method to this.

(def pit (iterate list "bottom!"))

(defn get-bottom [p]
  (loop [p (first p)]
(if (seq? p) (recur (first p)) p)))

(defn test-walk [walker shallowest deepest]
  (doseq [depth (range shallowest deepest)]
(println (get-bottom
   (walker #(str depth " reached " %)
 (lazy-seq (last (take depth pit

And now everything make lot more sense. A classic case of good code
with bad test which make you search for some imaginary bug. So always
carefully read your stack traces! Here's some benchmarking I've done
with the above versions.

user> (time (test-walk lazy-recursive-string-walk-with-zipper 10
11))
10 reached bottom!
"Elapsed time: 1368.337794 msecs"

user> (time (test-walk lazy-recursive-string-walk 10 11))
10 reached bottom!
"Elapsed time: 233.80888 msecs"

user> (time (test-walk really-lazy-recursive-string-walk 10
11))
10 reached bottom!
"Elapsed time: 223.631872 msecs"

The one with a zipper is the slowest, zippers being much more capable
than just walking data structure, so it's normal. The first lazy
version is more than five faster and the one using Tom Hicks lazy-walk
function is slightly faster.

- budu
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
I've found the real problem. The overflow was coming from recursion
between pr-on and print-method. It must be that way because it's not
really useful to print such deeply nested data structure anyway.

On Jan 18, 7:06 pm, Nicolas Buduroi  wrote:
> On Jan 16, 7:33 pm, Laurent PETIT  wrote:
>
> > For the non lazy version , maybe using clojure.zip would help not blow
> > up the stack ?
>
> > (using clojure.zip/zip + a loop with recur on clojure.zip/next) ?
>
> I've just tried it and it appears to be equivalent to the lazy walk
> version, which I think is fully lazy after all (not tested, see
> below).
>
> (defn lazy-recursive-string-walk-with-zipper [f form]
>   (loop [loc (z/seq-zip form)]
>     (if (z/end? loc)
>       (z/root loc)
>       (recur (z/next
>                (if (string? (z/node loc))
>                  (zip/replace loc (f (z/node loc)))
>                  loc))
>
> The thing is, I should learn to read stack traces more carefully! The
> StackOverflowError was coming from my test function.
>
> (def pit (iterate list "bottom!"))
>
> (defn test-walk [walker shallowest deepest]
>   (doseq [depth (range shallowest deepest)]
>     (pprint (walker #(str depth " reached " %)
>               (last (take depth pit))
>
> It's the iterate function that was throwing the error, while used
> directly it can generate a 1000 lists deep nested list, but when used
> in the test-walk function it only reach 828. The stack overflow make
> more sense now, yet the stack trace is not easy to decipher.
>
> No message.
>   [Thrown class java.lang.StackOverflowError]
>
> Restarts:
>  0: [ABORT] Return to SLIME's top level.
>
> Backtrace:
>   0: clojure.lang.PersistentHashMap$BitmapIndexedNode.index
> (PersistentHashMap.java:467)
>   1: clojure.lang.PersistentHashMap$BitmapIndexedNode.assoc
> (PersistentHashMap.java:616)
>   2: clojure.lang.PersistentHashMap$TransientHashMap.doAssoc
> (PersistentHashMap.java:222)
>   3: clojure.lang.ATransientMap.assoc(ATransientMap.java:64)
>   4: clojure.lang.PersistentHashMap.create(PersistentHashMap.java:79)
>   5: clojure.core$hash_map__4297.doInvoke(core.clj:279)
>   6: clojure.lang.RestFn.invoke(RestFn.java:426)
>   7: clojure.core$print_sequential__6823.invoke(core_print.clj:37)
>   8: clojure.core$fn__6908.invoke(core_print.clj:136)
>   9: clojure.lang.MultiFn.invoke(MultiFn.java:161)
>  10: clojure.core$pr_on__5416.invoke(core.clj:2336)
>  11: clojure.core$print_sequential__6823.invoke(core_print.clj:54)
>  12: clojure.core$fn__6908.invoke(core_print.clj:136)
>  13: clojure.lang.MultiFn.invoke(MultiFn.java:161)
>  14: clojure.core$pr_on__5416.invoke(core.clj:2336)
>
> I'll look a little deeper at this error and keep this post updated. In
> the meantime, has anyone got an idea to replace iterate for creating
> mock nested lists to test recursive-string-walk?
>
> P.S.: Finally learned to use zippers and they can be very useful, like
> that concept a lot. Found it intimidating at first but I've just read
> an excellent write-up about them today:
>
> http://scienceblogs.com/goodmath/2010/01/zippers_making_functional_up...
>
> Thanks
>
> - budu
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Lazy recursive walk.

2010-01-18 Thread Nicolas Buduroi
On Jan 16, 7:33 pm, Laurent PETIT  wrote:
> For the non lazy version , maybe using clojure.zip would help not blow
> up the stack ?
>
> (using clojure.zip/zip + a loop with recur on clojure.zip/next) ?

I've just tried it and it appears to be equivalent to the lazy walk
version, which I think is fully lazy after all (not tested, see
below).

(defn lazy-recursive-string-walk-with-zipper [f form]
  (loop [loc (z/seq-zip form)]
(if (z/end? loc)
  (z/root loc)
  (recur (z/next
   (if (string? (z/node loc))
 (zip/replace loc (f (z/node loc)))
 loc))

The thing is, I should learn to read stack traces more carefully! The
StackOverflowError was coming from my test function.

(def pit (iterate list "bottom!"))

(defn test-walk [walker shallowest deepest]
  (doseq [depth (range shallowest deepest)]
(pprint (walker #(str depth " reached " %)
  (last (take depth pit))

It's the iterate function that was throwing the error, while used
directly it can generate a 1000 lists deep nested list, but when used
in the test-walk function it only reach 828. The stack overflow make
more sense now, yet the stack trace is not easy to decipher.

No message.
  [Thrown class java.lang.StackOverflowError]

Restarts:
 0: [ABORT] Return to SLIME's top level.

Backtrace:
  0: clojure.lang.PersistentHashMap$BitmapIndexedNode.index
(PersistentHashMap.java:467)
  1: clojure.lang.PersistentHashMap$BitmapIndexedNode.assoc
(PersistentHashMap.java:616)
  2: clojure.lang.PersistentHashMap$TransientHashMap.doAssoc
(PersistentHashMap.java:222)
  3: clojure.lang.ATransientMap.assoc(ATransientMap.java:64)
  4: clojure.lang.PersistentHashMap.create(PersistentHashMap.java:79)
  5: clojure.core$hash_map__4297.doInvoke(core.clj:279)
  6: clojure.lang.RestFn.invoke(RestFn.java:426)
  7: clojure.core$print_sequential__6823.invoke(core_print.clj:37)
  8: clojure.core$fn__6908.invoke(core_print.clj:136)
  9: clojure.lang.MultiFn.invoke(MultiFn.java:161)
 10: clojure.core$pr_on__5416.invoke(core.clj:2336)
 11: clojure.core$print_sequential__6823.invoke(core_print.clj:54)
 12: clojure.core$fn__6908.invoke(core_print.clj:136)
 13: clojure.lang.MultiFn.invoke(MultiFn.java:161)
 14: clojure.core$pr_on__5416.invoke(core.clj:2336)

I'll look a little deeper at this error and keep this post updated. In
the meantime, has anyone got an idea to replace iterate for creating
mock nested lists to test recursive-string-walk?

P.S.: Finally learned to use zippers and they can be very useful, like
that concept a lot. Found it intimidating at first but I've just read
an excellent write-up about them today:

http://scienceblogs.com/goodmath/2010/01/zippers_making_functional_upda.php?

Thanks

- budu
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Lazy recursive walk.

2010-01-17 Thread Nicolas Buduroi
> Sorry, I forgot to ask: how rapid is "rapidly"?

Oh, I'd say I misused that word, at least it's way more than I need
for what I use this for. I created this post only to see if someone
would have an idea for a fully lazy version out of curiosity. From my
experiments, the non-recursive version blow the stack around 486
recursions on my computer.

> Can you provide a simple example that rapidly blows the stack
> so we can experiment  with lazy solutions?

Here's what I used to test the depth of recursion:

(def pit (iterate list "bottom!"))

(defn test-walk [walker shallowest deepest]
  (doseq [depth (range shallowest deepest)]
(pprint (walker #(str depth " reached " %)
  (last (take depth pit))

Here's the recursive walks functions and a new one using your first
attempt at lazy-walk:

(defn recursive-string-walk [f form]
  (walk #(if (string? %) (f %) (recursive-string-walk f %))
identity form))

(defn lazy-recursive-string-walk [f form]
  (walk #(cond
   (string? %) (f %)
   (seq? %)(lazy-seq (lazy-recursive-string-walk f %))
   :default(lazy-recursive-string-walk f %))
identity form))

(defn really-lazy-recursive-string-walk [f form]
  (lazy-walk #(if (string? %) (f %) (really-lazy-recursive-string-walk
f %))
identity form))

And here's the results:

 * (test-walk recursive-string-walk 450 500) -> ...(...("487 reached
bottom!")...); Evaluation aborted.
 * (test-walk lazy-recursive-string-walk 800 900) -> ...(...("828
reached bottom!")...); Evaluation aborted.
 * (test-walk really-lazy-recursive-string-walk 800 900) -> ...(...
("829 reached bottom!")...); Evaluation aborted.

So just one more, there's still lots of room for improvement ;-). For
whatever reason the lazy version isn't able to reach 1000 while
yesterday it was able to go slightly above that and the non-lazy
version didn't changed. The more I look at the code the more I don't
get why it's not fully lazy. I'll try with zippers as Laurent
suggested.

Thanks a lot!

- budu
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Lazy recursive walk.

2010-01-15 Thread Nicolas Buduroi

On Jan 15, 3:25 pm, Sean Devlin  wrote:
> Did you try wrapping everything w/ a call to lazy-seq?

Yes, it doesn't seem change anything.
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Lazy recursive walk.

2010-01-15 Thread Nicolas Buduroi
Hi, I'm still not familiar with laziness and I'm trying to make a
function recursively walk arbitrary data structures to perform some
action on all strings. The non-lazy version is quite easy to do:

(use
  'clojure.walk
  'clojure.contrib.str-utils)

(defn recursive-string-walk [f form]
  (walk #(if (string? %) (f %) (recursive-string-walk f %))
identity form))

But it blow up the stack quite rapidly, I've tried to inject some
laziness inside, but only came up with a slight improvement. It can
take forms that are a little more than two time as deep.

(defn recursive-string-walk [f form]
  (walk #(cond
   (string? %) (f %)
   (seq? %)(lazy-seq (recursive-string-walk f %))
   :default(recursive-string-walk f %))
identity form))

Is there a way too make a fully lazy version of this function?

Thanks

- budu
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

ANN: clj-doc, a library to generate API documentation for Clojure code to various markup languages.

2010-01-12 Thread Nicolas Buduroi
Hi, I announce my first open source project, it's really small and
doesn't have lots of features yet, but I think it can be already
useful in its current state. I'll always be open to suggestions to
improve it, but as it's only version 0.3, now is the time to get
things straight.

There's two macro gen-doc that returns a list of documentation strings
and gen-doc-to-file that write those strings to files. Namespaces can
be grouped and also be specified using regular expressions. Here's an
example demonstrating most of the available features:

(gen-doc-to-file
  "g:/test.markdown"
  {:markup markdown}
  [clj-doc.markups.markdown clj-doc.markups.html-simple]
  #"(?=clj-doc)(?=(?!.*markdown))(?=(?!.*html-simple))")

This print documentation for clj-doc's markdown and html-simple
namespaces in the test0.markdown file and all others clj-doc
namespaces in test1.markdown. For more examples see the link below.

http://github.com/budu/clj-doc
http://whollyweirdwyrd.blogspot.com/2010/01/documenting-clojure-code.html

- budu
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Strange problem when adding type to a var defined by a macro.

2010-01-10 Thread Nicolas Buduroi

> So I think the source of the exception is clear, but have you found a
> solution to your original problem? Maybe if you expand on that someone
> can describe a good technique.

I'm using clojure-contrib's ns-utils/ns-vars and find-namespaces/find-
namespaces-on-classpath to discover namespaces and look for typed vars
in them to be later evaled and used. Here's the main components that
are used:

 * defmytype: like the defbar example in the above post.
 * find-mytypes: a function that takes a set of namespaces or regex
expressions to search for namespaces and returns the symbols of each
instance of mytype found in them.
 * then the code may use these symbols to load one of them.

For now, I have only a partial implementation and it's not much more
useful than loading any given symbol in a try catch, but eventually I
think it could be useful to provide plugin-like capabilities without
much boilerplate. I've been working on a small project that use this
technique and will release it shortly, that will give you a better
idea.

Thanks

- budu
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Strange problem when adding type to a var defined by a macro.

2010-01-09 Thread Nicolas Buduroi

> The macro works fine. The problem is that the REPL tries to print the
> result (which is the var you created) and the print multimethod does
> not know what to do with your custom type, and the default method
> throws an exception.

That was it, thanks a lot.

- budu
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Strange problem when adding type to a var defined by a macro.

2010-01-08 Thread Nicolas Buduroi
Hi, I'm using macros to define special vars (w/ a keyword as type) to
retrieve them later with ns-utils/ns-vars and filter them. I don't
know if this technique is recommended or if there's some better way to
achieve this, but there's something weird happening when we try to
evaluate the var defined at the REPL. For example, if you run this
code:

(defmacro defbar [foo & body]
  `(def ~(with-meta foo {:type ::MyType})
 (eval ~...@body)))

(defbar baz (+ 1 1))

It throws a ClassCastException: "clojure.lang.Var cannot be cast to
clojure.lang.IObj", which is an error I encountered often and never
truly understood. Can somebody help me find out what I'm missing?

Thanks

- budu
-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Small problem with sets documentation.

2009-12-29 Thread Nicolas Buduroi
Hi, just to warn that there's a small problem with sets documentation
in the data structures page of Clojure's website. The hyperlinks to
set operations and pseudo-relational algebra are broken as they
haven't followed the move to the new clojure.set namespace.

- budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Using map on multiple collections.

2009-12-29 Thread Nicolas Buduroi
Big thanks to everyone, the suggestions given are all very welcome,
even if I didn't really needed a better version as my use of mappad is
really simple for now. It was just curiosity on my part.

The lazy version by Heinz could be quite useful in other situations,
I've added it to my toolbox. Using lazy sequence with recursion is a
really elegant way to resolve most problems, it make up for the lack
of TCO in lots of cases. Also, the use of fnil is interesting. It
seems like a quite useful function, but it's a little bit confusing,
need more studying on that one. So to wrap up this post here's the
code for both lazy and non-lazy version of mappad:

(defn extend-tuple
  "Lazily creates tuples from given colls, filling the ones that are
  empty before the rest with the default value."
  [default & colls]
  (if (some (complement empty?) colls)
(cons
  (map (fn [l] (if (empty? l) default (first l))) colls)
  (lazy-seq (apply extend-tuple default (map next colls
nil))

(defn append-default
  "Returns the given colls padded with the given default value."
  [default & colls]
  (let [lengths (map count colls)
maxlen (apply max lengths)]
(map #(concat %1 (repeat (- maxlen %2) default)) colls lengths)))

(defn mappad
  "Like map but if collections aren't all of the same size, the
smaller
  ones are padded with the given default value."
  [f default & colls]
  (apply map f (apply append-default default colls)))

(defn lazy-mappad
  "Like mappad but lazy."
  [f default & colls]
  (map #(apply f %) (apply extend-tuple default colls)))

As you see, I renamed it extend-tuple as tupel was probably a typo
unless I'm mistaken. I'd like to find a better name, but these kind of
functions are always hard to name. I'll eventually release these and
other simple helpers in a small library where I keep these things. But
maybe one of these version (the lazy one at least) warrant being
included in clojure.contrib.seq-utils.  I'll open a ticket for it in
the Assembla page later this week.

Thanks again and happy new year!

- budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Using map on multiple collections.

2009-12-25 Thread Nicolas Buduroi

On Dec 25, 9:08 am, "Heinz N. Gies"  wrote:
> On Dec 23, 2009, at 6:04 , Nicolas Buduroi wrote:
>
> > Hi, today I needed to use the map function on multiple collections
> > which didn't had all the same length. In this case, it returns a
> > sequence of the size of smallest one. But the problem I was facing was
> > required to map until the end of the longest, padding the smaller ones
> > with a default value. I came up with this:
>
> No code but an idea, calling length on the collection might force them to be 
> itterated entirely why not define something like a lazy seq that takes:
>
> 1) the sequence to extend
> 2) the default value
> 3) a number of other sets
>
> As long as any of the lists is not epty return either first or the default 
> value, this saves iterating through all lists, and is lazy :)
>
> A quick not tested and proably horribl wrong example:
>
> (defn extend-list [main-list default & other-lists]
>   (if (some #(not (empty? %)) other-lists)
>     (if
>       (cons
>          (empty? main-list) default (first main-list)) (apply extend-list 
> (next main-list) default (map next other-lists)
>
> (this is not tested and just an idea, sorry short in time!

I'll have a look at this, it would certainly make this function more
idiomatic to Clojurians.

Thanks for the suggestion.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Using map on multiple collections.

2009-12-25 Thread Nicolas Buduroi
On Dec 25, 1:52 am, Tom Hicks  wrote:
> A slight modification, which I think avoids counting each collection
> twice:
>
> (defn append-val [val & colls]
>   (let [lengths (map count colls)
>         maxlen (apply max lengths)]
>     (map #(concat %1 (repeat (- maxlen %2) val)) colls lengths)
>   )
> )

Good one!

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Using map on multiple collections.

2009-12-23 Thread Nicolas Buduroi
On Dec 23, 12:30 pm, kyle smith  wrote:
> It's a little shorter if you unconditionally concat & repeat.
>
> (defn append-val [val & colls]
>   (let [maxlen (apply max (map count colls))]
>     (map #(concat % (repeat (- maxlen (count %)) val)) colls)))
>
> user> (apply map + (append-val 0 [1] [2 3] [4 5 6]))
> (7 8 6)

Thanks for the suggestion.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Using map on multiple collections.

2009-12-22 Thread Nicolas Buduroi
Hi, today I needed to use the map function on multiple collections
which didn't had all the same length. In this case, it returns a
sequence of the size of smallest one. But the problem I was facing was
required to map until the end of the longest, padding the smaller ones
with a default value. I came up with this:

(defn mappad [f val & colls]
  (let [longest (apply max (map count colls))
colls   (map #(if (< (count %) longest)
(concat % (repeat val))
%) colls)]
(apply (partial map f) colls)))

user> (mappad #(+ %1 %2 %3) 0 [1] [2 3] [4 5 6])
(7 8 6)

Is there a better way?

- budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


A Help Macro

2009-12-21 Thread Nicolas Buduroi
Hi everybody, I wrote a help macro to make getting help easier within
the REPL and thought others might also find it useful. It regroups
into one command various helpers found in clojure-contrib:

 * classpath: classpath
 * ns-utils: docs, dir, vars
 * repl-utils: expression-info, show, source

There's also a shortcut to get the current working directory (pwd) and
it also act like find-doc, but is easier to type. Here's the available
help queries:

Usage: (help pwd)
   (help classpath)
   (help dir )
   (help docs )
   (help vars )
   (help source )
   (help  [])
   (help )
   (help )
   (help ? )

I wrote a blog post about it:

http://whollyweirdwyrd.blogspot.com/2009/12/writing-help-macro.html

and the code can be found there:

http://dl.dropbox.com/u/2682770/mu/help_macro.clj

Any comments or code reviews are welcomed.

Happy Holidays

- budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Semantic Versioning

2009-12-18 Thread Nicolas Buduroi

On Dec 18, 4:16 am, Roman Roelofsen 
wrote:
> IMHO, no. This is the whole problem. Library users will mostly care
> about the runtime. It doesn't help at all if your code compiles, maybe
> in isolated pieces, but everything blows up at runtime. For example, I
> never had problems compiling against the correct Log4j version. Maven
> will set up the classpath for each "compiliation unit" (here Maven
> module) individually. But I stopped counting how often the runtime
> screw up because several libraries were using log4j, all expecting
> different version, and the whole classpath was a total mess of
> different jar files, redundancy and shadowed classes.
>
> Solving this problem at runtime implies a solution for build time but
> not the other way around.

Thanks for the explanation, I still have lots of learning to do on
this subject.

> I am looking at this constantly :-) I am working on an intergration
> layer (http://wiki.github.com/romanroe/ogee) but I haven't had much
> time in the last weeks. Ogee also has a small context-oriented
> programming module and I am focusing on this anyway currently.

I hope your project work out fine, it would certainly be a nice
addition to Clojure for managing that kind of situation. I'll give it
a closer look when I'll have more time on my hands.

- budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Semantic Versioning

2009-12-17 Thread Nicolas Buduroi

On Dec 17, 3:13 am, Roman Roelofsen 
wrote:
> Dealing with version numbers at build time is quite easy with tool
> like Maven. The important thing is that everyone agrees on the same
> version semantics (great summary [1]). Putting some more tooling
> around this should be a good idea, yes.

Talking of semantics, do you think the one I enumerated would work?
I'll certainly try to implement this concept, but I have many other
projects on the table right now, so it might take a while before I
start working on it.

> However, the problem in Java is dealing with versions at runtime, not
> at build time!

It's sure would be a nice addition, but dealing with versioning at
build time would at least give library users some assurance.

> Java's classloader design has not knowledge about
> versions, etc and  makes it impossible to deal with versions without a
> new layer on top of it. The default system for dealing with this in
> Java is OSGi. Unfortunately, Clojure's classloader design seems to be
> completely incompatible with OSGi. If we could solve this, Clojure
> would instantly get multi version support.

My knowledge of Java's classloader is pretty limited, I'll look at
OSGi and Clojure's classloader to see what I can do, but don't expect
miracles ;-)

- budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Semantic Versioning

2009-12-17 Thread Nicolas Buduroi
On Dec 17, 3:11 am, Laurent PETIT  wrote:
> Isn't this the ideal that clojure and libraries are almost more or less
> already following ?

Yes it is, but that's because the maintainers are very disciplined and
professional people. Not everybody follow this scheme properly and
even the best of us can err. If the build system enforce that system,
it would help us follow it more closely.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Semantic Versioning

2009-12-16 Thread Nicolas Buduroi
s/thinking/think/

On Dec 16, 2:56 pm, Nicolas Buduroi  wrote:
> Hi, on the CommonJS Google Group there was a discussion on semantic
> versioning, a formalization of the concept of properly using a common
> version number scheme (Major.Minor.Patch) for libraries.
>
> http://semver.org/
>
> I think it would be especially easy to enforce a simple version of
> this system in a Clojure project. A program could inspect code and
> decide what version number to use during build time. The major version
> could be changed automatically once a public function, multi-method or
> macro arguments list change in a non-backward compatible way and also
> when some of them are removed. The patch version number could be
> incremented when code change (but not the API) and existing tests
> don't change or new tests have been added. The minor version could be
> incremented in other cases. This implementation have it's quirks, like
> not being able to check for return types. Doing it for real would
> certainly uncover a more lot subtle details.
>
> What do you thinking about this idea? How would you improve it?
>
> - budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Semantic Versioning

2009-12-16 Thread Nicolas Buduroi
Hi, on the CommonJS Google Group there was a discussion on semantic
versioning, a formalization of the concept of properly using a common
version number scheme (Major.Minor.Patch) for libraries.

http://semver.org/

I think it would be especially easy to enforce a simple version of
this system in a Clojure project. A program could inspect code and
decide what version number to use during build time. The major version
could be changed automatically once a public function, multi-method or
macro arguments list change in a non-backward compatible way and also
when some of them are removed. The patch version number could be
incremented when code change (but not the API) and existing tests
don't change or new tests have been added. The minor version could be
incremented in other cases. This implementation have it's quirks, like
not being able to check for return types. Doing it for real would
certainly uncover a more lot subtle details.

What do you thinking about this idea? How would you improve it?

- budu

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Funding Clojure 2010

2009-12-14 Thread Nicolas Buduroi
That's a great idea, hope it gains some traction. I'm recently
unemployed and trying to bootstrap my own startup, so I'll skip this
year. When my financial condition will be more solid though, I'll
certainly donate something. In the meantime, as I intend to build my
projects in Clojure, I'll contribute code back as much as I can.

- budu

On Dec 14, 9:33 am, Rich Hickey  wrote:
> Funding Clojure 2010
>
> Background
> --
>
> It is important when using open source software that you consider who
> is paying for it, because someone is. There is no such thing as free
> software.
>
> Sometimes open source software is developed under a license with
> undesirable properties (e.g. the GPL), such that people are willing to
> pay for a (proprietary) version of it that is not subject to that
> license. Both Monty Widenius [1] and Richard Stallman [2] have argued
> for the necessity of such a mechanism to fund open source software,
> lest there be insufficient resources for its development. Clojure
> doesn't use the GPL, thus conveying more freedom to its users, but
> precluding me from funding it via dual licensing.
>
> Some companies develop technology as a component of a proprietary
> product or service, absorbing it as a necessary expense, only to
> decide that it is not a core, unique, or advantage-bearing business
> function. They can reduce their costs in ongoing development by open
> sourcing it, deriving benefit from community contributions and letting
> them focus on their core business [3]. It is important to note that
> the bulk of the costs are often in the original development, and are
> paid for by the proprietary product or service. That is not the case
> for Clojure.
>
> Some open source is the product of academic research, and is funded by
> the academic institution and/or research grants [4]. That is not the
> case for Clojure.
>
> Some open source software is (partially) funded by proprietary
> support. It is important to note that often the support income does
> not in fact make it to the people who create the software. Such income
> models work best for support sold to conservative enterprises [5].
> That is not the case for Clojure.
>
> Some companies 'fund' open source software by dedicating some of their
> employees' time, or making investments, in its development. There must
> be some business value to the company for doing so (e.g. it helps them
> sell hardware [6]), and thus is ultimately paid for by their
> proprietary products/services. That is not the case for Clojure.
>
> There *are* companies that make software themselves, whose consumers
> see a value in it and willingly pay to obtain that value. The money
> produced by this process pays the salaries of the people who are
> dedicated to making it, and some profit besides. It's called
> "proprietary software". People pay for proprietary software because
> they have to, but otherwise the scenario is very similar to open
> source - people make software, consumers get value from it. In fact,
> we often get a lot less with proprietary software - vendor lock-in, no
> source etc. Most alarmingly, this is the only model that associates
> value with software itself, and therefore with the people who make it.
>
> Why don't people pay for open source software? Primarily, because they
> don't *have to*. I think also, partially, it is because open source
> software often doesn't have a price tag. I think it should. I'd like
> to pay for open source, and know the money is going to those who
> create it. I'd like companies to *expect* to pay for it. I'd like to
> see people make a living (and even profit!) directly making open
> source, not as a side effect of some other proprietary process, to
> dedicate themselves to it, and not have it be hobby/side work.
>
> Unfortunately, there seems to be no way to convey the full benefits of
> open source software while *forcing* people to pay for it. Only in the
> proprietary (including dual-license) model is there a direct
> connection between the consumers of software and the funding of those
> that produce it. This is having the effect of driving open source
> software towards having zero apparent cost, becoming a free bounty of
> someone else's other profitable endeavors, and is severely
> compromising our profession.
>
> Foreground
> --
>
> As should be obvious, Clojure is a labor of love on my part. Started
> as a self-funded sabbatical project, Clojure has come to occupy me far
> more than full-time. However, Clojure does not have institutional or
> corporate sponsorship, and was not, and is not, the by-product of
> another profitable endeavor. I have borne the costs of developing
> Clojure myself, but 2009 is the last year I, or my family, can bear
> that.
>
> Many generous people have made donations (thanks all!), but many more
> have not, and, unfortunately, donations are not adding up to enough
> money to pay the bills. So far, less than 1% of the time I've spent on
> Clojure has be

Re: Latest news on ClojureQL

2009-12-14 Thread Nicolas Buduroi
Ruby-style migrations are great but, as others have said, they lend
themselves better to another layer of abstraction. I was thinking of a
lower-level alternative to migration. We could find a way to construct
an ast from the current database schema and then compare it with the
one generated by the create-table macro. Another macro could generate
the alter clauses to migrate the differences between both. This option
too should be considered only after version 1.0 is release as it's not
trivial to implement.

On Dec 11, 4:40 pm, rb  wrote:
> > > And a suggestion: having migrations in CQL would be great!
>
> > Could you elaborate a little?
>
> Migrations are a way to manage the evolution of a schema of a
> database. I'm familiar with migration in Ruby on Rails which are
> explained here:http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
>
> All changes to the data schema are made with migrations that, when
> applied (in the right order), build your database. You can also
> possibly go back and undo the change if the operation was not
> destructive (migrations have an up- and downgrade operation). The list
> of migrations applied are kept in a table of the database, so when an
> upgrade is done, the migration system knows which migrations have to
> be run in the upgrade step. When a migration is run, its id is added
> to the list of migrations that have been applied to the database. And
> when a migration is unapplied (downgrade operation), its id is removed
> from the list. That way, you can go up and down in the version of your
> schema. Of course you most often only play with the last migrations
> during the development phase. And when you deploy to production, you
> may be sure the same changes will be applied as what you did.
>
> And migration can also manipulate the data in addition to change the
> data structure. For example, it can create and populate a table with
> initial data. In an extreme case, if you want to split a table in
> multiple tables, you could do that in a migration which would
> - create the new tables
> - populate them with data from the initial table
> - drop columns that are now superfluous in the initial table
> These operation can be non-destructive, and so the migration can be
> undone.
>
> It's really been a time saver and I think it's a really good fit with
> ClojureQL.
>
> Raphaël

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Calling static methods on a variable holding a class

2009-07-08 Thread Nicolas Buduroi

> Lets say you want to call static method "foo" of a class,
> but you don't know which class -- you want this to be
> specified at runtime in a parameter.  Something like this:
>
> (defn map-foo [cls coll]
>   (map cls/foo coll))  ; doesn't work
>
> As mentioned by others, one approach is to use reflection,
> either Java's API or Clojure's (undocumented,
> may-change-without-warning) wrapper:
>
> (defn map-foo [cls coll]
>   (map #(clojure.lang.Reflector/invokeStaticMethod
>cls "foo" (to-array [%]))
>coll))
>
> (map-foo MyClass [1 2 3 4])
>
> This works, but if you're allowed to adjust the requirements
> a bit, a better solution is possible.  What if your user
> called:
>
> (map-foo #(MyClass/foo %) [1 2 3 4])
>
> This can be done without any runtime reflection at all,
> which can greatly boost the runtime speed.  Also, it's more
> flexible:  I *told* you to name your method "foo" but
> I guess I should have been more explicit.  Oh well, no
> matter:
>
> (map-foo #(YourClass/Foo %) [1 2 3 4])
>
> Or if your user is using Clojure rather than Java, they
> don't even have to use a class:
>
> (map-foo #(her-do-foo-thing %) [1 2 3 4])
>
> or just:
>
> (map-foo her-do-foo-thing [1 2 3 4])
>
> Best of all implementing map-foo is simpler:
>
> (defn map-foo [f coll]
>   (map f coll))
>
> Which in this trivial example means you can just use 'map'
> instead of 'map-foo'.  But even in a less trivial example
> you may find this approach more workable all around.

Wow, that was a great answer, a thousand thanks

> Now if you were going to do more than one thing on the class
> (call static methods foo, bar, and baz, for example) things
> get more complicated.

Yeah, that was one of constraint for the problem I was trying to
solve, I should have mentioned it.

- budu

--~--~-~--~~~---~--~~
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Calling static methods on a variable holding a class

2009-07-08 Thread Nicolas Buduroi

> If you know the method you wish to call, do you not know the class and can
> thus call the static method directly?

Well that was the point of the question, that is if I have to call a
static method on a class we don't know in advance. I understand this
capability isn't that useful and is quite rarely used, but maybe
somebody will one day need it for some practical reason. ;-)

> My first impression is that this is probably not the best way to go
> about this.  Java classes are not like Ruby or Python classes; you
> can't just call methods on them.  Using "eval" is a hack, and probably
> not a good idea.

Yeah, you're quite right about this. For now I'm just experimenting
with some ideas on how to abstract Java libraries, nio in this case.
So it's not something I really need.

> If you go this route, I recommend either using or learning from the  
> functions in clojure/src/jvm/clojure/lang/Reflector.java. Its methods  
> are not part of Clojure's official interface, so the usual caveats  
> about using unsupported "implementation private" code apply, but it  
> include many useful methods for dealing with reflection from Clojure.

I'll certainly use the Reflector class, should have thought about it!
I wonder if it would be a good idea to include a function for it in
Clojure or in Contrib?

As for the call-static macro, I now understand the error message. It
was quite obvious in fact, as macros must output something that the
reader can read!

Thanks all!

- budu

--~--~-~--~~~---~--~~
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Calling static methods on a variable holding a class

2009-07-06 Thread Nicolas Buduroi

I've just figured out that the macro version in the allocate example
can't be  used with local variables.

(let [foo ByteBuffer]
  (allocate1 foo 1024))

throws java.lang.UnsupportedOperationException: Can't eval locals
(NO_SOURCE_FILE:94)

On Jul 6, 6:59 pm, Nicolas Buduroi  wrote:
> Hi, I needed to call a static method on a class stored in a var
> yesterday and found that it was a little bit trickier than I initially
> thought. There's three way of doing it, the two first are quite
> straightforward and working ;-) e.g.:
>
> (import '(java.nio ByteBuffer FloatBuffer))
>
> (def foo ByteBuffer)
>
> (. foo (allocate 1024)) ; throw an exception as intended.
>
> (defmacro allocate1 [buffer-type size]
>   `(. ~(eval buffer-type) (allocate ~size)))
>
> (defn allocate2 [buffer-type size]
>   (eval `(. ~buffer-type (allocate ~size
>
> (allocate1 foo 1024)
> (allocate2 foo 1024)
>
> Both works fine, but I'm still not sure which one is the best. The
> third way is to call a static method from the class object, I've tried
> something but wasn't able to get it working. It throws some weird
> exception, here's the code:
>
> (defn to-primitive [class]
>  (try
>  (let [type (.getField (identity class) "TYPE")]
>    (.get type Object))
>  (catch NoSuchFieldException _ class)))
>
> (defmacro call-static [class name & args]
>  (let [arg-types (into-array
>                  (map (comp to-primitive #(.getClass %)) args))
>       method (.getMethod (eval class) name arg-types)]
>   `(.invoke ~method ~class ~...@args)))
>
> When calling this macro (call-static foo "allocate" 1024) it throws:
> java.lang.RuntimeException: Can't embed object in code, maybe print-
> dup not defined: public static java.nio.ByteBuffer
> java.nio.ByteBuffer.allocate(int) (NO_SOURCE_FILE:0)
>
> This error message is quite puzzling isn't it?
>
> Is there any other way?
>
> Thanks
>
> - budu
--~--~-~--~~~---~--~~
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Calling static methods on a variable holding a class

2009-07-06 Thread Nicolas Buduroi

Hi, I needed to call a static method on a class stored in a var
yesterday and found that it was a little bit trickier than I initially
thought. There's three way of doing it, the two first are quite
straightforward and working ;-) e.g.:

(import '(java.nio ByteBuffer FloatBuffer))

(def foo ByteBuffer)

(. foo (allocate 1024)) ; throw an exception as intended.

(defmacro allocate1 [buffer-type size]
  `(. ~(eval buffer-type) (allocate ~size)))

(defn allocate2 [buffer-type size]
  (eval `(. ~buffer-type (allocate ~size

(allocate1 foo 1024)
(allocate2 foo 1024)

Both works fine, but I'm still not sure which one is the best. The
third way is to call a static method from the class object, I've tried
something but wasn't able to get it working. It throws some weird
exception, here's the code:

(defn to-primitive [class]
 (try
 (let [type (.getField (identity class) "TYPE")]
   (.get type Object))
 (catch NoSuchFieldException _ class)))

(defmacro call-static [class name & args]
 (let [arg-types (into-array
 (map (comp to-primitive #(.getClass %)) args))
  method (.getMethod (eval class) name arg-types)]
  `(.invoke ~method ~class ~...@args)))

When calling this macro (call-static foo "allocate" 1024) it throws:
java.lang.RuntimeException: Can't embed object in code, maybe print-
dup not defined: public static java.nio.ByteBuffer
java.nio.ByteBuffer.allocate(int) (NO_SOURCE_FILE:0)

This error message is quite puzzling isn't it?

Is there any other way?

Thanks

- budu

--~--~-~--~~~---~--~~
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Nicolas Buduroi

> I'm not running off any server. All the pages are static html, which
> are generated by a Clojure script.

No kidding! I've done the exact same thing for my first website. It
was using Scheme though and leveraged Oleg's SXML library, it bring me
back fond memories. I'm looking at that old code right now and it was
kind of crazy, just using R5RS with srfi 1 and 19, Clojure is so much
better than this.

Your website looks good by the way. One thing is if you could dim the
background lines a little bit, it would make the text more readable,
some line look strikethrough.

> I looked at Compojure, and it seems very promising, but I decided it
> was overkill for my website.

Compojure is really great! ;-)

- budu
--~--~-~--~~~---~--~~
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: How is Clojure API reference generated?

2009-06-11 Thread Nicolas Buduroi

Great, exactly what we needed!

On Jun 11, 7:51 pm, Tom Faulhaber  wrote:
> Rich posted the code he uses here:http://paste.lisp.org/display/77339
>
> But note that he's building it in wiki markup and not html.
>
> HTH,
>
> Tom
>
> On Jun 9, 4:13 pm, Nicolas Buduroi  wrote:
>
> > Hi, I'm wondering how Clojure API reference page is generated? I'd
> > like to adapt it for the future Compojure website if possible. On
> > another note, how is Clojure website built and what language/framework
> > does it use?
>
> > Thanks
>
> > - budu
--~--~-~--~~~---~--~~
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Reading files with nio.

2009-06-10 Thread Nicolas Buduroi

I've got an even faster version using memory-mapped file I/O. It also
simplify the code a little bit.

(defn fast-read-file [#^String filename #^String charset]
  (with-open [cin (. (new FileInputStream filename) getChannel)]
(let [size (. (new File filename) length)
  char-buffer (. ByteBuffer (allocate size))
  decoder (. (. Charset (forName charset)) (newDecoder))]
  (str
   (. decoder
  (decode
   (.map cin (. FileChannel$MapMode READ_ONLY) 0 size)))

On Windows I get these results:

nio=> (time (dotimes [i 1000] (fast-read-file ".emacs" "ISO-8859-1")))
"Elapsed time: 247.9453 msecs"
nio=> (time (dotimes [i 1000] (fast-read-file ".emacs" "ISO-8859-1")))
"Elapsed time: 247.666881 msecs"
nio=> (time (dotimes [i 1000] (fast-read-file ".emacs" "ISO-8859-1")))
"Elapsed time: 247.895424 msecs"

Compared with the previous version with buffer size equal to the
length of the file:

nio=> (time (dotimes [i 1000] (read-file ".emacs" "ISO-8859-1" (. (new
File ".emacs") length
"Elapsed time: 264.470276 msecs"
nio=> (time (dotimes [i 1000] (read-file ".emacs" "ISO-8859-1" (. (new
File ".emacs") length
"Elapsed time: 265.775947 msecs"
nio=> (time (dotimes [i 1000] (read-file ".emacs" "ISO-8859-1" (. (new
File ".emacs") length
"Elapsed time: 263.828204 msecs"

The API documentation for the map method aren't very exhaustive,
there's not much information on its limits. A lot of details are
implementation dependent and left unspecified, most problems though
seems to be related to writing.

--~--~-~--~~~---~--~~
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Reading files with nio.

2009-06-09 Thread Nicolas Buduroi

Hi, I've been playing with nio lately and it's been quite fun to delve
in lower level stuff again, didn't do that in a long time. I've
translated a small example, just to read a file, and the result is
performing really well. Here's the code:

(defn read-file [#^String f #^String cs #^Integer buffer-size]
  (with-open [cin (. (new FileInputStream f) getChannel)]
(let [buffer (. ByteBuffer (allocate buffer-size))
  char-buffer (. ByteBuffer (allocate buffer-size))
  charset (. Charset (forName cs))
  decoder (. charset (newDecoder))
  sb (new StringBuilder)
  read #(. cin (read buffer))]
  (loop [r (read)]
(if (= r -1)
  (str sb)
  (do
(. buffer flip)
(. sb (append (. decoder (decode buffer
(. buffer clear)
(recur (read

And a couple of micro-benchmarks in Windows XP SP3:

nio=> (time (dotimes [n 1000] (read-file ".emacs" "ISO-8859-1" 8192)))
"Elapsed time: 284.693456 msecs"
nio=> (time (dotimes [n 1000] (read-file ".emacs" "ISO-8859-1" 8192)))
"Elapsed time: 280.79918 msecs"
nio=> (time (dotimes [n 1000] (read-file ".emacs" "ISO-8859-1" 8192)))
"Elapsed time: 284.62619 msecs"

nio=> (time (dotimes [n 1000] (slurp ".emacs")))
"Elapsed time: 530.622305 msecs"
nio=> (time (dotimes [n 1000] (slurp ".emacs")))
"Elapsed time: 531.319221 msecs"
nio=> (time (dotimes [n 1000] (slurp ".emacs")))
"Elapsed time: 527.439793 msecs"

And in Debian Linux 5.0:

user=> (time (dotimes [n 1000] (nio/read-file ".emacs" "ISO-8859-1"
8192)))
"Elapsed time: 243.364117 msecs"
user=> (time (dotimes [n 1000] (nio/read-file ".emacs" "ISO-8859-1"
8192)))
"Elapsed time: 247.718237 msecs"
user=> (time (dotimes [n 1000] (nio/read-file ".emacs" "ISO-8859-1"
8192)))
"Elapsed time: 246.027863 msecs"

user=> (time (dotimes [n 1000] (slurp ".emacs")))
"Elapsed time: 320.073016 msecs"
user=> (time (dotimes [n 1000] (slurp ".emacs")))
"Elapsed time: 309.658266 msecs"
user=> (time (dotimes [n 1000] (slurp ".emacs")))
"Elapsed time: 318.926749 msecs"

Things to note:
  * Playing with buffer size obviously changes the results, still the
nio version always outperformed slurp in my tests. The smallest buffer
size I tried was 1024 bytes.
  * The Debian machine is a virtual one running under Windows.
  * Windows java is Sun's JDK version 1.6.0_06.
  * Linux java is OpenJDK version 1.6.0_0.

- budu

--~--~-~--~~~---~--~~
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



How is Clojure API reference generated?

2009-06-09 Thread Nicolas Buduroi

Hi, I'm wondering how Clojure API reference page is generated? I'd
like to adapt it for the future Compojure website if possible. On
another note, how is Clojure website built and what language/framework
does it use?

Thanks

- budu
--~--~-~--~~~---~--~~
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure 1.0

2009-05-04 Thread Nicolas Buduroi

Wow, I really didn't expected this one! I also came to realize that
I've been using Clojure for a year now, the longest period of time
I've devoted to a single non-mainstream language. A million thanks!

Congratulations to Rich and all contributors.

On May 4, 8:58 am, Rich Hickey  wrote:
> After a sustained period of API stability and minimal bugs reports,
> I'm happy to announce the release of Clojure 1.0!
>
> http://clojure.googlecode.com/files/clojure_1.0.0.zip
>
> Numbered releases will enable people to consume a stable version of
> Clojure and move to bugfix-only incremental versions while preserving
> API stability, and to consume libraries designed to work with specific
> versions. Providing the bugfix-only revisions depends upon the
> community to submit patches for the release branch as well as the
> trunk.
>
> Clojure represents several years of effort on my part, but has also
> been shaped profoundly by the community in the 18 months since its
> release to the public. I can't thank everyone enough for your
> contributions of ideas, bug reports, suggestions, tests, tools,
> documentation and code - patches and enhancements. Clojure wouldn't be
> where it is today without its community and all of your efforts.
>
> Of course, there is more to do. Many good ideas have been suggested in
> the discussions preceding this release that were best put off for 1.1.
> Now with the release we can pursue them, and many others:
>
> http://clojure.org/todo
>
> I want to give special thanks to those who have made donations - they
> really help! I did the core work on Clojure during a self-funded
> sabbatical that has run its course (i.e. through my savings :) -
> donations help fund the future.
>
> Clojure 1.0 is a milestone of achievement, but it also represents a
> beginning. With 1.0, Stuart's book, the burgeoning set of libraries in
> and outside of contrib, and the large, friendly community, Clojure is
> poised to enter a period of increased adoption and application in many
> domains.
>
> Here's to the future!
>
> Rich
--~--~-~--~~~---~--~~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Dropping strings.

2009-04-30 Thread Nicolas Buduroi

> You can use (.substring s n), if n is larger than string length it
> will return a empty string.

Hum... that's not my experience, I'm at my job right now so I can't
double check this. Looking at the javadoc, it appears that if n is
larger than the string length it will throw an
IndexOutOfBoundsException. That must have been the reason why I've
written drop-str in the first place.

Thanks

- budu
--~--~-~--~~~---~--~~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Dropping strings.

2009-04-29 Thread Nicolas Buduroi

Hi, I was wondering if there's a drop function somewhere in contrib
that work for strings. I didn't found any so I wrote my own:

(defn drop-str
  ([s] (drop-str 1 s))
  ([n s] (apply str (drop n (seq s)

This is not really fast, a better version would be something like
that:

(defn drop-str [n #^String s]
  (let [l (.length s)]
(.substring s (if (> n l) l n

Any suggestions?

- budu

--~--~-~--~~~---~--~~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---