Re: Exception handling changes in Clojure 1.3.0

2011-10-09 Thread Constantine Vetoshev
I finally came up with a simple example which shows the broken
exception handling behavior I described in my earlier post on this
thread.

(defn broken-catch [filename]
  (try (java.io.FileReader. filename)
   (catch java.io.FileNotFoundException fnfe
 FileNotFoundException caught)
   (catch RuntimeException ioe
 (str RuntimeException caught; cause: 
  (.getCause ioe)

user= (broken-catch /etc/passwdXYZ)
RuntimeException caught; cause: java.io.FileNotFoundException: /etc/
passwdXYZ (No such file or directory)

The FileReader constructor throws a FileNotFoundException when the
file specified by the argument does not exist:
http://download.oracle.com/javase/6/docs/api/java/io/FileReader.html#FileReader(java.lang.String)
— and as you can see here, Clojure 1.3.0 wrapped it in a
RuntimeException, so the expected typed catch does not work.

However, if invoked in a way which bypasses reflection, the exception
is properly typed:

user= (try (java.io.FileReader. /etc/passwdXYZ)
 (catch java.io.FileNotFoundException fnfe
   FileNotFoundException caught)
 (catch RuntimeException ioe
   (str RuntimeException caught; cause: 
(.getCause ioe
FileNotFoundException caught

-- 
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


Google Maps in Clojurescript

2011-10-09 Thread Sam Ritchie
Hey all,

I started playing with Clojurescript tonight, and couldn't quite figure out
how to access an external library -- specifically the Google Maps API --
from within a clojurescript project. I can download maps.js, but how do I go
about including it in a project?

Thanks,

-- 
Sam Ritchie, Twitter Inc
703.662.1337
@sritchie09

(Too brief? Here's why! http://emailcharter.org)

-- 
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.base64

2011-10-09 Thread Ray Miller
On 6 October 2011 19:38, Ray Miller r...@1729.org.uk wrote:

 Incidentally, I used the Apache Commons Base64 encoder, as the one in
 contrib was producing different results from the Apache Commons and
 Perl implementations. Perhaps a bug?


Here's the problem I alluded to above. I'm trying to compute the
base64 MD5 digest of the string foobar. With Perl, I'd do it like
this:

   perl -MDigest::MD5=md5_base64 -le 'print md5_base64(foobar)'

Which gives me the string: OFj2IjCsPJFfMAxmQxLGPw

Now in Clojure, I can use java.security.MessageDigest to give me the
MD5 digest as a byte array. When I transform this to base64 using the
Apache Commons library, I get the same result as above. But when I try
to do it with clojure.contrib.base64, I get a slightly different
string. It's quite possible I've misunderstood the
clojure.contrib.base64 API (in which case enlightenment is welcome!),
but I wondered if I'd tickled a bug in the contrib library?

Here's the code:

(use '[clojure.contrib.io :only (to-byte-array input-stream)])

(import '[java.security MessageDigest]
'[java.io StringWriter]
'[org.apache.commons.codec.binary Base64])

(require '[clojure.contrib.base64 :as base64])

(def md5sum (.. (java.security.MessageDigest/getInstance MD5)
(digest (to-byte-array foobar
;;= #byte[] [B@6fd33eef

(org.apache.commons.codec.binary.Base64/encodeBase64String md5sum)
;;= OFj2IjCsPJFfMAxmQxLGPw==

(let [output (StringWriter.)]
  (base64/encode (input-stream md5sum)
 output
 base64/*base64-alphabet*
 nil)
  (.toString output))
;;= OF/2Ij+sP5FfMAxmQx/GPw==

This string differs in several positions (first at character 3). Any
idea what's going wrong?

Ray.

-- 
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: Google Maps in Clojurescript

2011-10-09 Thread r0man
Hi Sam,

this is how I use Google Maps with Clojurescript. In the html
page I load Google's Loader library, the Google Closure base.js
file and the deps.js file which is the one cljsc spit out.

(defhtml javascripts []
  (html
   (include-js (str https://www.google.com/jsapi?key=; (google-api-key)))
   (if (development?) (include-js /javascripts/goog/base.js))
   (include-js /javascripts/deps.js)
   (if (development?) (javascript-tag 
goog.require('burningswell.application');

After those have been loaded I require my application namespace,
which calls the start fn at the end of the file. Something like
this:

(defn ^:export start []
  (. js/google (load maps 3.6, (h/clj-js {:other_params 
sensor=false})))
  (. js/google
 (setOnLoadCallback
  (fn []
 (set! *map* (init-map (goog.dom/getElement map)))

(start)

I compile Clojurescript files with this command:

cljsc src/cljs '{:externs 
[closure-compiler/contrib/externs/maps/google_maps_api_v3_6.js 
closure-compiler/contrib/externs/google_loader_api.js] :output-dir 
resources/public/javascripts}'  resources/public/javascripts/deps.js

The important stuff is the externs option when using advanced
mode. This worked for me quiet well so far. I used this way
because I want to access the user's client location via Google's
loader API.

A simpler way is to include only the Google Maps javascript file
and it's extern file. That used to work also fine ...

Hope this helps, Roman.

-- 
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: Google Maps in Clojurescript

2011-10-09 Thread r0man
Forgot to mention my init-map fn:

(defn init-map [element]
  (let [options (h/clj-js {:zoom 1 :mapTypeId 
google.maps.MapTypeId.ROADMAP})
parent-size (style/getSize (. element parentNode))
element-size (style/getSize element)
map (doto (google.maps.Map. element options)
  (. (setCenter (to-lat-lng *location*)))
  (. (setZoom 10)))]
(style/setSize element (. element-size width) (. parent-size height))
(events/listen
 viewport-monitor
 events/EventType.RESIZE
 (fn [event] (google.maps.event/trigger map resize)

-- 
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: Oxjure - Oxford Clojure Group

2011-10-09 Thread Si
I'm not often in the UK, but when I am, I'm in the Thames Valley. It
would be great to have an Oxford Clojure group I could meet up with.

On Oct 8, 1:49 pm, Folcon fol...@gmail.com wrote:
 Hi Everyone,

 I'm interested in seeing if there are enough people in Oxford, United
 Kingdom to start an Oxford Clojure group. I'm willing to run the group in my
 spare time, but it would be useful to see if there are people here who would
 be interested in joining.

 I don't know if this is the right place to make such an announcement, but I
 think I need to start somewhere ;).

 I've visited the Cambridge Clojure group in the past and they
 are definitely a great bunch of people, but I've found it quite hard to find
 the time to regularly go. I've yet to visit the London group and hope to
 have the opportunity to do so in the future. So I think there is a need for
 Oxford to have it's own group.

 Please chime in with thoughts and ideas. I was thinking of setting up a
 meeting in the next week or two.

 Folcon

-- 
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: Anyone have any tips on functional - relational db data mapping?

2011-10-09 Thread Base
Can you create a db view for this? I have often tried to build this
sort of thing into the db as much as possible to reduce the complexity
of the app code and since this Ultimately what db's do well.  Of
course if you don not have create rights in the db you can't do
that...

On Oct 7, 7:55 am, Si si...@mintsource.org wrote:
 Hi all,

 I have a PostgreSQL database, which I am using via ClojureQL, and
 whilst basic relational operations are going smoothly, I'm wondering
 how to best tackle the n+1 selects issue and more generally how to
 construct a graph of maps and arrays from the relational data.

 As a specific example, I might fetch an array of (max 30 per page)
 books, but need access to the author via foreign key. I've thought of
 3 methods so far:

 * Leave as n + 1 selects. This might be useful when laziness is really
 needed, but almost all the time I would want eager fetching. I'll
 always want the author for a given book.

 * Use join to retrieve all the data in one hit. I would have clashing
 column names, which prevents ClojureQL result map creation, and would
 need to rename the projected fields to include the table name or
 similar (there's seemingly no way to instead specify table for columns
 at consumption time). Then I'd need to somehow convert the flattened
 data to hierarchical. Perhaps create or reuse by table name
 partitioned columns whilst moving through the array of hash data.

 * Use two selects, one for the books, then one for the authors where
 the id is in the foreign key set found by the first query. I can see
 that building a nested structure from the two arrays of hash data
 would be fairly straightforward.

 It feels like this last method is more simple, or perhaps a
 combination might be needed, but having been infantilized by ORMs for
 too long, the longer term best-bet is not clear to me, so I'm
 soliciting advice.

 Does anybody have any tips on this kind of functional - relational
 mapping?

-- 
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


Is there a clojure counterpart for java.lang.String indexOf method?

2011-10-09 Thread jingguo
java.lang.String has a method called indexOf(String str). We can use
it with
clojure in the following way:

(.indexOf 012 12)

Does clojure has a API for this? I have checked clojure.core and
clojure.string.
It seems that clojure does not have a counterpart for indexOf.

-- 
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: Is there a clojure counterpart for java.lang.String indexOf method?

2011-10-09 Thread Stephen Compall
On Sun, 2011-10-09 at 07:36 -0700, jingguo wrote:
 Does clojure has a API for this? I have checked clojure.core and
 clojure.string.
 It seems that clojure does not have a counterpart for indexOf.

No, it doesn't.

There's usually a way to do string operations that you traditionally do
with indexOf using other tools like regular expressions; these also have
the benefit of helping you avoid fencepost errors.

For example, if you wanted all the text before and after 12 in a
string, you could match #(?s)(.*?)12(.*).

That aside, while the lack of a Clojure-level facility should give you a
nudge to consider such alternatives, it's perfectly fine to call Java
when needed.

-- 
Stephen Compall
^aCollection allSatisfy: [:each|aCondition]: less is better

-- 
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: Anyone have any tips on functional - relational db data mapping?

2011-10-09 Thread Si
I have free reign over the db.

I think a view would simplify the join approach from the app
perspective, and this might be a good idea when the db is normalizing
data not needed to be seen by the app as separate objects, but I
sense a snag with join. It would work for 1-1 relationships, but for 1-
many, my pagination requirements would cull needed table rows (1 book
with 29 authors would saturate my 30 row retrieval limits). I'd need
to execute my base query of the books with limits via sub-select, then
eager fetch join at a higher level.

Using two queries is definitely looking much simpler at this point,
and I can't see myself breaching SELECT IN limitations for the
number of passed IDs I might be handling.

The process of manually eager fetching works as hoped in experimental
code (I get a nice functional-friendly set of all the data I need),
and so I'm now thinking on how I might hook that in to ClojureQL. My
pagination is currently taking a ClojureQL relational table object
(before deref), cloning the query, and running one refined with a
count function, one refined for limited data retreival. That works,
but it won't if the eager fetching is part of the query passed up to
the paginator doing this. That's because I'd need to have processed
the query already, to find out the IDs for prefetch, and the with-
paginated-results is sitting up at controller level currently ( 
wanting the query object, not it's result set).

Perhaps I can push pagination down into the IO portion of the model
code base, setting up a dynamic variable for page at request
handling time. When the model wishes to fetch some books, it discovers
it is in paged mode, and refines the query appropriately, leaving the
eager fetching to operate higher up the stack.

Bah! Feels too magical and I'd prefer explicit parameter passing
unless it's a real chore (like i18n locale handling throughout a
request). It might actually be simple to define my query code as
taking options, then explicitly passing in the page as one.

This then leaves the trickiness of spawning the extra count query when
the ClojureQL query is deref-ed, and updating the metadata of the
result set vector with a total count value. Actually, the total count
could be lazily generated. Rather than wrap anything coming back from
ClojureQL, I'd prefer to keep it as-is, enabling further query
refinement.

Any ideas on hooking in to ClojureQL this way?

Thanks

On Oct 9, 4:08 pm, Base basselh...@gmail.com wrote:
 Can you create a db view for this? I have often tried to build this
 sort of thing into the db as much as possible to reduce the complexity
 of the app code and since this Ultimately what db's do well.  Of
 course if you don not have create rights in the db you can't do
 that...

 On Oct 7, 7:55 am, Si si...@mintsource.org wrote:







  Hi all,

  I have a PostgreSQL database, which I am using via ClojureQL, and
  whilst basic relational operations are going smoothly, I'm wondering
  how to best tackle the n+1 selects issue and more generally how to
  construct a graph of maps and arrays from the relational data.

  As a specific example, I might fetch an array of (max 30 per page)
  books, but need access to the author via foreign key. I've thought of
  3 methods so far:

  * Leave as n + 1 selects. This might be useful when laziness is really
  needed, but almost all the time I would want eager fetching. I'll
  always want the author for a given book.

  * Use join to retrieve all the data in one hit. I would have clashing
  column names, which prevents ClojureQL result map creation, and would
  need to rename the projected fields to include the table name or
  similar (there's seemingly no way to instead specify table for columns
  at consumption time). Then I'd need to somehow convert the flattened
  data to hierarchical. Perhaps create or reuse by table name
  partitioned columns whilst moving through the array of hash data.

  * Use two selects, one for the books, then one for the authors where
  the id is in the foreign key set found by the first query. I can see
  that building a nested structure from the two arrays of hash data
  would be fairly straightforward.

  It feels like this last method is more simple, or perhaps a
  combination might be needed, but having been infantilized by ORMs for
  too long, the longer term best-bet is not clear to me, so I'm
  soliciting advice.

  Does anybody have any tips on this kind of functional - relational
  mapping?

-- 
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


Stanford Dabatabase Class Begins Tomorrow

2011-10-09 Thread Harrison Maseko
The Stanford Introduction to Databases class officially starts
tomorrow, October 10, 2011. I have enrolled and look forward to this
nine-week online course. I was wondering if anyone on this list is
taking it. It will be encouraging to know I am not the only Clojure
programmer doing this!?
-h.

-- 
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.base64

2011-10-09 Thread Teemu Antti-Poika
On Oct 9, 12:56 pm, Ray Miller r...@1729.org.uk wrote:
 On 6 October 2011 19:38, Ray Miller r...@1729.org.uk wrote:
  Incidentally, I used the Apache Commons Base64 encoder, as the one in
  contrib was producing different results from the Apache Commons and
  Perl implementations. Perhaps a bug?

 ...
 This string differs in several positions (first at character 3). Any
 idea what's going wrong?

That does look like a bug. On closer look base64/encode does not
handle
negative bytes properly (java has only unsigned bytes and bitwise
operations on byte arrays always cause grief).

I have a fix in https://github.com/anttipoi/clojure-contrib if anyone
is interested. I do have the CA sent in, so you're welcome to pull,
if that is appropriate.

As discussed elsewhere, the base64 module is not very efficient and
is not currently planned to be migrated to a new style contrib module.
Maybe using commons-codec is the best alternative for you?

Yours,
Teemu Antti-Poika

-- 
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.base64

2011-10-09 Thread Ray Miller
On 9 October 2011 20:13, Teemu Antti-Poika antti...@gmail.com wrote:
 On Oct 9, 12:56 pm, Ray Miller r...@1729.org.uk wrote:
 On 6 October 2011 19:38, Ray Miller r...@1729.org.uk wrote:
  Incidentally, I used the Apache Commons Base64 encoder, as the one in
  contrib was producing different results from the Apache Commons and
  Perl implementations. Perhaps a bug?

 ...
 This string differs in several positions (first at character 3). Any
 idea what's going wrong?

 That does look like a bug. On closer look base64/encode does not
 handle negative bytes properly (java has only unsigned bytes and bitwise
 operations on byte arrays always cause grief).

Thanks for investigating and tracking down the bug - I didn't know
were to start!

 As discussed elsewhere, the base64 module is not very efficient and
 is not currently planned to be migrated to a new style contrib module.
 Maybe using commons-codec is the best alternative for you?

I already switched my code to use commons-codec, just posted here in
case it was a bug in the contrib library that might catch out someone
else.

Thanks again for your investigation and explanation.

Ray.

-- 
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: core.match 0.2.0-alpha5

2011-10-09 Thread David Nolen
I've removed some fairly big bugs in the algorithm. This will probably the
be the last alpha release before I cut a beta. Would love to hear any and
all feedback.

In particular if people have strong opinions about the remaining issues, let
me know now - http://dev.clojure.org/jira/browse/MATCH

Two things not listed there that I'm considering:

- clojure.core.match instead of clojure.core.match.core
- return nil instead of throwing if no match found to mirror the behavior of
cond

David

-- 
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: core.match 0.2.0-alpha5

2011-10-09 Thread Daniel Pittman
On Sun, Oct 9, 2011 at 12:31, David Nolen dnolen.li...@gmail.com wrote:

 I've removed some fairly big bugs in the algorithm. This will probably the
 be the last alpha release before I cut a beta. Would love to hear any and
 all feedback.
 In particular if people have strong opinions about the remaining issues, let
 me know now - http://dev.clojure.org/jira/browse/MATCH
 Two things not listed there that I'm considering:
 - clojure.core.match instead of clojure.core.match.core

That would have been a lot less surprising to me when I started
working with the library; it feels right that the main library is
named `match`, and extensions `match.whatever`, under the core
namespace.

 - return nil instead of throwing if no match found to mirror the behavior of 
 cond

Given `:else (throw ...)` I would entirely support that from my use of
the library.

Thanks,
Daniel
-- 
♲ Made with 100 percent post-consumer electrons

-- 
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: Stanford Dabatabase Class Begins Tomorrow

2011-10-09 Thread Andreas Kostler
I am :)

On 10 October 2011 04:02, Harrison Maseko lis...@gmail.com wrote:
 The Stanford Introduction to Databases class officially starts
 tomorrow, October 10, 2011. I have enrolled and look forward to this
 nine-week online course. I was wondering if anyone on this list is
 taking it. It will be encouraging to know I am not the only Clojure
 programmer doing this!?
 -h.

 --
 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


Re: Oxjure - Oxford Clojure Group

2011-10-09 Thread Folcon
A real world group was more what I had in mind :). Similar to Seajure etc.

@Si you are welcome to anything we manage to setup, though I am hoping we 
will get more interest over the week :).

I'm trying to work out a good/convenient place for the gathering. Preferably 
with a table for laptop carriers.

-- 
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: Stanford Dabatabase Class Begins Tomorrow

2011-10-09 Thread Claudia Zignaigo
I am, too! :)

2011/10/9 Andreas Kostler andreas.koest...@leica-geosystems.com

 I am :)

 On 10 October 2011 04:02, Harrison Maseko lis...@gmail.com wrote:
  The Stanford Introduction to Databases class officially starts
  tomorrow, October 10, 2011. I have enrolled and look forward to this
  nine-week online course. I was wondering if anyone on this list is
  taking it. It will be encouraging to know I am not the only Clojure
  programmer doing this!?
  -h.
 
  --
  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




-- 
Claudia Zignaigo

+39 333 1824595
http://gplus.to/gattoclaudia
@gattoclaudia
http://stackoverflow.com/users/560848/doppioslash

-- 
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: core.match 0.2.0-alpha5

2011-10-09 Thread Alan Malloy
On Oct 9, 12:31 pm, David Nolen dnolen.li...@gmail.com wrote:
 I've removed some fairly big bugs in the algorithm. This will probably the
 be the last alpha release before I cut a beta. Would love to hear any and
 all feedback.
 - clojure.core.match instead of clojure.core.match.core

Those both seem weird to me, unless the plan is to make it part of
clojure.core eventually. clojure.match is the namespace I would
expect to find it under, with clojure.match.core a reasonable second
choice. I assume you have a reason, though; would you mind explaining
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: Spread work onto multiple threads (in pure Clojure)

2011-10-09 Thread Lee Spector

I've been playing with medusa and it sometimes does what I expect, but 
sometimes it's doing something strange and I'm wondering if someone can help me 
to do one specific medusa-like thing but more simply (and without the 
strangeness, which I haven't fully traced but I hope to avoid having to).

What I want is a version of pmap that will always use any available cores to 
compute remaining values (except of course the last couple of values, when 
there are less remaining values than cores). 

In other words, I want the behavior that Andy Fingerhut describes medusa as 
having here:

 On Sep 22, 2011, at 11:34 PM, Andy Fingerhut wrote:
 
  pmap will limit the maximum number of simultaneous threads.  So will the 
  medusa library's medusa-pmap.
 
  The difference is that if one job early in the list takes, e.g., 100 times 
  longer than the next 20, and you have 4 cpus available, pmap will start the 
  first (4+2)=6 in parallel threads, let jobs 2 through 6 complete, and then 
  wait for the first one to finish before starting number 7.  Thus most of 
  the time will be spent running one thread.  This has the advantage of 
  limiting the memory required to store intermediate results, but the 
  disadvantage of low usage of multiple cpu cores.
 
  Medusa has a medusa-pmap that will also limit the parallelism, but it lets 
  you pick the level of parallelism (it isn't fixed at (# cpus + 2)), and it 
  will continue starting new threads, even if that means using more memory 
  when one job takes much longer than the following jobs.
 

FWIW I'll always be calling this on a finite sequence (although it may have 
1 elements or so, so I presume that I shouldn't start threads for all of 
them at once), and I will want a fully realized result sequence so I'll 
surround calls with doall if necessary. I will want all of the pmapped 
computations to finish before I continue doing anything else.

I know that I could launch the threads in other ways -- e.g. I sometimes use 
agents for something similar -- but pmap is much more elegant in many cases, 
and anyway I'm not even sure I'm getting full utilization with my other methods.

The medusa-pmap function is very close to what I want but medusa seems to do 
more that what I need, it requires initi/startup calls, it involves timeouts 
which I will never want, and it behaves strangely when I run my code on a 48 
core node. (It runs fine on my 4-core laptop, and then it seems to work 
beautifully on the 48 core node too for a while, giving me nearly 4800% 
utilization, but then it does something that looks like it might be caused by 
everything hitting the timeouts... which I bumped up by several orders of 
magnitude but I'm still getting the weird behavior).

So: Is there a simpler way to get pmap but not lazy and use all cores fully 
until the whole result sequence is completed? This is usually what I really 
want when I'm writing code that utilizes concurrency.

I've looked at the pmap source but it isn't obvious to me how to change that to 
do what I want... So any pointers would be appreciated.

Thanks,

 -Lee

-- 
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


where can I find the official statement about changes from 1.2 to 1.3?

2011-10-09 Thread jaime
When I tried to answer a question (from other people) about why in 1.3
we need to explicitly declare ^:dynamic for a Var, I found I cannot
find an official document about this change from 1.2 (or older
version) to 1.3. I went to github (https://github.com/clojure/clojure/
blob/master/changes.md) but only found description like 1.1 Earmuffed
Vars are No Longer Automatically Considered Dynamic -- at first
glance I thought that the explicit declaration thing is only for
earmuffed Vars but when I tried it in a 1.3 REPL, I found we need to
explicitly declare all Vars to ^:dynamic if we want a rebinding.

Where can I find the official statement about this change (or other
similar changes)?

-- 
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: Oxjure - Oxford Clojure Group

2011-10-09 Thread jaime
Got it. :-)

On Oct 9, 11:00 am, jaime xiejianm...@gmail.com wrote:
 Why not use this group directly?? I personally think separating people
 in different groups will disperse people's attention only.what is
 the benefit?

 On Oct 8, 7:49 pm, Folcon fol...@gmail.com wrote:







  Hi Everyone,

  I'm interested in seeing if there are enough people in Oxford, United
  Kingdom to start an Oxford Clojure group. I'm willing to run the group in my
  spare time, but it would be useful to see if there are people here who would
  be interested in joining.

  I don't know if this is the right place to make such an announcement, but I
  think I need to start somewhere ;).

  I've visited the Cambridge Clojure group in the past and they
  are definitely a great bunch of people, but I've found it quite hard to find
  the time to regularly go. I've yet to visit the London group and hope to
  have the opportunity to do so in the future. So I think there is a need for
  Oxford to have it's own group.

  Please chime in with thoughts and ideas. I was thinking of setting up a
  meeting in the next week or two.

  Folcon

-- 
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 to Collapse Nested Map into a Sequence of Flat Maps

2011-10-09 Thread Ari
Hi,

I'd appreciate suggestions and insights on how I can collapse a nested
map with n number of keys (levels) to create a flat map which is
comprised of composite keys and a value. For example, let's say we
have:

{ a { 2011 [ [ a 2011 ari] [ a 2011 dan] ] } { 2010 [ [ a
2010 jon] ] } }

I'd like to collapse the nest into a sequence of flat maps like:

( { [a 2011] [ [a 2011 ari] [a 2011 dan] ] }, { [a 2010]
[ [a 2010 jon] ] } )

Thanks.

Regards,
Ari

-- 
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 to Collapse Nested Map into a Sequence of Flat Maps

2011-10-09 Thread Alan Malloy
Your input isn't a legal Clojure form, and the correlation between
input and output is difficult to spot, so it is hard to guess what you
mean. Try a simpler example, preferably with less repetition of
similar-looking values.

On Oct 9, 5:34 pm, Ari ari.brandeis.k...@gmail.com wrote:
 Hi,

 I'd appreciate suggestions and insights on how I can collapse a nested
 map with n number of keys (levels) to create a flat map which is
 comprised of composite keys and a value. For example, let's say we
 have:

 { a { 2011 [ [ a 2011 ari] [ a 2011 dan] ] } { 2010 [ [ a
 2010 jon] ] } }

 I'd like to collapse the nest into a sequence of flat maps like:

 ( { [a 2011] [ [a 2011 ari] [a 2011 dan] ] }, { [a 2010]
 [ [a 2010 jon] ] } )

 Thanks.

 Regards,
 Ari

-- 
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.base64

2011-10-09 Thread Stuart Sierra
The original clojure.contrib.base64 was little more than an exercise. This 
is the kind of thing that Java libraries do well; don't see much point to 
rewriting in Clojure unless somebody clever can make one that's actually 
*faster* than the best Java lib.

-S

-- 
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: core.match 0.2.0-alpha5

2011-10-09 Thread Ambrose Bonnaire-Sergeant
On Mon, Oct 10, 2011 at 3:31 AM, David Nolen dnolen.li...@gmail.com wrote:

 - return nil instead of throwing if no match found to mirror the behavior
 of cond


I don't like this.

Why are we emulating cond? clojure.core/case, for example, seems closer to
what `match` provides,
and that throws an IllegalArgumentException if there is no match.

Seems arbitrary to me.

Is there more to it?

Thanks,
Ambrose

-- 
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

inconsistent results from String.valueOf

2011-10-09 Thread Jack Moffitt
Hi,

I discovered this testing some code this evening:

(String/valueOf nil) ; throws NullPointerException

(#(String/valueOf %) nil) ; null

Another formulation of the above (courtesy of brehaut in IRC):

(let [s nil] (String/valueOf s)) ; exception
(let [s nil] (String/valueOf ^Object s)) ; null

The correct output should be null. It seems that in the direct
invocation, the Clojure compiler is choosing the wrong implementation
of valueOf. This appears to be the same in both Clojure 1.2 and
Clojure 1.3.

Is this a bug?

jack.

-- 
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: Stanford Dabatabase Class Begins Tomorrow

2011-10-09 Thread Harrison Maseko
Great! Hope we'll cross paths on the forums.
-h.

On Oct 10, 1:12 am, Claudia Zignaigo claudia.doppiosl...@gmail.com
wrote:
 I am, too! :)

 2011/10/9 Andreas Kostler andreas.koest...@leica-geosystems.com





  I am :)

  On 10 October 2011 04:02, Harrison Maseko lis...@gmail.com wrote:
   The Stanford Introduction to Databases class officially starts
   tomorrow, October 10, 2011. I have enrolled and look forward to this
   nine-week online course. I was wondering if anyone on this list is
   taking it. It will be encouraging to know I am not the only Clojure
   programmer doing this!?
   -h.

   --
   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

 --
 Claudia Zignaigo

 +39 333 1824595http://gplus.to/gattoclaudia
 @gattoclaudiahttp://stackoverflow.com/users/560848/doppioslash- Hide quoted 
 text -

 - Show quoted text -

-- 
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