Re: clojure-contrib 1.3.0-alpha2 deployed to build.clojure.org

2010-10-27 Thread Jacek Laskowski
On Wed, Oct 27, 2010 at 4:37 AM, Btsai benny.t...@gmail.com wrote:
 Is there still a complete jar somewhere that has all the modules?  If
 so, I can't seem to find it.  Or is that a thing of the past now?

s/complete/standalone :-)

I believe it's 
http://build.clojure.org/releases/org/clojure/contrib/standalone/1.3.0-alpha2/standalone-1.3.0-alpha2.jar.
It seems to work with Clojure 1.3.0-alpha2 and c.c.monads. It contains
clj's and classes.

wget -O clojure-contrib-1.3.0-alpha2.jar
http://build.clojure.org/releases/org/clojure/contrib/standalone/1.3.0-alpha2/standalone-1.3.0-alpha2.jar
and update your launch script for REPL.

I wish there'd be a link to a zip distro in Developer Releases
alongside w/ the Clojure zip file itself. Is it already provided by
the mvn-based build?

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://jaceklaskowski.pl

-- 
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: Getting this error regarding duck-streams/spit ...

2010-10-27 Thread Btsai
Awesome!  Thanks for the great work, Tom :)  clojuredocs has quickly
become my go-to reference source.

On Oct 26, 11:46 pm, Tom Faulhaber tomfaulha...@gmail.com wrote:
 You remind me that I need to markhttp://richhickey.github.com/clojure...
 as obsolete and redirect users to the new place.

 Zack Kim and I are working to have clojuredocs pull data from the
 autodoc system and, at that point, I assume that he'll add deprecation
 info over there as well.

 Sorry for any confusion! Clojure's still a fast moving target.

 Tom

 On Oct 26, 12:48 pm, Btsai benny.t...@gmail.com wrote:







  I'm fairly positive duck-streams is deprecated, as it is no longer
  present in the clojure-contrib git repository:

 http://github.com/clojure/clojure-contrib/tree/master/modules/

 http://richhickey.github.com/clojure-contrib/doesn'thave the
  deprecation info most likely because it is the documentation for the
  original (now outdated) clojure-contrib repository, and doesn't have
  1.2 info.

 http://clojure.github.com/clojure-contrib/isthe documentation for
  the current repository.

  clojuredocs should probably be updated to include the deprecation
  info, and also have its link to clojure-contrib point to the current
  repository.

  On Oct 26, 12:44 pm, Victor Olteanu bluestar...@gmail.com wrote:

   Thank you Btsai. I checked 
   bothhttp://richhickey.github.com/clojure-contrib/io-api.html#clojure.cont...
   andhttp://clojuredocs.org/clojure_contrib/clojure.contrib.duck-streams/s...
   and couldn't find any reference to deprecation.
   If you can confirm that this deprecation was made official then we could
   update those docs so other people won't run into these same issues.

   Victor

   On Tue, Oct 26, 2010 at 12:46 AM, Btsai benny.t...@gmail.com wrote:
I don't think it's a mistake or accident that spit exists in
clojure.core.  In 1.2, duck-streams became deprecated and functions
such as spit were incorporated into clojure.core:

   http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/...
   http://clojure.github.com/clojure-contrib/duck-streams-api.html

Are you using anything beyond spit and slurp*?  If not, I think you
can switch to clojure.core's slurp and spit and drop duck-streams
altogether.

On Oct 25, 8:59 pm, Victor Olteanu bluestar...@gmail.com wrote:
 Thank you.

 The following statement worked for me:
 (:require [clojure.contrib.duck-streams :as d])

 As I was using slurp and slurp*, I then had to do the following:

 use the form d/slurp* instead (prefixed with d/)
 use slurp without a change

 This brings up a related point - I can see that there are functions 
 with
the
 same name in different packages, which I believe it's quite 
 unfortunate.
 There is slurp in clojure.core and there is duck-streams/slurp* , 
 along
with
 other functions such as spit...

 I hope this kind of things might be addressed in future versions of
 Clojure...

--
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.comclojure%2bunsubscr...@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


I eat parentheses for breakfast

2010-10-27 Thread David Sletten
Some of you might enjoy the music video for the new Land of Lisp book:
http://www.youtube.com/watch?v=HM1Zb3xmvMcfeature=player_embedded

Have all good days,
David Sletten




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


I eat parentheses for breakfast

2010-10-27 Thread David Sletten
Some of you might enjoy the music video for the new Land of Lisp book:
http://www.youtube.com/watch?v=HM1Zb3xmvMcfeature=player_embedded

Have all good days,
David Sletten




-- 
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: I eat parentheses for breakfast

2010-10-27 Thread Baishampayan Ghose
 Some of you might enjoy the music video for the new Land of Lisp book:
 http://www.youtube.com/watch?v=HM1Zb3xmvMcfeature=player_embedded

Wow. Kick ass. Every programmer should learn a little Lisp -- hell yeah!

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
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 pass lazy seq to function for processing without keeping the head?

2010-10-27 Thread rb
I have a big MySQL database containing telephone call detail records.

The database is on a remote server and it's a bit slow to access. I
want to migrate the data to local SQLite databases on my machine for
further processing. I want to store each month's records in separate
files, located under ~/calls/source/year/year-month.db, where
source is a string identifying the telephone switch which processed
the call (lucent or c4), while year and month correspond to
the start date of the call.

I wrote two functions, one to SELECT the records from the MySQL
database, the other to store them in SQLite. The first function would
generate a lazy seq of records (maps), while the second would take
this seq of maps and INSERT the records to the appropriate SQLite
databases.

Here are the current versions of the two functions:

(defn c4-calls
  [st-prefix]
  (let [conn (datasource/connection datasource/cdr-c4)
stmt (.prepareStatement
  conn
  (format SELECT
 SUBSTRING(a,5) AS a,
 SUBSTRING(b,3) AS b,
 SUBSTRING(st,1,14) AS st,
 duration/1000 AS duration
   FROM `call`
   WHERE st LIKE '%s%%'
   ORDER BY st st-prefix))]
(for [rec (resultset-seq (.executeQuery stmt))
  :let [{:keys [a b st duration]} rec]]
  {:a a
   :b b
   :st st
   :duration duration})))

The (datasource/connection datasource/cdr-c4) call returns a
java.sql.Connection to the MySQL db. Each record returned from MySQL
gets packaged into map and is returned to the caller in a lazy seq (or
at least that's what I expect reading the documentation of the 'for'
macro).

Here is the one which stores the records to the corresponding SQLite
db:

(defn store-calls
  [source calls]
  (when (not (#{lucent c4} source))
(throw (RuntimeException. invalid source, must be \lucent\ or
\c4\)))
  (loop [calls calls
 conn nil
 stmt nil
 year nil
 month nil]
(if-let [c (first calls)]
  (let [y (Integer/parseInt (.substring (:st c) 0 4))
m (Integer/parseInt (.substring (:st c) 4 6))]
(if (or (nil? conn) (not= y year) (not= m month))
  (do
(when conn (.commit conn))
(let [conn (call-db source y m)
  stmt (.prepareStatement conn INSERT INTO `call`
(a,b,st,duration) VALUES (?,?,?,?))]
  (recur calls conn stmt y m)))
  (do
(.setString stmt 1 (:a c))
(.setString stmt 2 (:b c))
(.setString stmt 3 (:st c))
(.setDouble stmt 4 (:duration c))
(.executeUpdate stmt)
(recur (rest calls) conn stmt year month
  (when conn (.commit conn)

The idea is to iterate over the calls and if there is a difference
between the year/month of the previously processed record and this
one, switch to the corresponding SQLite connection, before the record
is written via INSERT. The function 'call-db' ensures that the SQLite
database identified by the passed source-year-month triad exists and
returns a java.sql.Connection to it.

My problem is a java heap space overflow error.

The likely reason may be that I keep a reference to 'calls' in the
store-calls function 1. in the function arg, 2. in the loop ([calls
calls]) - although I doubt that the second would be a problem.

I thought about using two signatures, [source calls] on one hand and
[source calls conn stmt year month] on the other, thereby substituting
the loop with a function which I can recur to, but even then, the
[source calls] version would be called first, which would pass the
calls to the other, which means the head was just kept again.

It also occurred to me that I should think in records instead of maps
and write store-calls as a kind of filter (store-call), but then I'd
lose the ability to compare the dates of the previous/current records
or would have to resort to some caching trickery which I'd rather
avoid.

Any ideas?

-- 
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 pass lazy seq to function for processing without keeping the head?

2010-10-27 Thread rb
Oops, I made an error in the last paragraph:

 It also occurred to me that I should think in records instead of __seqs__
 and write store-calls as a kind of filter (store-call), but then I'd
 lose the ability to compare the dates of the previous/current records
 or would have to resort to some caching trickery which I'd rather
 avoid.

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


bug or misunderstanding intern?

2010-10-27 Thread bOR_
Hi all.
This got me puzzled. Intern has trouble with symbols containing
periods?

user *clojure-
version*
{:major 1, :minor 2, :incremental 0, :qualifier }

user (intern *ns* (symbol orig-0.5)
3)
#'user/
orig-0.5

user
orig-0.5
; Evaluation aborted.  [Thrown class
java.lang.ClassNotFoundException]  0: java.net.URLClassLoader
$1.run(URLClassLoader.java:217)

user (intern *ns* (symbol orig-05)
3)
#'user/
orig-05

user
orig-05
3

-- 
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: bug or misunderstanding intern?

2010-10-27 Thread Meikel Brandmeyer
Hi,

from http://clojure.org/reader: Symbols begin with a non-numeric
character and can contain alphanumeric characters and *, +, !, -, _,
and ?. (and ' with 1.3 I guess)

So not really surprising behaviour.

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: bug or misunderstanding intern?

2010-10-27 Thread Meikel Brandmeyer
Hi again,

and additionally (explaining the error message): '.' has special
meaning - it can be used one or more times in the middle of a symbol
to designate a fully-qualified class name, e.g. java.util.BitSet, or
in namespace names.

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


using a macro like a function

2010-10-27 Thread Sunil S Nandihalli
Hello everybody,

I would like to do something like the following ..

 (- create clojure.repl/apropos (map doc))

but I can't do it since doc is a macro and not a function.. how would one
wrap doc with a function so that it can be used in the above example.

Thanks
Sunil.

-- 
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 a macro like a function

2010-10-27 Thread Meikel Brandmeyer
Hi,

On 27 Okt., 13:53, Sunil S Nandihalli sunil.nandiha...@gmail.com
wrote:

 I would like to do something like the following ..

  (- create clojure.repl/apropos (map doc))

 but I can't do it since doc is a macro and not a function.. how would one
 wrap doc with a function so that it can be used in the above example.

You can't. You have to rewrite doc as a function.
http://bitbucket.org/kotarak/vimclojure/src/tip/server/src/main/clojure/vimclojure/backend.clj#cl-31

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: using a macro like a function

2010-10-27 Thread Sunil S Nandihalli
Thanks Meikel..

so it looks like doc was written as a macro since they wanted to avoid
people having to quote the symbol when called from the repl.. or is there
any other reason also?

Sunil.

On Wed, Oct 27, 2010 at 5:28 PM, Meikel Brandmeyer m...@kotka.de wrote:

 Hi,

 On 27 Okt., 13:53, Sunil S Nandihalli sunil.nandiha...@gmail.com
 wrote:

  I would like to do something like the following ..
 
   (- create clojure.repl/apropos (map doc))
 
  but I can't do it since doc is a macro and not a function.. how would one
  wrap doc with a function so that it can be used in the above example.

 You can't. You have to rewrite doc as a function.

 http://bitbucket.org/kotarak/vimclojure/src/tip/server/src/main/clojure/vimclojure/backend.clj#cl-31

 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.comclojure%2bunsubscr...@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: using a macro like a function

2010-10-27 Thread Ken Wesson
On Wed, Oct 27, 2010 at 7:53 AM, Sunil S Nandihalli 
sunil.nandiha...@gmail.com wrote:

 Hello everybody,

 I would like to do something like the following ..

  (- create clojure.repl/apropos (map doc))

 but I can't do it since doc is a macro and not a function.. how would one
 wrap doc with a function so that it can be used in the above example.


It's a bit evil, but this works:

#(eval `(doc ~%)))

-- 
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: challenge with vectors

2010-10-27 Thread Glen Rubin
wow, i think you just went way over my head.  First off a very naive
question: I thought all clojure programming was functional, as long as
you are not using refs, agents, or other mutable values etc...??





On Oct 27, 12:26 am, Aravindh Johendran ajohend...@gmail.com wrote:
 What kind of an answer are you looking for? Just the quickest way to
 do it? Do you want an idiomatic clojure solution or are you learning
 functional programming using clojure? There are many ways to do this.
 Others have provided cool solutions.

 Here's a way of doing it if you are interested in filled-with-fun bare-
 bones no-frills functional code. It will NOT be the fastest solution.

 (defn min-b [vctr collection-function]
   (let [current-item (first vctr)]
     (cond (empty? vctr) (collection-function [] -1)
           (= 1 (count vctr)) (collection-function current-item 1)
           :else (min-b (rest vctr) (fn [next-item pos] (if ( (second next-
 item) (second current-item))
                                                              
 (collection-function next-item (inc pos))
                                                              
 (collection-function current-item pos)))

 The initial function you pass in will contain the logic to print out
 the result. Over here we are making a simple list out of the result .
 You can modify it to print out whatever you want done with the result
 (min-b [ [22 5] [56 8] [99 3] [43 76] ]  (fn [x y] (list x y)))
 or
 (min-b [ [22 5] [56 8] [99 3] [43 76] ]  (fn [x y] (println (str
 Value:  x  Position:  y

 If you have a large data set and are worried about blowing the stack,
 you'll have to use recur and trampoline. Notice the extra # before the
 returned functions

 (defn min-b [vctr collection-function]
   (let [current-item (first vctr)]
     (cond (empty? vctr) (collection-function [] -1)
           (= 1 (count vctr)) #(collection-function current-item 1)
           :else (recur (rest vctr) (fn [next-item pos] (if ( (second next-
 item) (second current-item))
                                                              
 #(collection-function next-item (inc pos))
                                                              
 #(collection-function current-item pos)))

 (trampoline (min-b (vec (take 5000 (cycle [ [22 5] [56 8] [99 3] [43
 76] ])))  (fn [x y] (list x y

 This example should demonstrate why hard tail calls are not a mere
 recursion thing.

-- 
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: Images in autodoc?

2010-10-27 Thread Andrew Gwozdziewycz
So, I started working on docup[1], which currently is just for fun,
but my intentions are to find some subset of rules for what we've
discussed in this thread that would be appropriate for autodoc's
markup. It doesn't currently support much at all, but to eliminate
gobbledegook, there's no nesting of simple element types (bold,
italic, underline, inline code). The plan is to support images, lists,
links (by recognizing some common raw URLs), blocks, and eventually
equations (though I'm not convinced they can be simplified for REPL
documentation). For images/figures, the current plan is to use the
footnote approach as discussed previously, but, rearrange the syntax
to eliminate the excess noise:

  ![caption][ref label] = [ref label: caption]

There would be no supported way to inline the reference for the
image--again, the goal as Tom reiterated originally is to eliminate
excess junk.

[1]: http://github.com/apgwoz/clj-docup

On Tue, Oct 26, 2010 at 6:21 PM, Chris Maier
christopher.ma...@gmail.com wrote:
 On Tue, Oct 26, 2010 at 4:44 PM, Timo Mihaljov noid@gmail.com wrote:
 If you wanted to get real fancy, you could even check if the code
 block is a list, and then resolve each symbol inside the list, so
 that, for example, resolve's docstring would look like this at the
 REPL:

 user= (doc resolve)
 -
 clojure.core/resolve
 ([sym])
  same as `(ns-resolve *ns* sym)`

 But in the HTML documentation `ns-resolve` and `*ns*` would be
 hyperlinks.

 That is slick.

 If there's any way I can help out, too, sign me up.

 Chris

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



-- 
http://www.apgwoz.com

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


creating a function from a sexp

2010-10-27 Thread Sunil S Nandihalli
Hello everybody,

I would like to create a function from an arbitrary s-expression for example
if I have something like

(def x 10)
(let [y 20]
  (create-fn-from-sexp '(+ x y z)))

I would like create-fn-from-sexp to return a function which is a function of
the third argument z .. since both x and y are both bound in this lexical
scope . Is it possible to write such a function?  If the create-fn-from-sexp
worked correctly the above code would be equivalent to


(def x 10)
(let [y 20]
 (fn [z] (+ x y z))

Is it possible to write such a function?

thanks
Sunil.

-- 
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 1.3.0-alpha2 deployed to build.clojure.org

2010-10-27 Thread Stuart Sierra
Yes, to get one big JAR containing all of clojure-contrib, you can
depend on:

  groupId: org.clojure.contrib
  artifactId: standalone
  version: 1.3.0-alpha2

  Or in Leiningen: [org.clojure.contrib/standalone 1.3.0-alpha2]


To get lots of little JARs for each of the contrib libraries, you can
depend on:

  groupId: org.clojure.contrib
  artifactId: complete
  version: 1.3.0-alpha2

  Or in Leiningen: [org.clojure.contrib/complete 1.3.0-alpha2]


To get just a single library, check out the list at
http://build.clojure.org/releases/org/clojure/contrib/
and depend on:

  groupId: org.clojure.contrib
  artifactId: NAME-OF-THE-LIBRARY
  version: 1.3.0-alpha2

  Or in Leiningen: [org.clojure.contrib/NAME-OF-THE-LIBRARY 1.3.0-
alpha2]

-S



On Oct 26, 10:37 pm, Btsai benny.t...@gmail.com wrote:
 Is there still a complete jar somewhere that has all the modules?  If
 so, I can't seem to find it.  Or is that a thing of the past now?

-- 
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: creating a function from a sexp

2010-10-27 Thread Ulises
 Is it possible to write such a function?

Perhaps you're looking for partial?

user (def x 10)
#'user/x
user (let [y 5] (partial + x y))
#core$partial$fn__3680 clojure.core$partial$fn__3...@beebcd
user ((let [y 5] (partial + x y)) 1)
16
user

U

-- 
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: creating a function from a sexp

2010-10-27 Thread Sunil S Nandihalli
not really the problem is that the s-expression is passed I don't know it
ahead of time during compilation .. it is known at run-time...

On Wed, Oct 27, 2010 at 6:54 PM, Ulises ulises.cerv...@gmail.com wrote:

  Is it possible to write such a function?

 Perhaps you're looking for partial?

 user (def x 10)
 #'user/x
 user (let [y 5] (partial + x y))
 #core$partial$fn__3680 clojure.core$partial$fn__3...@beebcd
 user ((let [y 5] (partial + x y)) 1)
 16
 user

 U

 --
 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.comclojure%2bunsubscr...@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: creating a function from a sexp

2010-10-27 Thread nicolas.o...@gmail.com
You need to use both eval and a macro to get then environment.
I think env contains the lexical environment in any macro call now.
(I don't know in each form though).
So you need to walk the term, looking for free variables, close under
free variables by creating a function and then call eval.

That's probably quite some work to write.

Altogether, it looks like at least a step too far. (Especially some
kind of problem may arise: what of (+  x y ((fn [z] z) 3))?)
But I know sometimes it is necessary to go a few steps further than we should.

What is the use case?

Best,

Nicolas.

-- 
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 pass lazy seq to function for processing without keeping the head?

2010-10-27 Thread rb
Hi everyone,

I found the solution and it has nothing to do with my ramblings above.

It turns out that when I do (.executeQuery stmt), the MySQL JDBC
driver fetches the entire resultset from the server at once.

Here is how to make it lazy also on the JDBC side:

  (let [conn (datasource/connection datasource/cdr-c4)
stmt (.prepareStatement
  conn
  (format SELECT
 SUBSTRING(a,5) AS a,
 SUBSTRING(b,3) AS b,
 SUBSTRING(st,1,14) AS st,
 duration/1000 AS duration
   FROM `call`
   WHERE st LIKE '%s%%'
   ORDER BY st st-prefix)
  java.sql.ResultSet/TYPE_FORWARD_ONLY
  java.sql.ResultSet/CONCUR_READ_ONLY)]
(.setFetchSize stmt Integer/MIN_VALUE)
 ...

With this change, everything works as expected.

Details about why this works:

http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-implementation-notes.html
(scroll down to the section on ResultSet)

(Note, that this is a MySQL-only solution, other JDBC drivers may
require different tricks.)

P.s. I still don't understand though why the 'calls' argument to the
store-calls function is not a held reference to the head of the lazy
seq...

-- 
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 pass lazy seq to function for processing without keeping the head?

2010-10-27 Thread Chris Maier
On Wed, Oct 27, 2010 at 10:18 AM, rb ruzsa.bal...@gmail.com wrote:
 P.s. I still don't understand though why the 'calls' argument to the
 store-calls function is not a held reference to the head of the lazy
 seq...

I think (and someone please correct me if I'm wrong) that the head of
'calls' isn't being retained because you recur on (rest calls),
replacing your hold on the head with the next item downstream.  Now
nobody's holding on to the head, so it gets GC'd.  Keep recurring, and
you just move down the sequence, always dropping what you were holding
onto, thus allowing it all to be GC'd.

Chris

-- 
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: creating a function from a sexp

2010-10-27 Thread Sunil S Nandihalli
Hi Nicolas,
 Thanks for you response.
 This is an experimental work. Knowing that there was clojuratica to link to
mathematica .. I was hoping that we can generate the code to solve PDE ..
This is an experimental thing .. But been having a lot of trouble in getting
the basic stuff setup .. being able to do what I described above would be
crucial to achieve this.
 and between .. I didn't find any other examples of the usage of env and
form apart from their presence in the clojure/core.clj. It would be nice to
have some description of the usage of these things.
Thanks again,
Sunil.

On Wed, Oct 27, 2010 at 7:17 PM, nicolas.o...@gmail.com 
nicolas.o...@gmail.com wrote:

 You need to use both eval and a macro to get then environment.
 I think env contains the lexical environment in any macro call now.
 (I don't know in each form though).
 So you need to walk the term, looking for free variables, close under
 free variables by creating a function and then call eval.

 That's probably quite some work to write.

 Altogether, it looks like at least a step too far. (Especially some
 kind of problem may arise: what of (+  x y ((fn [z] z) 3))?)
 But I know sometimes it is necessary to go a few steps further than we
 should.

 What is the use case?

 Best,

 Nicolas.

 --
 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.comclojure%2bunsubscr...@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: creating a function from a sexp

2010-10-27 Thread Sunil S Nandihalli
actually i am able to find a few examples ... from a google group thread...
http://groups.google.com/group/clojure/browse_thread/thread/d710c290b67951a3/b827d46389110f26?lnk=gstq=clojure+macro+%26env#b827d46389110f26

http://groups.google.com/group/clojure/browse_thread/thread/d710c290b67951a3/b827d46389110f26?lnk=gstq=clojure+macro+%26env#b827d46389110f26just
thought of sharing it again in this context..
Sunil
On Wed, Oct 27, 2010 at 8:08 PM, Sunil S Nandihalli 
sunil.nandiha...@gmail.com wrote:

 Hi Nicolas,
  Thanks for you response.
  This is

an experimental work. Knowing that there was clojuratica to link to
 mathematica .. I was hoping that we can generate the code to solve PDE ..
 This is an experimental thing .. But been having a lot of trouble in getting
 the basic stuff setup .. being able to do what I described above would be
 crucial to achieve this.
  and between .. I didn't find any other examples of the usage of env and
 form apart from their presence in the clojure/core.clj. It would be nice to
 have some description of the usage of these things.
 Thanks again,
  Sunil.


 On Wed, Oct 27, 2010 at 7:17 PM, nicolas.o...@gmail.com 
 nicolas.o...@gmail.com wrote:

 You need to use both eval and a macro to get then environment.
 I think env contains the lexical environment in any macro call now.
 (I don't know in each form though).
 So you need to walk the term, looking for free variables, close under
 free variables by creating a function and then call eval.

 That's probably quite some work to write.

 Altogether, it looks like at least a step too far. (Especially some
 kind of problem may arise: what of (+  x y ((fn [z] z) 3))?)
 But I know sometimes it is necessary to go a few steps further than we
 should.

 What is the use case?

 Best,

 Nicolas.

 --
 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.comclojure%2bunsubscr...@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: Images in autodoc?

2010-10-27 Thread Eric Schulte
Christopher Petrilli petri...@amber.org writes:

 Interestingly, the Python community does something like this.  Usually
 there's a very brief explanation of the function/class, a blank line,
 then more, and many tools take this into account.  Seems like it might
 be a good way to split it up.


Similarly, in Emacs (elisp) documentation the first line (i.e. ending on
the first newline) is meant to be a single self-contained sentence
describing the function.  Many tools/functions use only this first line.

Another elisp convention that may be worth adopting is the use of
quotes, specifically `' to delimit variable and function names in
documentation.  These then look nice in plain text documentation, but
also allow the documentation engine to turn them into links in those
formats that support documentation links.  It's a nice low-overhead way
to add links to documentation without having to worry that every time
you use the word and in a sentence it will link to the and macro.

Best -- Eric


 Chris

 On Wed, Oct 27, 2010 at 1:09 PM, Ryan Waters ryan.or...@gmail.com wrote:
 What if documentation came in two (embedded?) forms, e.g.

 (doc ...)
 (doc-verbose ...)

 One could be a terse version of the documentation using docstrings
 (doc) and the other could have the bells, whistles, etc. to be shipped
 with the code in an as yet undetermined manner (as posited by this
 post  ; )

 - Ryan


 On Tue, Oct 26, 2010 at 12:08 PM, Tom Faulhaber tomfaulha...@gmail.com 
 wrote:
 Nah, changing the autodoc generation is easy (though we need to figure
 out where images go on the input and output sides and move them
 around, but that shouldn't be too much of a problem).

 The bigger problem is figuring out what to tell folks who type (doc
 foo) at the REPL and get a bunch of gobbledegook back. That's the
 thing that's been making me look for a better format than markdown.
 (Autodoc already does markdown translation for supporting
 documentation).

 Tom

 On Oct 26, 9:25 am, Andrew Gwozdziewycz apg...@gmail.com wrote:
 On Tue, Oct 26, 2010 at 12:21 PM, Eric Schulte schulte.e...@gmail.com 
 wrote:
  Chris christopher.ma...@gmail.com writes:

  On Oct 26, 9:54 am, Andrew Gwozdziewycz apg...@gmail.com wrote:
  I like that idea, especially if it could be extended to reference 
  other code:

  Agreed.  So now that's links to images, web pages, Clojure vars...
  anything else?

  LaTeX equations.  Which are increasingly easy to render in HTML
  (e.g.http://www.mathjax.org/).

 I guess the problem is actually making a patch to autodoc to do this all :)

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

 --http://www.apgwoz.com

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




 -- 
 | Chris Petrilli
 | petri...@amber.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: challenge with vectors

2010-10-27 Thread Glen Rubin
awesome dude!!!  Thanks for the book recommendation...I'll take a look
at those when I can.  Right now I am just eager to get my code
working ;)

On Oct 27, 1:18 pm, Aravindh Johendran ajohend...@gmail.com wrote:
 On Oct 27, 8:24 am, Glen Rubin rubing...@gmail.com wrote:

  wow, i think you just went way over my head.  First off a very naive
  question: I thought all clojure programming was functional, as long as
  you are not using refs, agents, or other mutable values etc...??

 You are mostly right. And there are varying degrees of functional
 programming and various associated styles, meaning you can use
 functions to do a lot of things that you didn't think was possible.
 Functional programming is very rich and deep in paradigms and they
 take time to understand and master.

 What people refer to as idiomatic clojure, I think, is a style reliant
 on laziness and higher order functions. It makes for clean and
 succinct code. But there is a lot more to functional programming than
 idiomatic clojure.

 The example I provided is in what's called the Continuation Passing
 Style. Functions are created on the fly to hold values. It is very
 thought provoking. It is also very basic, meaning it uses nothing more
 than the simplest lisp primitives.

 I highly recommend the books Little Schemer and Seasoned Schemer. They
 are fun and a LOT of light bulbs went on in my head. Once you are done
 with those books, terms like Y Combinator, continuations, continuation
 passing style (CPS), etc will not intimidate you. You'll gain an
 appreciation for the core tenets of functional programming.

-- 
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: Detecting More than one matching method

2010-10-27 Thread ataggart
If you (set! *warn-on-reflection* true) you'll see that the first uses
reflection while the second doesn't.  This is (imo) a bug in the
method resolution behavior, namely that the code path for looking up
compiled calls is different from reflected calls.

I submitted a patch to fix both this divergence and to allow for more
correct lookup behavior when it comes to primitive args:
https://www.assembla.com/spaces/clojure/tickets/445

Note that with the patch applied both scenarios result in a More than
one matching method found exception, which is (imo) the correct
behavior.

Feel free to bug Stu, et al., to get the patch applied.  ;)


On Oct 26, 7:44 am, Maks Romih mak...@gmail.com wrote:
 Hi!

 I stumbled on a difference of behavior in using a variable vs. let
 binding. It may even be a bug in Clojure.

 Using Java 1.6 and Clojure 1.1 or 1.2, if you execute the following
 code

 code
 (import
  'javax.xml.crypto.dsig.XMLSignatureFactory
  'javax.xml.crypto.dsig.Transform)

 (def fac (XMLSignatureFactory/getInstance DOM))

 (let [tf (. fac newTransform Transform/ENVELOPED nil)]
   tf)

 (let [fac (XMLSignatureFactory/getInstance DOM)
       tf (. fac newTransform Transform/ENVELOPED nil)]
   tf)
 /code

 the first let works OK while the second one breaks with stack trace
 and the error More than one matching method found: newTransform.
 There are really two methods with this name and the second parameter
 nil does not differentiate them enough, but I'd like to know why the
 first call, with the fac as a variable, succeeds. Which method of the
 two does it call?

 Maks.

-- 
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 1.3.0-alpha2 deployed to build.clojure.org

2010-10-27 Thread Btsai
Thanks, that's great info to have :)  Although I have to confess that
I'm still doing only small exploratory projects, so I haven't gotten
my feet wet with build systems like maven or lein yet.

On Oct 27, 7:21 am, Stuart Sierra the.stuart.sie...@gmail.com wrote:
 Yes, to get one big JAR containing all of clojure-contrib, you can
 depend on:

   groupId: org.clojure.contrib
   artifactId: standalone
   version: 1.3.0-alpha2

   Or in Leiningen: [org.clojure.contrib/standalone 1.3.0-alpha2]

 To get lots of little JARs for each of the contrib libraries, you can
 depend on:

   groupId: org.clojure.contrib
   artifactId: complete
   version: 1.3.0-alpha2

   Or in Leiningen: [org.clojure.contrib/complete 1.3.0-alpha2]

 To get just a single library, check out the list 
 athttp://build.clojure.org/releases/org/clojure/contrib/
 and depend on:

   groupId: org.clojure.contrib
   artifactId: NAME-OF-THE-LIBRARY
   version: 1.3.0-alpha2

   Or in Leiningen: [org.clojure.contrib/NAME-OF-THE-LIBRARY 1.3.0-
 alpha2]

 -S

 On Oct 26, 10:37 pm, Btsai benny.t...@gmail.com wrote:







  Is there still a complete jar somewhere that has all the modules?  If
  so, I can't seem to find it.  Or is that a thing of the past now?

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


Karras update problem

2010-10-27 Thread Victor Marzo
I'm trying to update a document that has an user list inside:

test.db (def uu (fetch-one users (where (eq :name victor
#'test.db/uu
test.db uu
{:password 1234, :name victor, :_id #ObjectId
4cbda9037fc2dffea9affbd7}
test.db (def pp (insert projects {:name test :users [uu]}))
#'test.db/pp
test.db pp
{:_id #ObjectId 4cc83eed9c5bdfb15517ed18, :users ({:_id #ObjectId
4cbda9037fc2dffea9affbd7, :name victor, :password 1234}), :name
test}
test.db (fetch-one projects (where (in :users [uu])))
{:users ({:_id #ObjectId 4cbda9037fc2dffea9affbd7, :name
victor, :password 1234}), :name asdfsdaf, :_id #ObjectId
4cc83c019c5bdfb15417ed18}   until this all works ok
test.db (update projects (where (eq :name test)) (merge pp {:name
test2}))
#WriteResult { err :  null  , updatedExisting : true , n : 1 ,
ok : 1.0}
test.db (fetch-one projects (where (in :users [uu])))
nil   ?
test.db (fetch-all projects)
({:name test2, :users ({:password 1234, :name victor, :_id
#ObjectId 4cbda9037fc2dffea9affbd7}), :_id #ObjectId
4cc840c19c5bdfb15917ed18})  it seems to be ok. I don't know why
the previous query fails.

I don't know what I'm doing wrong.

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


dynamic namespace generation using clj-record

2010-10-27 Thread takashi
Hello Jimm

I've been testing the clojure library clj-record and it is very
usefull. But I have a question, I'm a 'noob' on clojure language and
I'm wondering if it is possible to write a macro or something to get
namespaces generated for every table in my database, for example I
inicialize the model of one table 'keyword' in a keyword.clj file:

(ns interp.keyword
  (:use interp.conn) ;for db connection
  (:require clj-record.boot))
(clj-record.core/init-model
:table-name keyword)

I already try to use create-ns and with-ns to define a namespace but
din't work. Something like:

(with-ns (create-ns 'interp.keyword)
(:require clj-record.boot)
(:use interp.conn)
(clj-record.core/init-model
:table-name keyword)
)

Any advices? thank you in advance!

Regards!

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


Installing Clojure CLR

2010-10-27 Thread Sean Devlin
So, I just started running w/ Clojrue CLR.  I'm trying to get 1.2 up
and running.  I followed the instructions here:

http://github.com/richhickey/clojure-clr/wiki/Getting-started-binary-distribution

And got an error report.  Doesn't seem like a show stopper, but I can
post it later.  Are there instructions somewhere on how to start a
REPL?

Sean

-- 
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 pass lazy seq to function for processing without keeping the head?

2010-10-27 Thread rb


On Oct 27, 4:36 pm, Chris Maier christopher.ma...@gmail.com wrote:
 On Wed, Oct 27, 2010 at 10:18 AM, rb ruzsa.bal...@gmail.com wrote:
  P.s. I still don't understand though why the 'calls' argument to the
  store-calls function is not a held reference to the head of the lazy
  seq...

 I think (and someone please correct me if I'm wrong) that the head of
 'calls' isn't being retained because you recur on (rest calls),
 replacing your hold on the head with the next item downstream.  Now
 nobody's holding on to the head, so it gets GC'd.  Keep recurring, and
 you just move down the sequence, always dropping what you were holding
 onto, thus allowing it all to be GC'd.

 Chris

Yes, this is quite clear in the case of the loop construct:

(loop [calls calls
 conn nil
 stmt nil
 year nil
 month nil]
(if-let [c (first calls)]
...
(recur (rest calls) conn stmt year month

The 'calls' variable bound in the loop is clearly not retained.

What bothers me is the function argument:

(defn store-calls
  [source calls]
...

Here the lazy seq coming in as the second arg is bound to a local
variable named 'calls'. I would think this counts as retainment of the
head of the lazy seq (for the lifetime of the function), but it
apparently doesn't.

-- 
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.3 Alpha 2

2010-10-27 Thread ka
Hi,

Please explain this!

 code path for using vars is now *much* faster for the common case, and you 
 must explicitly ask for :dynamic bindability

-- 
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 pass lazy seq to function for processing without keeping the head?

2010-10-27 Thread Matt Fowles
rb~

I believe that local variables are nulled after their last usage to prevent
exactly this behavior.  In fact, you can find code like:

Object dummy(Object o, Object dummy) { return o; }

call_stuff(dummy(var, var = null));

In the Clojure source to accomplish this.

Matt

On Wed, Oct 27, 2010 at 4:12 PM, rb ruzsa.bal...@gmail.com wrote:



 On Oct 27, 4:36 pm, Chris Maier christopher.ma...@gmail.com wrote:
  On Wed, Oct 27, 2010 at 10:18 AM, rb ruzsa.bal...@gmail.com wrote:
   P.s. I still don't understand though why the 'calls' argument to the
   store-calls function is not a held reference to the head of the lazy
   seq...
 
  I think (and someone please correct me if I'm wrong) that the head of
  'calls' isn't being retained because you recur on (rest calls),
  replacing your hold on the head with the next item downstream.  Now
  nobody's holding on to the head, so it gets GC'd.  Keep recurring, and
  you just move down the sequence, always dropping what you were holding
  onto, thus allowing it all to be GC'd.
 
  Chris

 Yes, this is quite clear in the case of the loop construct:

 (loop [calls calls
 conn nil
 stmt nil
 year nil
 month nil]
(if-let [c (first calls)]
 ...
 (recur (rest calls) conn stmt year month

 The 'calls' variable bound in the loop is clearly not retained.

 What bothers me is the function argument:

 (defn store-calls
  [source calls]
 ...

 Here the lazy seq coming in as the second arg is bound to a local
 variable named 'calls'. I would think this counts as retainment of the
 head of the lazy seq (for the lifetime of the function), but it
 apparently doesn't.

 --
 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.comclojure%2bunsubscr...@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: Clojure 1.3 Alpha 2

2010-10-27 Thread Baishampayan Ghose
 Please explain this!

 code path for using vars is now *much* faster for the common case, and you 
 must explicitly ask for :dynamic bindability

Earlier vars were looked up each time they were accessed inside
functions because there was no way of telling if it was being
dynamically rebound or not. Now all vars are cached inside function
calls and are not looked up every time. To be able to dynamically
rebind vars, the metadata :dynamic needs to be present in which case
the vars will be looked up when they are rebound. For global
(non-dynamic) vars, there is a universal var counter which is
incremented each time a var root is altered and when that change is
detected inside functions, they lookup the vars again. Since the
function would use the cached var values happily if the global var
counter is unchanged, they are now way faster.

I hope that helps.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
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: Installing Clojure CLR

2010-10-27 Thread dmiller
Let me know on the error.

Re REPL: run Clojure.Main.exe to start.

-David

On Oct 27, 2:54 pm, Sean Devlin francoisdev...@gmail.com wrote:
 So, I just started running w/ Clojrue CLR.  I'm trying to get 1.2 up
 and running.  I followed the instructions here:

 http://github.com/richhickey/clojure-clr/wiki/Getting-started-binary-...

 And got an error report.  Doesn't seem like a show stopper, but I can
 post it later.  Are there instructions somewhere on how to start a
 REPL?

 Sean

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


Access to the issue tracker...

2010-10-27 Thread John Szakmeister
I'm not sure what the protocol is for this, but I'd like to attach a
patch to one of the issues in Assembla.  Unfortunately, it won't let
me.  Do I have to get added to the project in some way?  Or should I
just hang out until Jira comes online?

BTW, I did send in my CA.  Rich should hopefully have it in hand
already (I sent it in early last week).

Thanks!

-John

-- 
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 issue tracking is now on JIRA

2010-10-27 Thread Stuart Halloway
Apologies to all whose tickets have gone unloved in the last 48 hours. I have 
been busy moving the ticketing system itself.

The Old: http://www.assembla.com/spaces/clojure
The New: http://dev.clojure.org/jira/browse/CLJ

Completed so far:
* Moved tickets over.
* Turned off write access to Assembla to prevent inadvertent use.

Still in progress:
* Moving users over. We are using Crowd for SSO across the various tools in the 
chain. In the short run, contact me by email directly with your desired 
username if you are a CA signer and need in immediately.
* Creating commonly-used views.
* Picking some useful widgets for the dashboard.

Help wanted:
* Crowd guru to tell me how to enable better self-service, i.e. create your own 
account.
* Is there any way to make JIRA world-readable?
* Suggestions for useful tweaks to JIRA.

Broken and won't be fixed:
* Any text oddities in the import. Each historical ticket links back (via a 
comment) to the original Assembla ticket if you really need. Also, each 
attachment from Assembla is linked in the same auto-comment.

Feedback welcome.

Thanks,
Stu

Stuart Halloway
Clojure/core team at Relevance
http://clojure.com
http://thinkrelevance.com

-- 
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 issue tracking is now on JIRA

2010-10-27 Thread Baishampayan Ghose
 Apologies to all whose tickets have gone unloved in the last 48 hours. I have 
 been busy moving the ticketing system itself.

 The Old: http://www.assembla.com/spaces/clojure
 The New: http://dev.clojure.org/jira/browse/CLJ

How do I create an account?

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
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 issue tracking is now on JIRA

2010-10-27 Thread Stuart Halloway
I sure wish somebody would tell me! The only thing I have figured out how to do 
with Crowd is create accounts for others. Email me privately with your desired 
account name / email and I will do it.

Stu

 Apologies to all whose tickets have gone unloved in the last 48 hours. I 
 have been busy moving the ticketing system itself.
 
 The Old: http://www.assembla.com/spaces/clojure
 The New: http://dev.clojure.org/jira/browse/CLJ
 
 How do I create an account?
 
 Regards,
 BG
 
 -- 
 Baishampayan Ghose
 b.ghose at gmail.com
 
 -- 
 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: Karras update problem

2010-10-27 Thread Wilkes Joiner
You want use $elemMatch to test for items in an array:

http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-ValueinanArray

In karras that would be:

 (fetch-one projects (where (element-match :users uu)))

That doesn't explain why the first query passed. I can recreate it,
but I don't understand it. I'll look into it more closely later.

BTW, I don't check the clojure group too often.  I do receive emails
from the karras-dev group: http://groups.google.com/group/karras-dev

- Wilkes

On Oct 27, 10:13 am, Victor Marzo samsa...@gmail.com wrote:
 I'm trying to update a document that has an user list inside:

 test.db (def uu (fetch-one users (where (eq :name victor
 #'test.db/uu
 test.db uu
 {:password 1234, :name victor, :_id #ObjectId
 4cbda9037fc2dffea9affbd7}
 test.db (def pp (insert projects {:name test :users [uu]}))
 #'test.db/pp
 test.db pp
 {:_id #ObjectId 4cc83eed9c5bdfb15517ed18, :users ({:_id #ObjectId
 4cbda9037fc2dffea9affbd7, :name victor, :password 1234}), :name
 test}
 test.db (fetch-one projects (where (in :users [uu])))
 {:users ({:_id #ObjectId 4cbda9037fc2dffea9affbd7, :name
 victor, :password 1234}), :name asdfsdaf, :_id #ObjectId
 4cc83c019c5bdfb15417ed18}   until this all works ok
 test.db (update projects (where (eq :name test)) (merge pp {:name
 test2}))
 #WriteResult { err :  null  , updatedExisting : true , n : 1 ,
 ok : 1.0}
 test.db (fetch-one projects (where (in :users [uu])))
 nil   ?
 test.db (fetch-all projects)
 ({:name test2, :users ({:password 1234, :name victor, :_id
 #ObjectId 4cbda9037fc2dffea9affbd7}), :_id #ObjectId
 4cc840c19c5bdfb15917ed18})  it seems to be ok. I don't know why
 the previous query fails.

 I don't know what I'm doing wrong.

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


Fastest way to generate comma-separated list

2010-10-27 Thread andrei
Hi all,

I work with a database and need a function, that will convert Clojure
sequence to a string with a comma-separated elements. E.g.,

  (comma-separated (list 1 2 3 4 5))  ==  1, 2, 3, 4, 5

It must work with any data type - ints, strings, other lists, etc.
E.g. for a list of strings it must generate

  (comma-separated (list 1 2 3 4 5))  ==  \1\, \2\,
\3\, \4\, \5\

I tried `cl-format` function from clojure.contrib.pprint package:

  (cl-format nil ~{~S~^, ~} lst)

It works fine, but is too slow. Next, I tried such function:

  (defn comma-separated [s]
  (if (= (type (first s)) String)
 (chop (chop (chop (str \ (apply str (interleave s
(repeatedly (fn [] \, \)))
 (chop (chop (apply str (interleave s (repeatedly (fn [] ,
)

This one works much faster (~20 times), but it is ugly and still
doesn't cover all cases.

So, what is the fastest way to generate such list?

-- 
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: Fastest way to generate comma-separated list

2010-10-27 Thread Christopher Petrilli
I didn't do any timing, but, I would say the idiomatic way:

(apply str (interpose ,  some-vector))

Chris

On Wed, Oct 27, 2010 at 8:18 PM, andrei andrei.zhabin...@gmail.com wrote:
 Hi all,

 I work with a database and need a function, that will convert Clojure
 sequence to a string with a comma-separated elements. E.g.,

  (comma-separated (list 1 2 3 4 5))  ==  1, 2, 3, 4, 5

 It must work with any data type - ints, strings, other lists, etc.
 E.g. for a list of strings it must generate

  (comma-separated (list 1 2 3 4 5))  ==  \1\, \2\,
 \3\, \4\, \5\

 I tried `cl-format` function from clojure.contrib.pprint package:

  (cl-format nil ~{~S~^, ~} lst)

 It works fine, but is too slow. Next, I tried such function:

  (defn comma-separated [s]
      (if (= (type (first s)) String)
         (chop (chop (chop (str \ (apply str (interleave s
 (repeatedly (fn [] \, \)))
         (chop (chop (apply str (interleave s (repeatedly (fn [] ,
 )

 This one works much faster (~20 times), but it is ugly and still
 doesn't cover all cases.

 So, what is the fastest way to generate such list?

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




-- 
| Chris Petrilli
| petri...@amber.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 issue tracking is now on JIRA

2010-10-27 Thread Stuart Halloway
Thanks to Contegix tech support and some RTFM on my part, self sign-on is now 
enabled for JIRA at http://dev.clojure.org/jira/browse/CLJ. Have at it.

Stu

 I sure wish somebody would tell me! The only thing I have figured out how to 
 do with Crowd is create accounts for others. Email me privately with your 
 desired account name / email and I will do it.
 
 Stu
 
 Apologies to all whose tickets have gone unloved in the last 48 hours. I 
 have been busy moving the ticketing system itself.
 
 The Old: http://www.assembla.com/spaces/clojure
 The New: http://dev.clojure.org/jira/browse/CLJ
 
 How do I create an account?
 
 Regards,
 BG
 
 -- 
 Baishampayan Ghose
 b.ghose at gmail.com
 
 -- 
 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: Odds for tail calls in JVM

2010-10-27 Thread Tim Daly

 I use emacs to write Java code for work.
I even use fundamental mode because I don't want emacs
changing my buffer while I work.

I don't find that IDEs add any value to programming
and they often get in my way.

I guess I must be part amish :-)

Tim Daly

On 10/27/2010 12:10 PM, MarkH wrote:


On Oct 26, 11:05 pm, Tom Marbletmar...@gmail.com  wrote:


On the bright side the community has really leveraged and added
cool features to OpenJDK [2] [3].  Even MacOS hackers have indicated
interest in OpenJDK [4] [5] [6]. One viewpoint is that
desktop Java is dead, it really only impacts a couple IDE's anyway
and developers can use emacs.

Developers will not be using Emacs to write Java code.  You might as
well ask them to trade their car in for a horse and buggy.



--
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: Fastest way to generate comma-separated list

2010-10-27 Thread Stuart Campbell
On 28 October 2010 13:22, andrei andrei.zhabin...@gmail.com wrote:


 I was seeking `interpose` function, thanks. But it still doesn't work
 for strings - they are not wrapped by \\. E.g.

 (apply str (interpose ,  (list 1 2 3 4 5)))  == 1, 2, 3, 4, 5

 and

 (apply str (interpose ,  (list 1 2 3 4 5))) == 1, 2, 3,
 4, 5

 The problem is that applying `str` to strings just concatenates them
 and doesn't include inverted commas. It's the same issue that applies
 to `print` and `pr` functions - first just prints, and the second
 prints in the form that can be read by reader. Is there an equivalent
 of `pr` that returns string as is?

 Of course, I can make such trick:

 (defn pr-to-str [o]
  (let [sw (StringWriter.)]
(binding [*out* sw]
  (pr o))
(str sw)))


 But aren't there such built-in function?


Are you looking for pr-str?

user (pr-str foo)
\foo\

Regards,
Stuart

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

for rich: caffeine?

2010-10-27 Thread Steven Deobald
Rich,

I meant to corner you for a minute after your second talk, but you were
pretty thoroughly cornered for all of clojure conj.

Just curious:  Do you subscribe to Linda Rising's suggestion that we could
replace our caffeine intake with naps*?  Or do you not find it as damaging
as booze?

-steven

* I think this is the presentation:
http://www.infoq.com/presentations/agility-personal-level-possibilities

-- 
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: Fastest way to generate comma-separated list

2010-10-27 Thread Avram

Does this help?

user (use 'clojure.string)
nil
user (join , (range 10))
0,1,2,3,4,5,6,7,8,9

-Avram


On Oct 28, 4:22 am, andrei andrei.zhabin...@gmail.com wrote:
 I was seeking `interpose` function, thanks. But it still doesn't work
 for strings - they are not wrapped by \\. E.g.

 (apply str (interpose ,  (list 1 2 3 4 5)))  == 1, 2, 3, 4, 5

 and

 (apply str (interpose ,  (list 1 2 3 4 5))) == 1, 2, 3,
 4, 5

 The problem is that applying `str` to strings just concatenates them
 and doesn't include inverted commas. It's the same issue that applies
 to `print` and `pr` functions - first just prints, and the second
 prints in the form that can be read by reader. Is there an equivalent
 of `pr` that returns string as is?

 Of course, I can make such trick:

 (defn pr-to-str [o]
   (let [sw (StringWriter.)]
     (binding [*out* sw]
       (pr o))
     (str sw)))

 But aren't there such built-in function?

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