Re: Quirk with printing regexps

2013-03-31 Thread Mark Engelberg
On Sun, Mar 31, 2013 at 10:46 PM, Andy Fingerhut
wrote:

> If you print it as a string, then want to read it back in and convert back
> to a regex, you must read it as a string, then call re-pattern on it.  That
> should preserve the original meaning.
>
> Printing it as a string, and trying to read it as a regex by prepending it
> directly with # before the " of the string, would definitely change the
> meaning of the regex in the case you mention, and many many others.
>
> Andy
>
>
Yeah, my goal is simply to get (re-pattern #"a\nb") to print (or more
precisely, pr) as #"a\nb" without affecting the semantics of printing other
regular expressions, but that seems to be impossible to achieve.  Sigh...

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Quirk with printing regexps

2013-03-31 Thread Andy Fingerhut
If you print it as a string, then want to read it back in and convert back
to a regex, you must read it as a string, then call re-pattern on it.  That
should preserve the original meaning.

Printing it as a string, and trying to read it as a regex by prepending it
directly with # before the " of the string, would definitely change the
meaning of the regex in the case you mention, and many many others.

Andy


On Sun, Mar 31, 2013 at 10:33 PM, Mark Engelberg
wrote:

> On Sat, Mar 30, 2013 at 11:33 AM, Mark Engelberg  > wrote:
>
>> On Thu, Mar 28, 2013 at 6:36 PM, Andy Fingerhut > > wrote:
>>
>>> (defn print-regex-my-way [re]
>>>   (print "#regex ")
>>>   (pr (str re)))
>>>
>>> That might be closer to what you want.
>>>
>>
>> Yes.  That does the trick.  That extra level of converting the regular
>> expression to a string does the trick because pr "does the right thing"
>> with strings, but not with regexes.  I'd classify pr's different behavior
>> on regexes as a bug, but this is an effective workaround.
>>
>
> I found a deficiency with the trick of converting the regex to a string
> for printing.
>
> Consider:
> (print-regex-my-way #"\s")
> which will print as
> #regex "\\s"
>
> The extra \ changes the meaning of the regular expression.
>
>
>
>
>
>  --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Quirk with printing regexps

2013-03-31 Thread Mark Engelberg
On Sat, Mar 30, 2013 at 11:33 AM, Mark Engelberg
wrote:

> On Thu, Mar 28, 2013 at 6:36 PM, Andy Fingerhut 
> wrote:
>
>> (defn print-regex-my-way [re]
>>   (print "#regex ")
>>   (pr (str re)))
>>
>> That might be closer to what you want.
>>
>
> Yes.  That does the trick.  That extra level of converting the regular
> expression to a string does the trick because pr "does the right thing"
> with strings, but not with regexes.  I'd classify pr's different behavior
> on regexes as a bug, but this is an effective workaround.
>

I found a deficiency with the trick of converting the regex to a string for
printing.

Consider:
(print-regex-my-way #"\s")
which will print as
#regex "\\s"

The extra \ changes the meaning of the regular expression.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: hash-map initialization issue

2013-03-31 Thread Ryan
Thanks for your input guys

Ryan

On Sunday, March 31, 2013 11:11:08 AM UTC+3, Alex Baranosky wrote:
>
> There's also 'for'
>
> (defn my-function [foo-id a-keyword a-list]  
>   (for [m a-list]
> {:foo_id foo-id (keyword a-keyword) (:BAR_KEY m)})) 
>
>
> On Sun, Mar 31, 2013 at 12:57 AM, JvJ >wrote:
>
>> ...even cheezier, use do
>> #(do {:foo %})
>>
>>
>> On Saturday, 30 March 2013 23:58:31 UTC-4, JvJ wrote:
>>>
>>> Here's a cheezy hack, use identity.
>>>
>>> #(identity {:foo %})
>>>
>>> On Thursday, 28 March 2013 17:51:10 UTC-4, Ryan wrote:

 Thanks for your explanation Jonathan. I am still a bit confused however 
 what is the proper solution here. Should i use an anonymous function 
 instead to do what I want or can it be done with the #() syntax?

 Hyphens is my preferred way as well, but, those keys represent sql 
 columns which they use underscore so I gotta go with underscores in order 
 code to match them :)

 Ryan

 On Thursday, March 28, 2013 11:24:38 PM UTC+2, Jonathan Fischer Friberg 
 wrote:
>
> It's because the #() syntax always calls the content as a function.
>
> So #(...) is the same as (fn [] (...)). In your case, 
> #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)})
> is the same as:
> (fn [%] ({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}))
> Note the extra () around {}. In other words, your map is called
> as a function.
>
> Maps can normally be called as functions, like this:
> ({:hello :world} :hello)
> => :world
> That's why you get the "Wrong number of args" error
> (and not a "a map is not a function" error).
> Hope that makes sense.
>
> Btw, hyphen is normally used instead of underscore
> in both variables and keywords. Just a slight style
> "issue", but maybe you had your reasons. :)
>
> Jonathan
>
>
> On Thu, Mar 28, 2013 at 10:16 PM, Ryan  wrote:
>
>> Hello!
>>
>> I am having a small issue with a hash-map initialization and I am 
>> failing to understand why. I have the following situation:
>>
>> (def a-list '({:BAR_KEY bar-value}, {:BAR_KEY another-value}))
>>
>>
>> (defn my-function [foo-id a-keyword a-list] 
>>
>>   (map #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) a-list))
>>>
>>
>> So, by running the above function like this:
>>
>> (my-function 5 "my_keyword" a-list) 
>>
>>
>> I get the following error:
>>
>> *clojure.lang.ArityException: Wrong number of args (0) passed to: 
>>> PersistentArrayMap*
>>
>>  
>> I am trying to get the following result:
>>
>> ({:foo_id 5 :my_keyword bar-value}, {:foo_id 5 :my_keyword 
>> another-value})
>>
>> Any ideas? I have played around in repl for the last 2 hrs but I 
>> haven't found the proper way to do this.
>>
>> Thank you for your time :)
>>
>>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient 
>> with your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/**group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google 
>> Groups "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to clojure+u...@googlegroups.com.
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out
>> .
>>  
>>  
>>
>
>  -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
-- 
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...@g

[ANN] clj-time 0.5.0 and repo/org change

2013-03-31 Thread Sean Corfield
clj-time 0.5.0 was recently released which includes the following changes:

* update Joda Time to 2.2
* update default version of Clojure to 1.5.1 (still supporting 1.2.1 onward)
* add: last-day-of-the-month, first-day-of-the-month,
number-of-days-in-the-month, today-at and periodic-seq from Michael
Klishin's Quartzite library
* add: do-at from Alex Baranosky's utilize library
* add support for LocalDate

In addition, clj-time has moved to its own organization:

https://github.com/clj-time/clj-time

My fork still exists to maintain any existing links but all new issues
and pull requests should be made against the new org/repo now.

Huge thanks to Michael Klishin for his assistance lately with
clj-time. We're hoping to have much expanded documentation for
clj-time soon and perhaps a dedicated website for this library!

Please also note that there is a dedicated mailing list for users of
clj-time on Google Groups:

http://groups.google.com/group/clj-time
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: no.disassemble, a runtime bytecode disassembler

2013-03-31 Thread Gary Trakhman
Ritz's debugger approach looks much more thorough and doesn't require 
invasive extra dependencies as far as I can tell.  If I had known it 
existed, I probably wouldn't have bothered :-).  One major weakness of my 
approach is it doesn't take into account class-unloading through garbage 
collection of clojure's ethereal classloaders.  One way around that would 
be apply transformations to clojure's dynamic classloaders, and add 
finalizers to do cleanup, but it seems more trouble than it's worth.  The 
jpda approach looks like what I really want.

Still, it's not clear how to use it.  I see a test in 
https://github.com/pallet/ritz/blob/develop/debugger/test/ritz/jpda/disassemble_test.clj#L90

but it appears to be more fine-grained than just grabbing the class of an 
object and dumping the bytecode.  Before I go down the rabbit-hole, is 
there anything like that in ritz's code?

On Saturday, March 30, 2013 2:31:36 PM UTC-4, Hugo Duncan wrote:
>
> Gary Trakhman > writes: 
>
> > I made a little proof of concept last night.  You could always look at 
> > bytecode that clojure emits in few ways, you can either hack the 
> compiler 
> > yourself, or force AOT in your project and use javap.  The first 
> approach 
> > is a bit intrusive, and the second has a somewhat annoying turnaround 
> time, 
> > and won't work for any code that calls eval at runtime. 
> > 
> > This takes another approach.  It uses java's Instrumentation stuff, to 
> > provide a hook into all classloading past the point at which it's 
> loaded, 
> > where I store off all the bytes of defined classes into a big 
> > ConcurrentHashMap.  Then I use eclipse.jdt.core's disassembler 
> > functionality to print out the bytecode. 
>
> The Ritz' disassembler uses jpda to access the bytecode.  Not yet ported 
> to 
> ritz-nrepl though. 
>
> Hugo 
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: Windows installer for Leiningen

2013-03-31 Thread David Powell
> That's correct, now it works! :)
>

Great.  The patch has been accepted by leiningen, so it should be in the
next release.


> IMHO the patch should be just the line 83 of your file, the other
> quoted variables are URLs (which cannot have spaces). Note that
> :DownloadFile, when calls powershell, inverts the order of its
> arguments.
>

The extra quotes seem to be an artifact of passing the arguments on the
command-line.  The actual arguments to the DownloadFile method in .NET
aren't expected to contain quotes.

>From inside powershell itself, this works:

  (new-object System.Net.WebClient).DownloadFile("
https://raw.github.com/technomancy/leiningen/stable/bin/lein.bat";, "with
space\file name.txt")

So the extra quotes probably won't harm on either parameter.

-- 
Dave

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: Windows installer for Leiningen

2013-03-31 Thread Roberto Mannai
On Sun, Mar 31, 2013 at 5:23 PM, David Powell  wrote:

> I think that this patch fixes the issue:
> https://github.com/djpowell/leiningen/commit/bd9e2e25508cfc01889057349b133941ff4fc379
>
> It seems that quotes around powershell parameters on the command-line need
> to be triple-double-quoted :)

That's correct, now it works! :)

IMHO the patch should be just the line 83 of your file, the other
quoted variables are URLs (which cannot have spaces). Note that
:DownloadFile, when calls powershell, inverts the order of its
arguments.

Thanks again,
Roberto

> --
> Dave
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: Windows installer for Leiningen

2013-03-31 Thread David Powell
Hi,

But there is a second problem. It (apparently) tries two save the jar file
> in
> C:\Users\\.lein\self-installs\leiningen-x.y.z-standalone.jar
>
> But it looks like it doesn't deal correctly with spaces in the path. If
> your Username
> were to be "John Doe", only the part in front of the space is used as the
> install path.
>
> So the leiningen jar-file would actually be a file named "John" in the
> directory C:\Users,
> instead of C:\Users\John
> Doe\.lein\self-installs\leiningen-x.y.z-standalone.jar.
>

I think all of these problems, and Robertos issue are caused by the same
lein.bat.  The permissions problem is probably because the spaces in the
profile are causing lein to attempt to write outside of the user profile.

I think that this patch fixes the issue:
https://github.com/djpowell/leiningen/commit/bd9e2e25508cfc01889057349b133941ff4fc379

It seems that quotes around powershell parameters on the command-line need
to be triple-double-quoted :)

-- 
Dave

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: Windows installer for Leiningen

2013-03-31 Thread Kemar
Using lein.bat with powershell I found two issues:

First, there is the aforementioned
  {param($a,$f) (new-object System.Net.WebClient).DownloadFile  ($a, 
$f)}
DotNetMethodException.

This could be solved by starting the Command Prompt as an Administrator
(shift + right-click on the cmd.exe, then "Run as administrator").

Then it's able to download the leiningen jar-file.

But there is a second problem. It (apparently) tries two save the jar file 
in
C:\Users\\.lein\self-installs\leiningen-x.y.z-standalone.jar

But it looks like it doesn't deal correctly with spaces in the path. If 
your Username
were to be "John Doe", only the part in front of the space is used as the 
install path.

So the leiningen jar-file would actually be a file named "John" in the 
directory C:\Users,
instead of C:\Users\John 
Doe\.lein\self-installs\leiningen-x.y.z-standalone.jar.

I hope this helps :-)


Am Sonntag, 31. März 2013 16:08:46 UTC+2 schrieb David Powell:
>
>
> powershell -Command "& {param($a,$f) 
>> (new-object System.Net.WebClient).DownloadFile($a, $f)}" %~2 %~1
>>
>
> Ah, yeah.  %~1 and %~2 strip the quotes off the parameters, which isn't a 
> good idea.
> Something like this should work:
>  
>
>> powershell -Command "& {param($a,$f) 
>> (new-object System.Net.WebClient).DownloadFile($a, $f)}" "%~2" "%~1"
>>
>  
>
>> [I can't believe both that in 2013 MS Windows does not handle such
>> cases, and that Windows Administrators still create User profiles with
>> spaces inside]
>>
>
> To be fair, whilst batch file syntax is horrible, it is more a lein.bat 
> problem in this case.  If we pass two parameters without quotes, and one 
> has spaces in, it isn't surprising that it gets interpreted wrongly.
>
> I'll submit a patch to fix the handling of profiles with spaces in them in 
> lein.bat
>
>
> -- 
> Dave
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: Windows installer for Leiningen

2013-03-31 Thread David Powell
> powershell -Command "& {param($a,$f)
> (new-object System.Net.WebClient).DownloadFile($a, $f)}" %~2 %~1
>

Ah, yeah.  %~1 and %~2 strip the quotes off the parameters, which isn't a
good idea.
Something like this should work:


> powershell -Command "& {param($a,$f)
> (new-object System.Net.WebClient).DownloadFile($a, $f)}" "%~2" "%~1"
>


> [I can't believe both that in 2013 MS Windows does not handle such
> cases, and that Windows Administrators still create User profiles with
> spaces inside]
>

To be fair, whilst batch file syntax is horrible, it is more a lein.bat
problem in this case.  If we pass two parameters without quotes, and one
has spaces in, it isn't surprising that it gets interpreted wrongly.

I'll submit a patch to fix the handling of profiles with spaces in them in
lein.bat


-- 
Dave

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: Windows installer for Leiningen

2013-03-31 Thread Roberto Mannai
C:\Users\Roberto Mannai\.lein\bin>powershell -Command echo $host.version
Major  Minor  Build  Revision
-  -  -  
2  0  -1 -1


I'm doing some test, the problem seems to be this line:

powershell -Command "& {param($a,$f) (new-object
System.Net.WebClient).DownloadFile($a, $f)}" %~2 %~1

Where %~1 points to a path with a space inside:
C:\Users\Roberto
Mannai\.lein\self-installs\leiningen-2.1.2-standalone.jar.pending

[I can't believe both that in 2013 MS Windows does not handle such
cases, and that Windows Administrators still create User profiles with
spaces inside]

It should be enough to do a smarter string concation; I'll try later.

Thanks again,
Roberto


On Sun, Mar 31, 2013 at 3:45 PM, David Powell  wrote:
> Also, can you check what version of powershell you have?
>
>   powershell -Command echo $host.version
>
> --
> Dave
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: Windows installer for Leiningen

2013-03-31 Thread David Powell
Also, can you check what version of powershell you have?

  powershell -Command echo $host.version

-- 
Dave

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: Windows installer for Leiningen

2013-03-31 Thread David Powell
Interesting.  Yes this is a problem with lein.bat rather than the installer.

Leiningen recently added support for powershell because it was assumed that
powershell would always be installed, but in fact that isn't the case.  The
installer bundles curl as a fallback for when powershell isn't installed.

The error suggests that you have powershell installed, but that it isn't
working for some reason.

Could you tell me what version of windows you are using?  Do you have any
unusual network setup - eg, are you behind a proxy?

Did the installer successfully download lein.bat to ~/.lein/bin/lein.bat?

Can you see if this command completes without errors:

  curl "
https://leiningen.s3.amazonaws.com/downloads/leiningen-2.1.2-standalone.jar";
-o test.jar


If powershell is going to be a problem, then it might be easier for
leiningen to lower powershell below curl in the priority list.

-- 
Dave

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




What's the difference between a "sequence" and a "seq"?

2013-03-31 Thread Alice
On http://clojure.org/lazier,

  Changed: (rest aseq) - returns a logical collection (Sequence) of
the remaining items, not (necessarily) a seq

rest simply calls RT.more and here's the code of RT.more:

  static public ISeq more(Object x){
if(x instanceof ISeq)
  return ((ISeq) x).more();
ISeq seq = seq(x);
if(seq == null)
  return PersistentList.EMPTY;
return seq.more();
  }

So, it seems to return just a seq and not some logical collection?

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: Windows installer for Leiningen

2013-03-31 Thread Roberto Mannai
Hello,

Should one have Powershell pre-installed? The wizard does not complete
successfully the "self-install" step, although it seems as it is not
aware of it.

When running "lein self-install" manually, I get a
DotNetMethodException (*). Now I'd guess this is an issue of lein.bat,
not of your installer, anyway it would be nice if your package could
embed all the hidden dependencies, as it already does for "curl.exe".

Kind regards,
Roberto

(*)
C:\Users\Roberto Mannai\.lein\bin>lein self-install
Downloading Leiningen now...
Eccezione durante la chiamata di "DownloadFile" con "2" argomento/i:
"Eccezione  durante una richiesta WebClient."
In riga:1 car:63
+ & {param($a,$f) (new-object System.Net.WebClient).DownloadFile  ($a, $f)}
 https://leiningen.s3.amazonaws.com/downloads/leiningen-2.1.2-standalone.jar C:
\Users\Roberto Mannai\.lein\self-installs\leiningen-2.1.2-standalone.jar.pendin
g
+ CategoryInfo  : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException



On Sat, Mar 30, 2013 at 6:39 PM, David Powell  wrote:
> Hi,
>
> I've put together an installer for Leiningen on Windows:
> http://leiningen-win-installer.djpowell.net/
>
> Hopefully it should make it a bit easier for Windows people to get Leiningen
> and a Clojure repl up and running.
>
> It requires a JDK to be installed first, but other than that there aren't
> any dependencies.
> It should work on Windows XP and above, 32-bit or 64-bit.  With or without
> powershell available.
>
> The installer should take the hassle out of setting up paths and environment
> variables, and changing them when new JDKs are installed.
>
> The current version is beta1.  If you've got any feedback then give me an
> email.
>
> --
> Dave
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Persistent Data Structures for Objective-C/LLVM

2013-03-31 Thread Matthias Benkard
I implemented persistent, array-mapped Patricia trees in C a while ago:

https://matthias.benkard.de/journal/118

It should be relatively straight-forward to build some Objective-C classes 
on top of that.  (There's a reason the memory management routines are named 
bpt_{retain, release, dealloc}. :))

You'll just need to do the hashing yourself if you want to build a hash map.

Matthias

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Invoke a specific multimethod

2013-03-31 Thread Chas Emerick
Just copy/paste from my Counterclockwise REPL. :-)

- Chas

On Mar 30, 2013, at 11:54 PM, JvJ wrote:

> Also, nice syntax highlighting!  How'd you do that?
> 
> On Saturday, 30 March 2013 23:54:03 UTC-4, JvJ wrote:
> get-method.  Thanks, that was exactly what I was looking for!
> 
> On Saturday, 30 March 2013 07:20:54 UTC-4, Chas Emerick wrote:
> On Mar 30, 2013, at 12:00 AM, George Oliver wrote:
> 
>> 
>> 
>> On Friday, March 29, 2013 6:19:19 PM UTC-7, JvJ wrote:
>> Is it possible to invoke a particular multimethod and bypass the dispatch 
>> function?
>> 
>> For instance, suppose that I have a multimethod with a dispatch value of 
>> ::foo, and it's a really complex method.
>> 
>> Now, I want all cases where the dispatch function returns nil to use the 
>> same multimethod.  Is there a way I can intercept the nil and
>> pass it directly on to the ::foo multimethod?
>> 
>> You could use the default multimethod to catch nil, and then call the multi 
>> with ::foo. 
> 
> That will only work if the dispatch fn is identity or similar.
> 
> If you control the dispatch fn, then you don't need to "intercept nil" -- 
> just returning ::foo from the dispatch fn when it might otherwise return nil 
> will get you to the method you want.
> 
> If you *don't* control the dispatch fn, but you're providing the methods for 
> :foo and nil, then you can use `get-method` to obtain the method associated 
> with a particular dispatch value:
> 
> => (defmulti foo :bar)
> #'user/foo
> => (defmethod foo :baz
>  [x]
>  (str x))
> #
> => (defmethod foo :default
>  [x]
>  ((get-method foo :baz) x))
> #
> => (foo {:bar :baz})
> "{:bar :baz}"
> => (foo {:some :other :value :here})
> "{:some :other, :value :here}"
> 
> Of course, if the functionality you need is available as a separate top-level 
> fn, and you can avoid the extra effective dispatch through the multimethod, 
> all the better.
> 
> Cheers,
> 
> - Chas
> 
> 
> -- 
> -- 
> 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 unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: hash-map initialization issue

2013-03-31 Thread Alex Baranosky
There's also 'for'

(defn my-function [foo-id a-keyword a-list]
  (for [m a-list]
{:foo_id foo-id (keyword a-keyword) (:BAR_KEY m)}))


On Sun, Mar 31, 2013 at 12:57 AM, JvJ  wrote:

> ...even cheezier, use do
> #(do {:foo %})
>
>
> On Saturday, 30 March 2013 23:58:31 UTC-4, JvJ wrote:
>>
>> Here's a cheezy hack, use identity.
>>
>> #(identity {:foo %})
>>
>> On Thursday, 28 March 2013 17:51:10 UTC-4, Ryan wrote:
>>>
>>> Thanks for your explanation Jonathan. I am still a bit confused however
>>> what is the proper solution here. Should i use an anonymous function
>>> instead to do what I want or can it be done with the #() syntax?
>>>
>>> Hyphens is my preferred way as well, but, those keys represent sql
>>> columns which they use underscore so I gotta go with underscores in order
>>> code to match them :)
>>>
>>> Ryan
>>>
>>> On Thursday, March 28, 2013 11:24:38 PM UTC+2, Jonathan Fischer Friberg
>>> wrote:

 It's because the #() syntax always calls the content as a function.

 So #(...) is the same as (fn [] (...)). In your case,
 #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)})
 is the same as:
 (fn [%] ({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}))
 Note the extra () around {}. In other words, your map is called
 as a function.

 Maps can normally be called as functions, like this:
 ({:hello :world} :hello)
 => :world
 That's why you get the "Wrong number of args" error
 (and not a "a map is not a function" error).
 Hope that makes sense.

 Btw, hyphen is normally used instead of underscore
 in both variables and keywords. Just a slight style
 "issue", but maybe you had your reasons. :)

 Jonathan


 On Thu, Mar 28, 2013 at 10:16 PM, Ryan  wrote:

> Hello!
>
> I am having a small issue with a hash-map initialization and I am
> failing to understand why. I have the following situation:
>
> (def a-list '({:BAR_KEY bar-value}, {:BAR_KEY another-value}))
>
>
> (defn my-function [foo-id a-keyword a-list]
>
>   (map #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) a-list))
>>
>
> So, by running the above function like this:
>
> (my-function 5 "my_keyword" a-list)
>
>
> I get the following error:
>
> *clojure.lang.ArityException: Wrong number of args (0) passed to:
>> PersistentArrayMap*
>
>
> I am trying to get the following result:
>
> ({:foo_id 5 :my_keyword bar-value}, {:foo_id 5 :my_keyword
> another-value})
>
> Any ideas? I have played around in repl for the last 2 hrs but I
> haven't found the proper way to do this.
>
> Thank you for your time :)
>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient
> with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/**group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+u...@googlegroups.com.
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>

  --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an em

Re: hash-map initialization issue

2013-03-31 Thread JvJ
...even cheezier, use do
#(do {:foo %})

On Saturday, 30 March 2013 23:58:31 UTC-4, JvJ wrote:
>
> Here's a cheezy hack, use identity.
>
> #(identity {:foo %})
>
> On Thursday, 28 March 2013 17:51:10 UTC-4, Ryan wrote:
>>
>> Thanks for your explanation Jonathan. I am still a bit confused however 
>> what is the proper solution here. Should i use an anonymous function 
>> instead to do what I want or can it be done with the #() syntax?
>>
>> Hyphens is my preferred way as well, but, those keys represent sql 
>> columns which they use underscore so I gotta go with underscores in order 
>> code to match them :)
>>
>> Ryan
>>
>> On Thursday, March 28, 2013 11:24:38 PM UTC+2, Jonathan Fischer Friberg 
>> wrote:
>>>
>>> It's because the #() syntax always calls the content as a function.
>>>
>>> So #(...) is the same as (fn [] (...)). In your case, 
>>> #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)})
>>> is the same as:
>>> (fn [%] ({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}))
>>> Note the extra () around {}. In other words, your map is called
>>> as a function.
>>>
>>> Maps can normally be called as functions, like this:
>>> ({:hello :world} :hello)
>>> => :world
>>> That's why you get the "Wrong number of args" error
>>> (and not a "a map is not a function" error).
>>> Hope that makes sense.
>>>
>>> Btw, hyphen is normally used instead of underscore
>>> in both variables and keywords. Just a slight style
>>> "issue", but maybe you had your reasons. :)
>>>
>>> Jonathan
>>>
>>>
>>> On Thu, Mar 28, 2013 at 10:16 PM, Ryan  wrote:
>>>
 Hello!

 I am having a small issue with a hash-map initialization and I am 
 failing to understand why. I have the following situation:

 (def a-list '({:BAR_KEY bar-value}, {:BAR_KEY another-value}))


 (defn my-function [foo-id a-keyword a-list] 

   (map #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) a-list))
>

 So, by running the above function like this:

 (my-function 5 "my_keyword" a-list) 


 I get the following error:

 *clojure.lang.ArityException: Wrong number of args (0) passed to: 
> PersistentArrayMap*

  
 I am trying to get the following result:

 ({:foo_id 5 :my_keyword bar-value}, {:foo_id 5 :my_keyword 
 another-value})

 Any ideas? I have played around in repl for the last 2 hrs but I 
 haven't found the proper way to do this.

 Thank you for your time :)

  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

>>>
>>>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.