Re: special handling of :type in meta data

2009-04-27 Thread Konrad Hinsen
On 27.04.2009, at 00:33, David Chamberlin wrote:

 I can get round this by not using a structure map for the metadata,
 but since I'm going to be creating container loads of these structures
 I understand that I need to be using struct-maps for efficiency.

 Is there a reason why this should not work?

Here is why it does not work. Any attempt to print a value causes a  
call to clojure.core/print-method. This is a multimethod that  
dispatches on clojure.core/type, i.e. by the :type on the metadata  
or, if there is no metadata or no :type tag, on class. If there is  
a :type tag but it has no implementation of print-method, a :default  
implementation removes the :type tag and tries again. It's removing  
the type tag that fails in your case.

On March 27 I sent a message to this group that contains a patch for  
clojure.core that fixes this problem, and other of a similar kind.  
The subject is PATCH: printing a ref with type metadata. I can't  
find the message in Google's archive, so I wonder if it got lost. The  
patch is attached again to this message.

As for efficiency, I doubt that struct maps make that much of a  
difference, but I didn't do any timings. Note that in your example,  
you create the metadata map once and assign it to m. The map is thus  
created only once, no matter to how many values you attach it later.  
That's how I handle metadata maps as well. The only potential  
difference in execution time thus comes from looking up :type.  
Compared to the rest of the work done in multimethod dispatching, I  
can't imagine that key lookup is that much more efficient for struct  
maps that it makes a difference overall.

Konrad.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



print-method.patch
Description: Binary data


Re: Unloading a namespace?

2009-04-27 Thread atreyu

http://clojure.org/api#remove-ns ??
i never used it but it seems to do it ;-)

On 27 abr, 06:08, Mark Derricutt m...@talios.com wrote:
 Is it possible to unload/remove a namespace at runtime at all?

 Mark

 ...and then Buffy staked Edward.  The End.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
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 slime-edit-definition to work with Clojure

2009-04-27 Thread Baishampayan Ghose

Phil,
 It works for me. Are you trying to look up a built-in clojure function
 or one from your own application? How did you install SLIME and
 swank-clojure etc?

It doesn't work for either. When I try looking up a clojure-contrib
function, I get let*: Search failed:   clojure/contrib/str_utils.clj$

In case of a function that I wrote somewhere in a file and loaded in
SLIME, I get an exception - java.lang.StringIndexOutOfBoundsException:
String index out of range: -1 (NO_SOURCE_FILE:0) (in *Messages* I get
funcall: Synchronous Lisp Evaluation aborted)


 If you installed by hand, you could try using M-x clojure-install from
 a recent copy of clojure-mode.el. This should download and configure
 all the necessary things to hook up Emacs and Clojure via SLIME.

I have installed it by hand and I have installed swank-clojure as well
as clojure-mode. Everything else works just fine, except this.

I tried re-installing Clojure using M-x clojure-install and I get the
same result with that too.

 If it's still not working, try pasting the contents of your *Messages*
 buffer to the list.

In case of my own function: funcall: Synchronous Lisp Evaluation aborted
In case of clojure-contrib.str-utils.str-join: let*: Search failed: 
clojure/contrib/str_utils.clj$

Any help will be highly appreciated.

PS - Relevant sections from my ~/.emacs

;;;

(require 'slime)
(slime-setup '(slime-fancy slime-banner slime-mdot-fu))

(defvar slime-net-coding-system
  (find-if 'slime-find-coding-system
   '(utf-8-unix iso-latin-1-unix iso-8859-1-unix binary)))

;;; Clojure specific
(defvar clj-root (concat (expand-file-name ~) /clojure/))
(setq load-path (append
 (list (concat clj-root clojure-mode)
   (concat clj-root swank-clojure))
 load-path))

(setq swank-clojure-binary clojure)

(require 'swank-clojure-autoload)

(add-to-list 'slime-lisp-implementations
 '(sbcl (/usr/bin/sbcl))
 '(clojure (/home/ghoseb/bin/clojure) :init
swank-clojure-init))

(require 'clojure-mode)
(eval-after-load 'clojure-mode '(clojure-slime-config))

(autoload 'clojure-mode clojure-mode A major mode for Clojure t)
(add-to-list 'auto-mode-alist '(\\.clj$ . clojure-mode))

(defun lisp-enable-paredit-hook ()
  (paredit-mode 1))

(add-hook 'clojure-mode-hook 'lisp-enable-paredit-hook)

(defun sbcl ()
  Starts sbcl in Slime
  (interactive)
  (slime 'sbcl))

(defun clj ()
  Starts Clojure in Slime
  (interactive)
  (slime 'clojure))

;;;


Regards,
BG

-- 
Baishampayan Ghose b.gh...@ocricket.com
oCricket.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
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: special handling of :type in meta data

2009-04-27 Thread Meikel Brandmeyer

Hi Konrad,

Am 27.04.2009 um 08:44 schrieb Konrad Hinsen:


As for efficiency, I doubt that struct maps make that much of a
difference, but I didn't do any timings.


AFAIU, struct-maps are not an optimisation for efficiency of the
key lookup, but for the storage space of the keys. So timings
should probably read memstats.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: How to call function (or Java method) using string name?

2009-04-27 Thread Christophe Grand

fft1976 a écrit :

 On Apr 26, 9:21 am, Stuart Sierra the.stuart.sie...@gmail.com wrote:
   
  resolve will find the Var
 that is named by the symbol.  
 

 Can there be Vars without names? Can I have a vector of Vars?
   

You can, see with-local-vars for example.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: special handling of :type in meta data

2009-04-27 Thread Konrad Hinsen

On 27.04.2009, at 09:42, Meikel Brandmeyer wrote:

 AFAIU, struct-maps are not an optimisation for efficiency of the
 key lookup, but for the storage space of the keys. So timings
 should probably read memstats.

If memory is the issue, then creating a single instance of the  
metadata map for all values of a type should be sufficient.

As for timing, key lookup is faster for struct maps than for standard  
maps if the number of keys defined in the struct is much smaller than  
the total number of keys in the map. This is probably not the case  
for most real-life metadata maps. Key lookup can be improved even  
more using accessor functions, but that would imply relying on the  
metadata being a struct-map for a given struct, which doesn't look  
like a great idea.

Konrad.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Unloading a namespace?

2009-04-27 Thread Mark Derricutt
Well that was a simple answer ;-)  That should help with using clojure in
OSGi, having a way to trigger an unload when a bundle dissapears should get
around the problem of coercing everything to use the same classloader.  I
sense some more hacking in the near future :)

On Mon, Apr 27, 2009 at 7:08 PM, atreyu atreyu_...@yahoo.es wrote:


 http://clojure.org/api#remove-ns ??
 i never used it but it seems to do 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
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
-~--~~~~--~~--~--~---



Oddity with clojure-contrib/sql

2009-04-27 Thread Mark Derricutt
Hey guys,

Just started looking at clojure-contrib's sql namespace, however, using the
following code:

(let [user_id (.toString (java.util.UUID/randomUUID))]
  (sql/with-connection db (sql/insert-records
:users
{:user_id user_id})))

and clojure-contrib-1.0-20090421.092453-8.jar seems to generate:

java.lang.Exception: transaction rolled back: Batch entry 0 INSERT INTO
users (user_id) VALUES (c3583933-cc55-4007-b857-b24441cfe409) was aborted.
 Call getNextException to see the cause.
at
clojure.contrib.sql.internal$transaction_STAR___4079.invoke(internal.clj:95)
 at clojure.contrib.sql$do_prepared__4108.doInvoke(sql.clj:87)
at clojure.lang.RestFn.applyTo(RestFn.java:144)

I see that theres no quotes around the value, even if I change the code to
use {:user_id testing} I get VALUES (testing).

Is there something I'm missing?




...and then Buffy staked Edward.  The End.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: 32-bit Unicode character literals

2009-04-27 Thread Christophe Grand

samppi a écrit :
 I see. Does this mean that, if I expect to handle 32-bit characters,
 then I need to consider changing my character-handling functions to
 accept sequences of vectors instead?

 Also, how does (seq \ud800\udc00) work? Does it split the character
 into two 16-bit characters? In the REPL, it seems to return (\? \?).
   

seq on a String returns a sequence of Java characters (16 bits values).

(defn codepoints-seq [s] ; returns a seq of ints
  (let [s (str s)
n (count s)
f (fn this [i]
(lazy-seq
  (when ( i n)
(cons (.codePointAt s i)
  (this (.offsetByCodePoints s i 1))]
(f 0)))

;; = (codepoint-seq \ud800\udc00a\ud800\udd00)
;; (65536 97 65792)

-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
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: 32-bit Unicode character literals

2009-04-27 Thread Stephen C. Gilardi


On Apr 27, 2009, at 10:07 AM, samppi wrote:


I see. Does this mean that, if I expect to handle 32-bit characters,
then I need to consider changing my character-handling functions to
accept sequences of vectors instead?


The blog post touches on this and searching around on Google and  
Wikipedia should turn up more info. Many APIs, especially in the  
Character class now have versions that accept and return int  
arguments (in addition to versions that accept and return char  
arguments) to support code points beyond 0x. int is wide enough to  
hold any individual Unicode character.


It may be convenient for you to work Strings rather than individual  
characters when possible.


Java strings (as of 1.5) are now UTF-16 encoded. This encoding allows  
(legal) Unicode code points in the range 0 to 0x to be encoded as  
a single Java character. To represent code points outside that range,  
UTF-16 uses a range of code points that are illegal for a single  
unicode character (0xD800–0xDFFF) to encode the code point a pair of  
16-bit values (Chars) called a surrogate pair. Using this encoding you  
can represent all strings made up of legal Unicode code points as Java  
strings.



Also, how does (seq \ud800\udc00) work? Does it split the character
into two 16-bit characters? In the REPL, it seems to return (\? \?).


seq doesn't know about the UTF16 encoding. It returns a sequence of  
every Char even if it is part of a surrogate pair. It would be  
possible to write a seq implementation for strings that knows about  
UTF-16 and returns a sequence of Unicode code points represented as  
ints instead. Whether doing that is useful or not depends on what  
you're hoping to do with the characters.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: How to call function (or Java method) using string name?

2009-04-27 Thread Stuart Sierra

On Apr 27, 3:49 am, fft1976 fft1...@gmail.com wrote:
 Can there be Vars without names? Can I have a vector of Vars?

Vars always have names, but you can create temporary Vars using with-
local-vars.  If you want to create a vector of unnamed, mutable
objects, you probably want Refs or Atoms instead.

-Stuart Sierra
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: AppEngine in Atlanta this week

2009-04-27 Thread Robert Campbell

Is there any way you could record the presentation and post it on your site?


On Mon, Apr 27, 2009 at 1:36 PM, slc sari.conn...@gmail.com wrote:

 If you are interested in Google AppEngine and live in the Atlanta
 area ...
 
 Tuesday - Clojure

    * Who: John Hume
    * What: Clojure on Google AppEngine
    * When: Tuesday, April 28th at 7pm
    * Where:  Norcross Group — 135 Technology Parkway, Suite 200,
 Norcross, GA 30092.

 For more details see Atlanta Clojure User Group (atlclj.org) .
 
 Wednesday - Groovy

    * Who: Vincent Stoessel
    * What: Google AppEngine and Groovy
    * When: Wednesday April 29, 2009 - 6:30PM
    * Where: Matrix Resources, 115 Perimeter Center Place NE, Suite
 250, Atlanta, GA

 PLEASE SIGN UP on the gg-members mail list: gg-members-
 requ...@www.ajug.org
 

 Sari Connard


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



similar to find-first

2009-04-27 Thread Mark Volkmann

find-first in seq_utils returns the first item in a collection where
(pred item) returns logical true. I needed a function that returns the
result of (pred item) instead of item. This seems to do the trick.
Maybe this should be added to seq_utils.

(defn find-first-result [fn coll]
  (first (filter #(not (nil? %)) (map fn coll

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: The Path to 1.0

2009-04-27 Thread David Andrews

Rich, refer to the patch described by Stephen Gilardi at
http://groups.google.com/group/clojure/msg/2b7dd55d9f766125 (which
makes it possible to run Clojure under z/OS).

Based on Steve and Laurent PETIT's comments in that thread, I gather
that the UTF-8 vs platform-default issue has been around awhile.  Is
this something you want to address before 1.0?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



vimclojure help

2009-04-27 Thread jim

Meikel,

I'm having a heck of a time getting started with VimClojure and it's
probably all due to my lack of knowing vim. After a lot of poking, I
got the plugin to load and got syntax highlighting working. I also
have got some autocmd's in my .vimrc so that they're listed when I do
a :map. I got the nailgun server running. But I can't get gvim to
start a REPL in a buffer.

Could you point me to some docs or give a quick howto on getting that
going?

Thanks,
Jim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: similar to find-first

2009-04-27 Thread Laurent PETIT

Shouldn't this return nil ? :

1:4 user= (find-first-result false? [true])
false

Maybe this definition of find-first-result may fill the gap:

(defn find-first-result [pred coll]
(find-first identity (map pred coll)))
=
1:22 user= (find-first-result false? [true])
nil
1:23 user= (find-first-result #(when (= % 10) (* % %)) (range 20))
100
1:24 user=  (find-first-result #(when (= % 10) (* % %)) (range 9))
nil


HTH,

-- 
Laurent

2009/4/27 Mark Volkmann r.mark.volkm...@gmail.com:

 find-first in seq_utils returns the first item in a collection where
 (pred item) returns logical true. I needed a function that returns the
 result of (pred item) instead of item. This seems to do the trick.
 Maybe this should be added to seq_utils.

 (defn find-first-result [fn coll]
  (first (filter #(not (nil? %)) (map fn coll

 --
 R. Mark Volkmann
 Object Computing, Inc.

 




-- 
Cordialement,

Laurent PETIT

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Oddity with clojure-contrib/sql

2009-04-27 Thread Stephen C. Gilardi


On Apr 27, 2009, at 9:57 AM, Stephen C. Gilardi wrote:

As a result of your report, I'm working on adding better error  
reporting on BatchUpdateException and SQLException to  
clojure.contrib.sql.


I've added this in SVN Revision 720 of clojure-contrib. Comments  
welcome.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: similar to find-first

2009-04-27 Thread Christophe Grand

find-first-result is already in core: some

Mark Volkmann a écrit :
 find-first in seq_utils returns the first item in a collection where
 (pred item) returns logical true. I needed a function that returns the
 result of (pred item) instead of item. This seems to do the trick.
 Maybe this should be added to seq_utils.

 (defn find-first-result [fn coll]
   (first (filter #(not (nil? %)) (map fn coll

   


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
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
-~--~~~~--~~--~--~---



typo in clojure.org sequences page

2009-04-27 Thread Laurent PETIT

The sequence page ( http://clojure.org/sequences )  reads :

(rest coll)
Returns a seq of the items after the first. Calls seq on its argument.
If there are no more items, returns nil.

It should state , ... returns ().

HTH,

-- 
Laurent

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: similar to find-first

2009-04-27 Thread Laurent PETIT

2009/4/27 Christophe Grand christo...@cgrand.net:

 find-first-result is already in core: some

OH! yes :-$


 Mark Volkmann a écrit :
 find-first in seq_utils returns the first item in a collection where
 (pred item) returns logical true. I needed a function that returns the
 result of (pred item) instead of item. This seems to do the trick.
 Maybe this should be added to seq_utils.

 (defn find-first-result [fn coll]
   (first (filter #(not (nil? %)) (map fn coll




 --
 Professional: http://cgrand.net/ (fr)
 On Clojure: http://clj-me.blogspot.com/ (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
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: AppEngine in Atlanta this week

2009-04-27 Thread Sari Connard
We will attempt to record the AppEngine Clojure talk.
If it turns out ok, it will be posted on youtube and I will link to it from
atlclj.org

On Mon, Apr 27, 2009 at 10:15 AM, Robert Campbell rrc...@gmail.com wrote:


 Is there any way you could record the presentation and post it on your
 site?


 On Mon, Apr 27, 2009 at 1:36 PM, slc sari.conn...@gmail.com wrote:
 
  If you are interested in Google AppEngine and live in the Atlanta
  area ...
  
  Tuesday - Clojure
 
 * Who: John Hume
 * What: Clojure on Google AppEngine
 * When: Tuesday, April 28th at 7pm
 * Where:  Norcross Group — 135 Technology Parkway, Suite 200,
  Norcross, GA 30092.
 
  For more details see Atlanta Clojure User Group (atlclj.org) .
  
  Wednesday - Groovy
 
 * Who: Vincent Stoessel
 * What: Google AppEngine and Groovy
 * When: Wednesday April 29, 2009 - 6:30PM
 * Where: Matrix Resources, 115 Perimeter Center Place NE, Suite
  250, Atlanta, GA
 
  PLEASE SIGN UP on the gg-members mail list: gg-members-
  requ...@www.ajug.org
  
 
  Sari Connard
 
 
  
 

 



-- 
Sari Connard
http://www.linkedin.com/in/sariconnard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: vimclojure help

2009-04-27 Thread Meikel Brandmeyer

Hi Jim,

Am 27.04.2009 um 18:08 schrieb jim:


I'm having a heck of a time getting started with VimClojure and it's
probably all due to my lack of knowing vim. After a lot of poking, I
got the plugin to load and got syntax highlighting working. I also
have got some autocmd's in my .vimrc so that they're listed when I do
a :map. I got the nailgun server running. But I can't get gvim to
start a REPL in a buffer.

Could you point me to some docs or give a quick howto on getting that
going?


Please note, that people reported problems with Vims  7.2.
So please make sure that you have a reasonable up-to-date vim.

As for the documentation:
For the installation there is information in the README.txt and
a screencast on kotka.blip.tv, which walks you through the steps.

For the usage there is information in the doc/clojure.txt. When you
copied it to the ~/.vim/doc directory, do a :helptags ~/.vim/doc.
Then you get the online help via :help vimclojure.

Make sure you have let clj_want_gorilla = 1 in your .vimrc.

The keymappings use the LocalLeader feature of Vim. More
info for this can be obtained by :help mapleader. Important
to know: the default is \. So LocalLeaderef in the docs means
actually \ef for the default settings. Starting the Repl would be \sr.

Also important: If your file contains a ns or in-ns clause, you have
to make sure, that the namespace can be loaded correctly! VC
relies on Clojure for its introspection facilities. So it needs to load
the namespace of the file to work correctly. If you often edit files
outside the classpath, files having side-effect when being loaded
or files with broken syntax you might want to disable the dynamic
features with let clj_want_gorilla = 0.

Hope this gets you started. If not, I need some more specific
background on the actual problems/errors.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: vimclojure help

2009-04-27 Thread jim

Thanks for the response.

Here's specifically what's happening:

I have vim 7.2, according to the :version command in gvim

I start the nailgun server with:
java -cp /home/jim/clojure/clojure.jar:/home/jim/clojure/
clojure.contrib/clojure-contrib.jar:/home/jim/clojure/vimclojure.jar
com.martiansoftware.nailgun.NGServer 127.0.0.1

and I get the response:

NGServer started on 127.0.0.1, port 2113.


I start gvim and give the command :e temp.clj. temp.clj is an empty
file.

The :map command give this for the sr shortcut:
n \sr PlugClojureStartRepl

In normal mode, when I type \sr, I get a beep when I type the 'r'.

In the bash shell, when I execute ng ng-stop, the ng server
shutsdown.

So what am I missing?

Thanks,
Jim

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
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 call function (or Java method) using string name?

2009-04-27 Thread Richard Lyman
There's a section on the wiki with almost the exact same title:

http://en.wikibooks.org/wiki/Clojure_Programming/Examples#Invoking_Java_method_through_method_name_as_a_String

If I'm understanding the question correctly that should do what you're
wanting to do.

-Rich


On Sun, Apr 26, 2009 at 11:50 AM, timc timgcl...@gmail.com wrote:


 Thanks Stuart.

 I have figured out another way, which is much more general (and uses
 the lowest level of how Clojure works).

 (defn evalStr [s] (clojure.lang.Compiler/eval (clojure.lang.RT/
 readString s)))

 will (attempt to) execute any valid form (i.e. the string that is the
 source of the form).

 Thus: (evalStr (+ 1 2)) -- 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
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: vimclojure help

2009-04-27 Thread jim

I forgot to say that I have:

let clj_want_gorilla = 1

in my .vimrc

On Apr 27, 12:08 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi Jim,

 Am 27.04.2009 um 18:08 schrieb jim:

  I'm having a heck of a time getting started with VimClojure and it's
  probably all due to my lack of knowing vim. After a lot of poking, I
  got the plugin to load and got syntax highlighting working. I also
  have got some autocmd's in my .vimrc so that they're listed when I do
  a :map. I got the nailgun server running. But I can't get gvim to
  start a REPL in a buffer.

  Could you point me to some docs or give a quick howto on getting that
  going?

 Please note, that people reported problems with Vims  7.2.
 So please make sure that you have a reasonable up-to-date vim.

 As for the documentation:
 For the installation there is information in the README.txt and
 a screencast on kotka.blip.tv, which walks you through the steps.

 For the usage there is information in the doc/clojure.txt. When you
 copied it to the ~/.vim/doc directory, do a :helptags ~/.vim/doc.
 Then you get the online help via :help vimclojure.

 Make sure you have let clj_want_gorilla = 1 in your .vimrc.

 The keymappings use the LocalLeader feature of Vim. More
 info for this can be obtained by :help mapleader. Important
 to know: the default is \. So LocalLeaderef in the docs means
 actually \ef for the default settings. Starting the Repl would be \sr.

 Also important: If your file contains a ns or in-ns clause, you have
 to make sure, that the namespace can be loaded correctly! VC
 relies on Clojure for its introspection facilities. So it needs to load
 the namespace of the file to work correctly. If you often edit files
 outside the classpath, files having side-effect when being loaded
 or files with broken syntax you might want to disable the dynamic
 features with let clj_want_gorilla = 0.

 Hope this gets you started. If not, I need some more specific
 background on the actual problems/errors.

 Sincerely
 Meikel

  smime.p7s
 5KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: vimclojure help

2009-04-27 Thread jim

I forgot to say that I have:

let clj_want_gorilla = 1
let vimclojure#NailgunClient = /home/jim/clojure/ng

in my .vimrc file.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Abstract data types in functional languages

2009-04-27 Thread David Nolen
For anybody who's still following, I've updated accessors.clj with a new
behavior. I realized assoc-in and get-in are very powerful, they work with
all sorts of collections (not just maps, duh on my part), thus now
if anything in the list of accessor symbols is not actually a
clojure.lang.Symbol, it will switch over to assoc-in/get-in. This allows
accessors to seemlessly support updating lists, vectors, etc. as well as
maps that are using something other than keywords to store properties. A non
silly example:

  (ns accessors-example
(:use accessors)
(:use clojure.contrib.str-utils))

  (accessors first last)

  (defget name [m]
(str (acc-first m)   (acc-last m)))

  (defset name [m v]
(let [[first last] (re-split #  v)]
  (- m
   (acc-first first)
   (acc-last last

  (acc-name {:first Bob, :last Smith}) ; - Bob Smith
  (acc-name {} Bob Smith) ; - {:first Bob, :last Smith}'s

On Sun, Apr 26, 2009 at 10:27 PM, David Nolen dnolen.li...@gmail.comwrote:

 GENIOUS idea Laurent ;)
 Extremely terse and uniform. Also because I switched the implementation to
 use multimethods, performance has jumped quite a bit. In fact if you memoize
 find-accessors, the code is only a little bit slower than
 update-in/assoc-in/get-in! The defset and defget macros now check to make
 sure their definition only defines 2 or 1 arguments respectively.
 find-accessor throws an error if you attempt to use an accessor in acc-in
 that hasn't been previously defined .

 The code is for now hosted here
 http://github.com/swannodette/accessors/tree/master.

 Does anybody care to see this in contrib? If so I'll send in my CLA :)

 (comment
   (accessors x y z)

   ; {:x 4}
   (acc-x {} 4)

   ; 4
   (acc-x {:x 4})

   (defset x [m v]
 (assoc (assoc m :new new) :x v))

   ;; {:new new, :x {:y {:z 1}}}
   (acc-in {:x {:y {:z 0}}} '(x y z) 1)

   ;; 0
   (acc-in {:x {:y {:z 0}}} '(x y z))

   ; {:x 4, :new new, :foo 9}
   (let [z {:foo 9}]
 (acc-x z 4))

   ; 10
   (let [y {:z 10}]
 (acc-z y))

   ; [0 1 2]
   (map acc-x [{:x 0}, {:x 1}, {:x 2}])

   ; performance --

   ; ~180ms 2.53ghz MBP Core2Duo
   (time (dotimes [x 10]
   (assoc-in {:x {:y {:z 0}}} [:x :y :z] 1)))

   ; ~700ms 2.53ghz MBP Core2Duo
   (time (dotimes [x 10]
   (acc-in {:x {:y {:z 0}}} '(x y z) 1)))

   ; ~300ms 2.53ghz MBP Core2Duo
   (def find-accessor (memoize find-accessor))
   (time (dotimes [x 10]
   (acc-in {:x {:y {:z 0}}} '(x y z) 1)))
 )

 On Sun, Apr 26, 2009 at 6:27 PM, Laurent PETIT laurent.pe...@gmail.comwrote:


 Hello,

 Maybe you should consider creating a single function with 2 arities:
 with one argument, it's the getter, with two arguments, it's the
 setter (that returns the new type) !


 (prop-foo obj) ; -- returns the property prop-foo
 (prop-foo obj newval) ; -- returns a new version of obj with prop-foo
 property set to newval

 Terse and uniform :-)

 ?



 2009/4/26 David Nolen dnolen.li...@gmail.com:
  You're right. The following includes code for handling this case via
 setin
  and getin. I've also ditched macros, because that code couldn't support
 new
  lexical scopes in the setter/getter definition. setin getin support
 works by
  dynamically resolving getters and setters, thus this is slower than
 direct
  access via assoc-in and get-in.
  Personally I have to say now that this is written, I prefer the
 terseness
  of:
  (set-x some-map v)
  over
  (assoc some-map :x v)
  This
  (get-x some-map)
  isn't as nice as
  (:x map)
  But it's also more explicit about how the map is being used- that a
 level
  indirection is required because the implementation might change.
  ;; ==
  (comment
(accessors x y z)
; {:x 4}
(set-x {} 4)
(defset x [m v]
  (assoc (assoc m :new new) :x v))
;; {:new new, :x {:y {:z 1}}}
(setin {:x {:y {:z 0}}} '(x y z) 1)
;; 0
(getin {:x {:y {:z 0}}} '(x y z))
; {:x 4, :new new, :foo 9}
(let [z {:foo 9}]
  (set-x z 4))
; 10
(let [y {:z 10}]
  (get-z y))
; [0 1 2]
(map get-x [{:x 0}, {:x 1}, {:x 2}]))
  (defn setter* [sym]
`(defn ~(symbol (str set- sym)) [~'m ~'v]
   (assoc ~'m ~(keyword (str sym)) ~'v)))
  (defn getter* [sym]
`(defn ~(symbol (str get- sym)) [~'m]
   (~(keyword (str sym)) ~'m)))
  (defmacro defset [sym args  forms]
(let [set-sym (symbol (str set- sym))]
  `(defn ~set-sym [...@args]
 ~...@forms)))
  (defmacro defget [sym args  forms]
(let [get-sym (symbol (str get- sym))]
  `(defn ~get-sym [...@args]
 ~...@forms)))
  (defn find-accessor [sym acc-type]
(let [ns   (or (namespace sym)
  (str *ns*))
  sym-name (name sym)]
  (find-var (symbol ns (str (name acc-type) - sym-name)
  (defn setin [m [sym  syms] v]
(let [setter (find-accessor sym :set)
  getter (find-accessor sym :get)]
(if syms
  (setter m (set-in (getter m) syms v))
  (setter m v
  (defn getin [m [sym  

Re: PeepCode screencast

2009-04-27 Thread Paul Barry
Yeah, I agree that it was pretty good.  I like that you have a non-trivial
working application at the end of it.  My one criticism is that it's too
hard to try to follow along and write the code as you go because there are
too many changes from each step to step that aren't discussed in the
screencast, you just have to look at the code.

Also, it does glaze over too many topics to be useful for a beginner, so I'm
not sure that explaining some basic concepts as they come up but not others
does anyone any good.  Stu's book is much better for a beginner, but if you
have been doing Clojure for a little while, this is a great screencast.

On Mon, Apr 27, 2009 at 6:51 AM, Jennifer Morgan 
jennifermorgan2...@gmail.com wrote:


 I though the screen cast was really very good,especially as it gives a
 good overview of how to break up your code and about packaging. It
 does go a bit quick, but I found that by re-watching + reading the
 code at the same time very helpful. It a useful demo to see the power
 and conciseness of clojure ;-)


 On 26/04/2009, Andrew Wagner wagner.and...@gmail.com wrote:
  Just to provide a review - I must say, I really wanted to like this
  screencast, and failed, unfortunately. It tries to cover everything from
  what is functional programming? (tracing through passing functional
  arguments, and basic map/reduce stuff, for example) to the intricacies of
  STM use and clojure syntax/semantics. While all of these are worthwhile
  talks, trying to cover all of them in an hour means flying through them
 and
  really barely getting into any of them.
 
  On Fri, Apr 24, 2009 at 1:03 PM, Phil Hagelberg p...@hagelb.org wrote:
 
 
  I'm proud to announce that the Functional Programming with Clojure
  PeepCode screencast has just been published:
 
  http://peepcode.com/products/functional-programming-with-clojure
 
  It's a professionally-produced 65-minute video that introduces all the
  foundational concepts of Clojure by stepping through the creation of a
  multiplayer text adventure game. If you've been looking for a quick
  way to get up to speed on Clojure, this is your ticket.
 
  The screencast is sold for $9, and there's a preview available:
 
  http://peepcode.com/system/uploads/2009/peepcode-clojure-preview.mov
 
  Hope you like it!
 
  -Phil Hagelberg
 
  http://technomancy.us
 
  
 
 
  
 

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: PeepCode screencast

2009-04-27 Thread Andrew Wagner
I can agree with that, for the most part. But if you've been doing clojure
for a while, why cover basic syntax, basic map/reduce stuff, etc.? The time
could have been spent more usefully. It just failed to pick an audience and
stick with it, that's all.

On Mon, Apr 27, 2009 at 2:45 PM, Paul Barry pauljbar...@gmail.com wrote:

 Yeah, I agree that it was pretty good.  I like that you have a non-trivial
 working application at the end of it.  My one criticism is that it's too
 hard to try to follow along and write the code as you go because there are
 too many changes from each step to step that aren't discussed in the
 screencast, you just have to look at the code.

 Also, it does glaze over too many topics to be useful for a beginner, so
 I'm not sure that explaining some basic concepts as they come up but not
 others does anyone any good.  Stu's book is much better for a beginner, but
 if you have been doing Clojure for a little while, this is a great
 screencast.

 On Mon, Apr 27, 2009 at 6:51 AM, Jennifer Morgan 
 jennifermorgan2...@gmail.com wrote:


 I though the screen cast was really very good,especially as it gives a
 good overview of how to break up your code and about packaging. It
 does go a bit quick, but I found that by re-watching + reading the
 code at the same time very helpful. It a useful demo to see the power
 and conciseness of clojure ;-)


 On 26/04/2009, Andrew Wagner wagner.and...@gmail.com wrote:
  Just to provide a review - I must say, I really wanted to like this
  screencast, and failed, unfortunately. It tries to cover everything from
  what is functional programming? (tracing through passing functional
  arguments, and basic map/reduce stuff, for example) to the intricacies
 of
  STM use and clojure syntax/semantics. While all of these are worthwhile
  talks, trying to cover all of them in an hour means flying through them
 and
  really barely getting into any of them.
 
  On Fri, Apr 24, 2009 at 1:03 PM, Phil Hagelberg p...@hagelb.org
 wrote:
 
 
  I'm proud to announce that the Functional Programming with Clojure
  PeepCode screencast has just been published:
 
  http://peepcode.com/products/functional-programming-with-clojure
 
  It's a professionally-produced 65-minute video that introduces all the
  foundational concepts of Clojure by stepping through the creation of a
  multiplayer text adventure game. If you've been looking for a quick
  way to get up to speed on Clojure, this is your ticket.
 
  The screencast is sold for $9, and there's a preview available:
 
  http://peepcode.com/system/uploads/2009/peepcode-clojure-preview.mov
 
  Hope you like it!
 
  -Phil Hagelberg
 
  http://technomancy.us
 
  
 
 
  
 




 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Oddity with clojure-contrib/sql

2009-04-27 Thread Mark Derricutt
The table def was:
CREATE TABLE users (
user_id VARCHAR(255) NOT NULL,
msisdn VARCHAR(255),
date_created timestamp with time zone NOT NULL,
date_verified timestamp with time zone NOT NULL
);

I'll try to build it up as a test case tonight.


On Tue, Apr 28, 2009 at 1:57 AM, Stephen C. Gilardi squee...@mac.comwrote:


 That code looks right to me. What is the definition of the users table?
 Could you please post a minimal complete example that shows the problem?



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Stack Overflow problem with Maps

2009-04-27 Thread fitzpatrick...@googlemail.com

Hi,
I am working with a very long list and populating it to a map. What i
have is three pieces of data from the list;
-Row Number
-Heading info List
-Actual Info List
note: both the Heading Info List and Actual Info List have the same
number of elements as each heading name will have a corresponding
actual value.

I define a headingnamelist which is a list of headings to be used to
generate the keys.

I iterate through the list and for each row look up each of the
heading names in the Heading Info List to get an index of where a
particular element should be in the Actual Info List and then i go and
get this from the Actual Info List and use this as part of my key.
With the key i write the Row Number to the map. If the key is already
there i just cons it to the exiting map value.

As i said it is quite a large list and i keep getting a stack
overflow. For comparison purposes i ran a similar program in python
and it ran in a matter of seconds.

Has anybody any ideas why this is happening?

tks,
PJ
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: vimclojure help

2009-04-27 Thread Meikel Brandmeyer

Hi,

Am 27.04.2009 um 19:56 schrieb jim:


I forgot to say that I have:

let clj_want_gorilla = 1
let vimclojure#NailgunClient = /home/jim/clojure/ng

in my .vimrc file.


That's clear. Otherwise you wouldn't have the mapping
in the :map output.

I'm a bit confused about the beep... There is no error
message of some kind? You can also check this with
:messages.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: vimclojure help

2009-04-27 Thread jim

The lack of error message stuck me as well.

The result of :messages simply lists Bram Molenaar as the messages
maintainer.

I also mapped \ab to a so that it would enter insert mode and that
worked fine. So I don't think it's a problem with the mapping. I'm
guessing the plugin isn't fully loaded or something.

Is there a way to check that? Perhaps a way to attempt to start the
REPL from the command prompt?

Jim

Meikel Brandmeyer wrote:
 Hi,

 Am 27.04.2009 um 19:56 schrieb jim:

  I forgot to say that I have:
 
  let clj_want_gorilla = 1
  let vimclojure#NailgunClient = /home/jim/clojure/ng
 
  in my .vimrc file.

 That's clear. Otherwise you wouldn't have the mapping
 in the :map output.

 I'm a bit confused about the beep... There is no error
 message of some kind? You can also check this with
 :messages.

 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
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: similar to find-first

2009-04-27 Thread billh04



On Apr 27, 11:22 am, Christophe Grand christo...@cgrand.net wrote:
 find-first-result is already in core: some

As an aside, I would have liked (some pred coll) to return the item
that makes the pred true and the current implementation of `some to be
renamed `any? so that we would have the following:

  (any? odd? [2 4 5 12]) ;; result is true
  (every? odd? [3 5 6 13]) ;; result is false
  (not-any? odd? [2 4 5 12]) ;; result is false
  (not-every? odd? [3 5 6 13]) ;; result is true
  (some odd? [2 4 5 12]) ;; result is 5

Mathematically, for the first four,

 (Ex in [2 4 5 12])(x is odd)
 (Ax in [3 5 6 13])(x is odd)
 ~(Ex in [2 4 5 12])(x is odd)
 ~(Ax in [3 5 6 13])(x is odd)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Stack Overflow problem with Maps

2009-04-27 Thread David Nolen
Can you post your code, always helpful :)

On Mon, Apr 27, 2009 at 4:07 PM, fitzpatrick...@googlemail.com 
fitzpatrick...@googlemail.com wrote:


 Hi,
 I am working with a very long list and populating it to a map. What i
 have is three pieces of data from the list;
 -Row Number
 -Heading info List
 -Actual Info List
 note: both the Heading Info List and Actual Info List have the same
 number of elements as each heading name will have a corresponding
 actual value.

 I define a headingnamelist which is a list of headings to be used to
 generate the keys.

 I iterate through the list and for each row look up each of the
 heading names in the Heading Info List to get an index of where a
 particular element should be in the Actual Info List and then i go and
 get this from the Actual Info List and use this as part of my key.
 With the key i write the Row Number to the map. If the key is already
 there i just cons it to the exiting map value.

 As i said it is quite a large list and i keep getting a stack
 overflow. For comparison purposes i ran a similar program in python
 and it ran in a matter of seconds.

 Has anybody any ideas why this is happening?

 tks,
 PJ
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Stack Overflow problem with Maps

2009-04-27 Thread Dimiter malkia Stanev

Unless you provide some kind of isolated source code that reproduces
the problem, I don't think it is going to be easy to help you out.

But try adding (doall ..) to some your map calls and others.

Even better, look at this excellent explanation why this might be
happening by Cristophe Grand:
http://groups.google.com/group/clojure/browse_frm/thread/43f9a716f1f91f5d#

Also check whether you don't have recursive functions (replace them
with loop/recur), or mutually recursive ones (for them, you would have
to use mutual exclusion). But I doubt that was the problem, more
likely the default lazy mode of clojure, and what Cristophe was
talking about is probably connected to your problem.


On Apr 27, 1:07 pm, fitzpatrick...@googlemail.com
fitzpatrick...@googlemail.com wrote:
 Hi,
 I am working with a very long list and populating it to a map. What i
 have is three pieces of data from the list;
 -Row Number
 -Heading info List
 -Actual Info List
 note: both the Heading Info List and Actual Info List have the same
 number of elements as each heading name will have a corresponding
 actual value.

 I define a headingnamelist which is a list of headings to be used to
 generate the keys.

 I iterate through the list and for each row look up each of the
 heading names in the Heading Info List to get an index of where a
 particular element should be in the Actual Info List and then i go and
 get this from the Actual Info List and use this as part of my key.
 With the key i write the Row Number to the map. If the key is already
 there i just cons it to the exiting map value.

 As i said it is quite a large list and i keep getting a stack
 overflow. For comparison purposes i ran a similar program in python
 and it ran in a matter of seconds.

 Has anybody any ideas why this is happening?

 tks,
 PJ
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



areduce flaw

2009-04-27 Thread Boris Mizhen

Hello all,
It seems to me that areduce can not be used with an anonymous array.
Consider:

(areduce (.. System getProperties values toArray) i r 0
(some_expression))

It seems to me that there is no way to get i'th element of the array
in (some_expression) other than let'-ing it first.
It would be nice to be able to pass the name for the current element
or define a local macro that expands to
(aref #a i) - here #a is a gensym for the array itself ...

Thought?

Boris

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Stack Overflow problem with Maps

2009-04-27 Thread pjfitz

Hi,
Here is the code. Each row of data is a string with @ between the
three types of data i mentioned.
-Row Number
-Heading info List
-Actual Info List
The Heading Info List is created by splitting on , as is the Actual
info list.
tks,
PJ


(import '(java.io InputStreamReader OutputStreamWriter))
(use '[clojure.contrib.duck-streams])
(import '(java.io File))

(def my-row-data-file e:/SoccerData/rowdata.txt)
(def my-map-file e:/SoccerData/map-data.txt)

(defn get-idx-of [inp-data inp-name]
(loop [my-count 0 inner-data inp-data]
(cond
(= (count inner-data) 0) -1
(= inp-name (first inner-data)) my-count
:else
(recur (+ 1 my-count) (rest inner-data))
)
)
)

(defn do-the-date-bigint [inp-date-string]
(let [date-array (.split inp-date-string /)]
(str20 (nth date-array 2)
(nth 
date-array 1)
(nth 
date-array 0)
)
)
)

;;

(defn get-key-instance [inp-key-names inp-row-data]
(loop [my-inner-vector (first inp-key-names) inner-key-names (rest
inp-key-names)]
(cond
(= (count inner-key-names) 0) (cons inp-key-names (vec 
(reverse my-
inner-vector)))
:else
(let [index-row (get-idx-of (nth inp-row-data 1) (first 
inner-key-
names))]
(if (== index-row -1) ()
(recur  (cons (nth (last inp-row-data) index-row)

my-inner-vector)
(rest 
inner-key-names)
)
)
)
)
)
)

(defn produce-date-rn-array [inp-row-data]
(try
[(do-the-date-bigint (nth (nth inp-row-data 2) (get-idx-of (nth inp-
row-data 1) Date)))
(nth inp-row-data 0)] (catch Exception e []
)
)
)

(defn update-map-list [inp-map inp-new-array inp-row-data inp-key-
names-list]
(loop [inner-key-names-list inp-key-names-list inner-map inp-map]
(cond
(= (count inner-key-names-list) 0) inner-map
:else
(let [inner-key-instance (get-key-instance (first 
inner-key-names-
list) inp-row-data)]
(recur
(rest inner-key-names-list)
(assoc-in inner-map inner-key-instance
(sort-by #(first %) (cons inp-new-array 
(get-in inner-map inner-
key-instance)))
)
)
)
)
)
)

(defn process-row-str[inp-row-str]
(loop [inner-array (rest (.split inp-row-str @)) inner-list [(first
(.split inp-row-str @))]]
(cond
(= (count inner-array) 0) (reverse inner-list)
:else
(recur  (rest inner-array)
(cons (.split (first 
inner-array) ,) inner-list)
)
)
)
)

(defn process-row-data-file [inp-key-names-list]
(with-open [rdr (reader my-row-data-file)]
(loop [inner-row-data (line-seq rdr) my-inner-map {}]
(cond
(= (count inner-row-data) 0) my-inner-map
:else
(recur  (rest inner-row-data)

(update-map-list my-inner-map

(produce-date-rn-array 
(process-row-str (first inner-
row-data)))

(process-row-str (first 
inner-row-data))

inp-key-names-list
)
)
)
)
)
)





On Apr 27, 9:34 pm, Dimiter \malkia\ Stanev mal...@gmail.com
wrote:
 Unless you provide some kind of isolated source code that reproduces
 the problem, I don't think it is going to be easy to help you out.

 But try adding (doall ..) to some your map calls and others.

 Even better, look at this excellent explanation why this might be
 happening by Cristophe 
 

Re: vimclojure help

2009-04-27 Thread jim

I think in my attempt to fix the problem, I masked a symptom.

When I saw that I didn't have the key mappings, I added some autocmds
to my .vimrc. From reading the vim plugin, I believe those should have
been generated automatically when a *.clj file is loaded. Removing
those autocmds from the .vimrc and the mappings go away.

Reading the vimclojure plugin, I see that it checks for the existence
of b:vimclojure_namespace before adding those mappings. When I do
a :echo b:vimclojure_namespace, I get an undefined variable error.

Jim

On Apr 27, 3:09 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 27.04.2009 um 19:56 schrieb jim:

  I forgot to say that I have:

  let clj_want_gorilla = 1
  let vimclojure#NailgunClient = /home/jim/clojure/ng

  in my .vimrc file.

 That's clear. Otherwise you wouldn't have the mapping
 in the :map output.

 I'm a bit confused about the beep... There is no error
 message of some kind? You can also check this with
 :messages.

 Sincerely
 Meikel

  smime.p7s
 5KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: vimclojure help

2009-04-27 Thread Meikel Brandmeyer

Hi,

Am 27.04.2009 um 22:18 schrieb jim:


The lack of error message stuck me as well.

The result of :messages simply lists Bram Molenaar as the messages
maintainer.

I also mapped \ab to a so that it would enter insert mode and that
worked fine. So I don't think it's a problem with the mapping. I'm
guessing the plugin isn't fully loaded or something.

Is there a way to check that? Perhaps a way to attempt to start the
REPL from the command prompt?


You can do a: :call vimclojure#Repl.New().

Did you install the vimplugin by defining vimdir in local.properties
and using ant install?

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: The Path to 1.0

2009-04-27 Thread Laurent PETIT

New patch with corrections posted to google code,

regards,

-- 
laurent

2009/4/27 Laurent PETIT laurent.pe...@gmail.com:
 I've created issue 110 with the patch attached in clojure's google code 
 project.

 Hi Rich, Howard,

 I'll answer to both at the same time, trying to reconcile things a bit.

 Howard, my first patch was already along the lines of what you
 described below, I think (concerning the fact to use ant to generate
 with filters from templates).

 Then Rich asked if it was possible to not have to generate files. I
 understand this question a little less broadly than not generate
 files at all cost, but not generate files in the source code. So
 that if the generation step is not followed by some tool for some
 reason, things don't break - at compile time or run time -.

 That's why I came up with this new version:

  * a src/clj/clojure/version.properties file
  * this version.properties file is the reference for version numbers.
 It is on the classpath so it can be seen by clojure at runtime. It is
 in a subdirectory of clojure-the-project so any tool can refer to it
 relatively to the installation of clojure.

  * I've added the needed code to clojure to load clojure version
 number at startup time


 I've also added function (clojure.core/clojure-version) that will
 return a string representing the version from the structured
 *clojure-version* map. The algorithm here is simple:
 MAJOR.MINOR[.INCREMENT][-QUALIFIER][-SNAPSHOT]

  * I've changed the ant build.xml so that it creates fully qualified
 names with version attributes for the generated jars.
  * Note on the :interim attribute: to protect the person who makes
 releases from itself, instead of considering :interim to be true if
 there is the true string in the properties file, I've made the
 opposite choice: interim is true for any value other than false. So
 if there is a typo in version.properties (e.g. tru instead of true),
 then the release will be marked as interim, and that will not be a big
 deal. In the other case, it would be a big deal if an official release
 was made accidentally instead of an interim.

 * finally, pom.xml file is now generated from ant as part of the
 classic init step.

 Note: I strongly suggest that the clojure.version.interim property
 remains true in svn, so that it's not possible to inadvertently
 release a version too early.



 HTH,

 Feel free to use or not,

 --
 Laurent

 2009/4/24 Howard Lewis Ship hls...@gmail.com:

 Another option is for the version number to be in build.xml, and for
 it to generate a runtime file (so that Clojure can know its own
 version number) and set the version number inside a generated pom.xml.
  You can use Ant resource copying with filters to accomplish both
 these goals.

 On Thu, Apr 23, 2009 at 8:24 AM, Laurent PETIT laurent.pe...@gmail.com 
 wrote:

 2009/4/23 Rich Hickey richhic...@gmail.com:



 On Apr 22, 12:41 pm, Laurent PETIT laurent.pe...@gmail.com wrote:
 2009/4/22 Rich Hickey richhic...@gmail.com:

  [...]
  {:major 1, :minor 0, :incremental 0, :qualifier :rc1 :interim true}

  for interim versions and

  {:major 1, :minor 0, :incremental 0}

  for releases. :interim tracks the SNAPSHOT segment of the version
  string.
  [...]
  I don't mind the build producing clojure-1.0.0.jar etc, but it doesn't
  now. The master build is Ant. Where is the best place to put the
  version info so it can be leveraged by Ant, Maven and the clojure core
  runtime in order to produce *clojure-version* ?

 Here a patch that allows to initialize from ant and from a file
 version.properties the values in *clojure-version*.

 The patch only addresses the problematic of having a single place for
 version attributes.
 Having the ant build also use these properties for creating correctly
 numbered jars is not part of the patch.

 Note that I had to create a new file, src/clj/clojure/core_version.clj
 , which is created by ant as a combination of template file
 core_version-template.clj and the properties from version.properties.

 You'll see that if you don't like the names of the keys in
 version.properties, build.xml is the single place where to change them
 (apart from version.properties, of course).
 Also, if you don't like the name version.properties (e.g. if it should
 be named project.properties or whatever for easing maven users), then
 you just have to change its occurence in build.xml too.

 If you like it, it can file an issue to google code and attach the patch,


 Thanks!

 I can't say I love the idea of generating a file during build.
 Me too, that's why I have made the file as short and independent as 
 possible.

 Well, I tried to keep close to the idea of having the version numbers
 built-in, similarly to what was commited where it was also not read
 from a simpler file at load time.

 What about clojure.jar containing a properties file it reads at load time?

 Why not, indeed ? The file would have to placed in the classpath, e.g.
 in directory 

Re: areduce flaw

2009-04-27 Thread Boris Mizhen

I suspect I will be asking more questions, so in order not to start
another thread I will post below :)

Why
((comp - +) -3 -4) = 7

but

((comp Math/abs +) -3 -4) = Error?
java.lang.Exception: No such namespace: Math (NO_SOURCE_FILE:1)
  [Thrown class clojure.lang.Compiler$CompilerException]

and
((comp #(Math/abs %) +) -3 -4) = 7

Is there an inherent difference between java and clojure functions, so
Java functions can't be passed as arguments? Or am I missing
something?

How can I pass a static java function to another function?

A member function must be trickier because this must be supplied, but
perhaps a macro can be created that results in a function that would
capture this and call the member function appropriately ...

Thank you,
Boris


On Apr 27, 4:26 pm, Boris Mizhen bo...@boriska.com wrote:
 Hello all,
 It seems to me that areduce can not be used with an anonymous array.
 Consider:

 (areduce (.. System getProperties values toArray) i r 0
 (some_expression))

 It seems to me that there is no way to get i'th element of the array
 in (some_expression) other than let'-ing it first.
 It would be nice to be able to pass the name for the current element
 or define a local macro that expands to
 (aref #a i) - here #a is a gensym for the array itself ...

 Thought?

 Boris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: vimclojure help

2009-04-27 Thread Meikel Brandmeyer

Hi,

Am 27.04.2009 um 22:50 schrieb jim:


Reading the vimclojure plugin, I see that it checks for the existence
of b:vimclojure_namespace before adding those mappings. When I do
a :echo b:vimclojure_namespace, I get an undefined variable error.


Please try the following from outside vim:

ng de.kotka.vimclojure.nails.NamespaceOfFile  some.clj

For an empty file this should return user, for a file with ns or in-ns
it should return the namespace. Does this work?

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: areduce flaw

2009-04-27 Thread Meikel Brandmeyer

Hi,

Am 27.04.2009 um 23:17 schrieb Boris Mizhen:


((comp #(Math/abs %) +) -3 -4) = 7

How can I pass a static java function to another function?


Here you already gave the answer to your question. Wrap it in
a Clojure fn/#().


A member function must be trickier because this must be supplied, but
perhaps a macro can be created that results in a function that would
capture this and call the member function appropriately ...


#(.someMethod an-object %)

Or passing in the object:

#(.someMethod %1 %2)

For apply and friends one needs a more elaborate way.
Search for rhickey jcall site:paste.lisp.org.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


hashmap default values

2009-04-27 Thread Mark Volkmann

Is there something in core or contrib that supports creating a map
where gets on undefined keys return a specified default value? For
example, I'd like to create a hashmap where the default value for
missing keys is zero.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: hashmap default values

2009-04-27 Thread Meikel Brandmeyer

Hi Mark,

Am 27.04.2009 um 23:42 schrieb Mark Volkmann:


Is there something in core or contrib that supports creating a map
where gets on undefined keys return a specified default value? For
example, I'd like to create a hashmap where the default value for
missing keys is zero.


You can specify the default value when retrieving the value:

(def m {:a 1 :b 2})
(get m :c 0) = 0
(m :c 0) = 0 (untested)
maybe also: (:c m 0) = 0 (also untested)

Sincerely
Meikel

smime.p7s
Description: S/MIME cryptographic signature


Re: areduce flaw

2009-04-27 Thread Boris Mizhen

Hi Meikel, thanks for the answer.

I wonder if someone could explain or point me to the explanation about
*why* a Java static fn can't be passed just like a closure fn?

After all the syntax to call them is the same :)

Thanks,
Boris


On Apr 27, 5:34 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 27.04.2009 um 23:17 schrieb Boris Mizhen:

  ((comp #(Math/abs %) +) -3 -4) = 7

  How can I pass a static java function to another function?

 Here you already gave the answer to your question. Wrap it in
 a Clojure fn/#().

  A member function must be trickier because this must be supplied, but
  perhaps a macro can be created that results in a function that would
  capture this and call the member function appropriately ...

 #(.someMethod an-object %)

 Or passing in the object:

 #(.someMethod %1 %2)

 For apply and friends one needs a more elaborate way.
 Search for rhickey jcall site:paste.lisp.org.

 Sincerely
 Meikel

  smime.p7s
 5KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: areduce flaw

2009-04-27 Thread Kevin Downey

no, the syntax is not the same.

user= (macroexpand-1 '(.foo bar))
(. bar foo)



On Mon, Apr 27, 2009 at 2:51 PM, Boris Mizhen bo...@boriska.com wrote:

 Hi Meikel, thanks for the answer.

 I wonder if someone could explain or point me to the explanation about
 *why* a Java static fn can't be passed just like a closure fn?

 After all the syntax to call them is the same :)

 Thanks,
 Boris


 On Apr 27, 5:34 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 27.04.2009 um 23:17 schrieb Boris Mizhen:

  ((comp #(Math/abs %) +) -3 -4) = 7

  How can I pass a static java function to another function?

 Here you already gave the answer to your question. Wrap it in
 a Clojure fn/#().

  A member function must be trickier because this must be supplied, but
  perhaps a macro can be created that results in a function that would
  capture this and call the member function appropriately ...

 #(.someMethod an-object %)

 Or passing in the object:

 #(.someMethod %1 %2)

 For apply and friends one needs a more elaborate way.
 Search for rhickey jcall site:paste.lisp.org.

 Sincerely
 Meikel

  smime.p7s
 5KViewDownload
 




-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: special handling of :type in meta data

2009-04-27 Thread David Chamberlin

Konrad,

Thanks for the guidance, this makes a lot of sense - I was planning to
provide a method for printing these objects in the future anyway.

A bit of background: I'm trying to put together a simple framework
that uses structures to represent business-domain objects read from a
database, similar to the object persistence mechanisms available in
JPA, etc.  The members of each structure hold the persistent data for
the object and I was thinking of using meta data to store ancillary
information such as object type, a reference to the context in which
the object was loaded and the state of the object (e.g. whether it is
consistent with the database or not).

A working system would likely have hundreds of thousands of such
structures loaded into memory and as such memory usage is a
significant concern.

By including state data in the meta data, I make it more difficult to
share meta data between objects (though maybe interning might be an
option?)  Alternatively, I could use the meta data for the information
that is more or less static (type and context) and make the state part
of the main structure data.  I'm tending towards the former approach
due to the fact that two objects with the same data in different
states should still probably be viewed as 'equal'


On Apr 27, 9:06 am, Konrad Hinsen konrad.hin...@laposte.net wrote:
 On 27.04.2009, at 09:42, Meikel Brandmeyer wrote:

  AFAIU, struct-maps are not an optimisation for efficiency of the
  key lookup, but for the storage space of the keys. So timings
  should probably read memstats.

 If memory is the issue, then creating a single instance of the  
 metadata map for all values of a type should be sufficient.

 As for timing, key lookup is faster for struct maps than for standard  
 maps if the number of keys defined in the struct is much smaller than  
 the total number of keys in the map. This is probably not the case  
 for most real-life metadata maps. Key lookup can be improved even  
 more using accessor functions, but that would imply relying on the  
 metadata being a struct-map for a given struct, which doesn't look  
 like a great idea.

 Konrad.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: areduce flaw

2009-04-27 Thread Stuart Sierra

On Apr 27, 5:51 pm, Boris Mizhen bo...@boriska.com wrote:
 I wonder if someone could explain or point me to the explanation about
 *why* a Java static fn can't be passed just like a closure fn?

The only reason I can give you is that Java methods aren't first-class
objects, like Clojure fns.

The (.method object) and (SomeClass/method ...) forms are syntactic
sugar, that expand to a special form:

user (macroexpand '(.method object argument))
(. object method argument)
user (macroexpand '(Class/method argument))
(. Class method argument)

Perhaps the compiler could automatically wrap Java methods when they
are used as a value, but that might not be easy or efficient to
implement.

-Stuart Sierra
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Would it be worth rewriting a parser library to use monads?

2009-04-27 Thread samppi

I have a library called FnParse, and I'm wondering if I should rewrite
it using monads. (You can see FnParse's documentation at http://
wiki.github.com/joshua-choi/fnparse and its implementation at http://
github.com/joshua-choi/fnparse/blob/
065cc97da4c368e10d901edacbe885bd3a8443a1/src/name/choi/joshua/
fnparse.clj.) It implements a bunch of rule functions that consume
tokens:
  Sequence of tokens - [a new product from the consumed tokens,
remaining tokens]

Right now, my basic rule-combining functions use loops over the rules
to be combined.

Now, I've been reading the Clojure monad introductions that have been
popping up around, and some things that struck me as interesting were
that parsers could be elegantly implemented using monads, and that
monads were modular and combinable.

I don't know enough about monads, though, to know if it'd be worth
trying to rewrite my library in it. It seems like if do that, people
may be able to directly use the new monads in their own monads, but
I'm not sure. My library is working fine as of now—would it be worth
it to add monads to 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
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: areduce flaw

2009-04-27 Thread Timothy Pratley

 How can I pass a static java function to another function?

There is also memfn:
(memfn name  args)
Macro
Expands into code that creates a fn that expects to be passed an
object and any args and calls the named instance method on the object
passing the args. Use when you want to treat a Java method as a first-
class fn.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Would it be worth rewriting a parser library to use monads?

2009-04-27 Thread jim

Monads are a great thing to learn because they can be used in so many
ways to make code simpler and more modular. But, they require an
investment of time to understand. You'll definitely be a better
programmer by trying to understand them. I'd say go for it, but
realize that it's going to be a steep learning curve at first.

Jim

On Apr 27, 5:48 pm, samppi rbysam...@gmail.com wrote:
 I have a library called FnParse, and I'm wondering if I should rewrite
 it using monads. (You can see FnParse's documentation at http://
 wiki.github.com/joshua-choi/fnparse and its implementation at http://
 github.com/joshua-choi/fnparse/blob/
 065cc97da4c368e10d901edacbe885bd3a8443a1/src/name/choi/joshua/
 fnparse.clj.) It implements a bunch of rule functions that consume
 tokens:
   Sequence of tokens - [a new product from the consumed tokens,
 remaining tokens]

 Right now, my basic rule-combining functions use loops over the rules
 to be combined.

 Now, I've been reading the Clojure monad introductions that have been
 popping up around, and some things that struck me as interesting were
 that parsers could be elegantly implemented using monads, and that
 monads were modular and combinable.

 I don't know enough about monads, though, to know if it'd be worth
 trying to rewrite my library in it. It seems like if do that, people
 may be able to directly use the new monads in their own monads, but
 I'm not sure. My library is working fine as of now—would it be worth
 it to add monads to 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
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: vimclojure help

2009-04-27 Thread jim

That was exactly what I was reading through the vimclojure.vim plugin
trying to find when I saw your post. It's a great thing to have when
trying to trouble shoot problems because you can isolate the server.

Anyway, I started over by wiping out my .vim and vimclojure-2.1.0
directories. Updated and rebuilt clojure and clojure-contrib. Re-
downloaded and rebuilt vimclojure paying very careful attention to get
all the details right. And when I ran the ng-server script, it still
blew up with an error from 'find'.

Finally discovered what I think is a bug in the ng-server script. The
find command has a '1' between the -depth and -print0. Removing
this allowed me to start the ng server with the script, which helped.
But I get the following error when I do the ng command you posted:

java.lang.NoClassDefFoundError: clojure/lang/APersistentMap (wrong
name: clojure/proxy/clojure/lang/APersistentMap)

CLASSPATH for the server is:

/home/jim/vimclojure-2.1.0/build/vimclojure.jar:src

CLOJURE_EXT for the server is:

/home/jim/clojure

/home/jim/clojure contains clojure.jar and clojure-contrib.jar.

On Apr 27, 4:29 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 27.04.2009 um 22:50 schrieb jim:

  Reading the vimclojure plugin, I see that it checks for the existence
  of b:vimclojure_namespace before adding those mappings. When I do
  a :echo b:vimclojure_namespace, I get an undefined variable error.

 Please try the following from outside vim:

 ng de.kotka.vimclojure.nails.NamespaceOfFile  some.clj

 For an empty file this should return user, for a file with ns or in-ns
 it should return the namespace. Does this work?

 Sincerely
 Meikel

  smime.p7s
 5KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: cannot use swig native shared libraries

2009-04-27 Thread jim

Hey Antonio,

I'm getting a similar error. I wanted to call setuid from Clojure, so
I followed this link's example:
http://www2.sys-con.com/itsg/virtualcd/Java/archives/0510/Silverman/index.html

to build a java class and a shared library. I added the class to my
classpath and was able to import my UID class. But when I tried to
call the UID.setuid method, it gave me that UnsatisfiedLinkError. Did
you find a solution to your problem?

Jim

On Apr 22, 8:41 am, Antonio, Fabio Di Narzo
antonio.fa...@gmail.com wrote:
 Hi all.
 I'm having problems with using swig-generated wrappers with Clojure.
 I'm running ubuntu-8.04-i386, gcc-4.2.4, swig-1.3.33, openjdk-1.6.0,
 latest clojure release.

 I've cut down a minimal reproducible example.
 The swig file:
 ---file:swig_test.i---
 %module swig_test
 %{
 int swig_test_whatever() {
   return 3;}

 %}
 int swig_test_whatever();
 ---cut---

 Compile with:
 ---cut---
 mkdir swig_test
 swig -java -package swig_test -outdir swig_test swig_test.i
 javac swig_test/*.java
 export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
 export JNI_CFLAGS=-I${JAVA_HOME}/include -I${JAVA_HOME}/include/
 linux
 gcc -shared ${JNI_CFLAGS} swig_test_wrap.c -o libswig_test.so
 ---cut---

 The swig-generated java itfc file is:
 ---file:swig_test/swig_test.java---
 package swig_test;
 public class swig_test {
   public static int swig_test_whatever() {
     return swig_testJNI.swig_test_whatever();
   }}

 ---cut---

 The clojure code:
 ---cut---
 (import '(swig_test swig_test))

 (System/load
  (.concat (System/getProperty user.dir) /libswig_test.so))
 (swig_test/swig_test_whatever)
 ---cut---
 I get:
 java.lang.UnsatisfiedLinkError:
 swig_test.swig_testJNI.swig_test_whatever()I (NO_SOURCE_FILE:0)

 I can use manually writtenJNIwrappers with clojure and, vice-
 versa, swig-generated wrappers with plain java code. What I'm missing
 here? Anybody can help?

 Bests,
 Antonio, Fabio Di Narzo.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: areduce flaw

2009-04-27 Thread Boris Mizhen

Thanks to all who replied.

To summarize what I learned  - Clojure has a special form (. ) to
*call* java functions, but does not have concept of a *value*
corresponding to a java function.
This makes Java functions a second class citizen :)

In addition special forms are expanded in the first position of the
list, but not on other positions, thus in (foo Math/abs)  Math/abs is
no longer a syntax for a static method, but a lookup of a var 'abs' in
a namespace Math.

Correct?

Regards,
Boris

On Apr 27, 7:28 pm, Timothy Pratley timothyprat...@gmail.com wrote:
  How can I pass a static java function to another function?

 There is also memfn:
 (memfn name  args)
 Macro
 Expands into code that creates a fn that expects to be passed an
 object and any args and calls the named instance method on the object
 passing the args. Use when you want to treat a Java method as a first-
 class fn.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Stack Overflow problem with Maps

2009-04-27 Thread Christophe Grand

Hi Patrick,

Please provide some code.

fitzpatrick...@googlemail.com a écrit :
 I iterate through the list and for each row look up each of the
 heading names in the Heading Info List to get an index of where a
 particular element should be in the Actual Info List and then i go and
 get this from the Actual Info List and use this as part of my key.
 With the key i write the Row Number to the map. If the key is already
 there i just cons it to the exiting map value.
   

Code smell: indexes. Most of the time, if you are using indexes there's 
something wrong in your code.
To work with two parallel lists (heading-info-list and 
actual-info-list), you can either build a map (if your keys are distinct):
  (- (zipmap heading-info-list actual-info-list) (select-keys 
headingnamelist) vals)
or turn the pair of lists into a list of pairs before further processing:
  (map vector heading-info-list actual-info-list)
or directly work in parallel on both lists:
  (map some-fn heading-info-list actual-info-list)

hth,

Christophe


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
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
-~--~~~~--~~--~--~---