Re: NoClassDefFoundError after I import with use on the repl?

2014-02-07 Thread larry google groups

I am grateful to you for testing. Your feedback sent me down a different 
road which lead me to the answer. I decided the repl was for some reason 
not working, so I thought I would run lein uberjar and see how the app 
ran, but when I ran lein uberjar I saw that I had an error that kept the 
app from compiling. When I fixed that I restarted the repl, and then things 
worked correctly at the repl. 

My setup is nearly identical to yours. 


On Friday, February 7, 2014 1:22:42 AM UTC-5, Andy Fingerhut wrote:

 I tried to reproduce this behavior with the following environment, and 
 didn't get this error.  You may want to provide similar information for 
 your environment in case it helps someone else track down the problem:

 Mac OS X 10.8.5
 Oracle Java 1.7.0_15
 Clojure 1.5.1
 Leiningen 2.3.4
 The following in my project.clj dependencies: [me.raynes/fs 1.4.3]

 Andy


 On Thu, Feb 6, 2014 at 9:11 PM, larry google groups 
 lawrenc...@gmail.comjavascript:
  wrote:

 I imagine this question has been asked a million times before, but I can 
 not find the answer. 

 I was looking at Raynes/fs library:

 https://github.com/Raynes/fs/blob/master/src/me/raynes/fs.clj

 I wanted to check and see if iterate-dir returned a seq of strings 
 (paths) or a seq of File objects (or a seq of something else). So at the 
 repl I: 

 (use 'me.raynes.fs)

 and, as a test, I run this on my home directory on my Mac: 

 (def all-from-dir (iterate-dir /Users/larry/))  

 but I get: 

 NoClassDefFoundError me/raynes/fs$iterzip$fn__8508  me.raynes.fs/iterzip 
 (fs.clj:329)

 While iterate-dir is public, iterzip is private. I assume I am 
 getting this error because iterzip is private, but how am I suppose to 
 work around that? I am calling a public function, why is it not able to 
 call a private function from the namespace where I imported it from? 

 I also tried: 

 (require '[me.raynes.fs :as fsss])

 (def all-from-dir (fsss/iterate-dir /Users/larry/))  

 but I got the same error. 

 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 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 javascript:
 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 javascript:.
 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.


Need help interfacing with ruby digest(hmac-sha256)

2014-02-07 Thread Haim Ashkenazi
Hi

I'm trying to interface with a web service that expects a base64 code
produced as followed (I included both the direct output of digest and the
base64 encoding):

require 'openssl'
digest = OpenSSL::Digest::Digest.new('sha256')
OpenSSL::HMAC.digest(digest, key, string)
=
\x97\xD1[\xEA\xBA\x06\r\a8\xECu\x9E\xA3\x18e\x17\x8A\xB8\xBBx\e-!\adK\xA8\x81\xF3\x99\xD8\xD6
Base64.encode64(OpenSSL::HMAC.digest(digest, key, string))
= l9Fb6roGDQc47HWeoxhlF4q4u3gbLSEHZEuogfOZ2NY=\n


I need to send the base64 encoded string to the web service. I tried with
pandec and base64-clj:

✓ ~ ➤ lein try [pandect] [base64-clj]
...
user= (require '[base64-clj.core :as base64])
nil
user= (require '[pandect.core :as p])
nil
user= (p/sha256-hmac string key)
97d15beaba060d0738ec759ea31865178ab8bb781b2d2107644ba881f399d8d6
user= (base64/encode (p/sha256-hmac string key))
OTdkMTViZWFiYTA2MGQwNzM4ZWM3NTllYTMxODY1MTc4YWI4YmI3ODFiMmQyMTA3NjQ0YmE4ODFmMzk5ZDhkNg==

As you can see the generated sha-256 is similar to the ruby digest, but
it's not the same and the base64 is completely different. I've also tried
using javax.crypto.Mac directly but it's the same:

(defn- secret-key-inst [key mac]
  (SecretKeySpec. (.getBytes key) (.getAlgorithm mac)))

(defn- sign* [key string]
  Returns the signature of a string with a given
  key, using a SHA-256 HMAC.
  (let [mac (Mac/getInstance HMACSHA256)
secretKey (secret-key-inst key mac)]
(- (doto mac
  (.init secretKey)
  (.update (.getBytes string)))
.doFinal)))

(defn sign [key string]
  (let [bytes (sign* key string)]
(apply str (map #(format 2%x %) bytes

Does anybody has an idea of how can I produce the same result as ruby? I
really don't want to resort to calling jruby snippet from clojure :(

Thanks
-- 
Haim

-- 
You 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: Need help interfacing with ruby digest(hmac-sha256)

2014-02-07 Thread Thomas Heller
Just a quick guess but it seems like the ruby version base64 encodes the 
BINARY version of the digest, while the clojure version encodes the HEX 
version of the digest.

The sign function also converts to hex, so if you put that into base64 
encode you get the same (wrong) result, use the returned bytes of .doFinal 
and use that to generate the base64 and you should be fine.

HTH,
/thomas

On Friday, February 7, 2014 10:08:27 AM UTC+1, babysnakes wrote:

 Hi

 I'm trying to interface with a web service that expects a base64 code 
 produced as followed (I included both the direct output of digest and the 
 base64 encoding):

 require 'openssl'
 digest = OpenSSL::Digest::Digest.new('sha256')
 OpenSSL::HMAC.digest(digest, key, string)
 = 
 \x97\xD1[\xEA\xBA\x06\r\a8\xECu\x9E\xA3\x18e\x17\x8A\xB8\xBBx\e-!\adK\xA8\x81\xF3\x99\xD8\xD6
 Base64.encode64(OpenSSL::HMAC.digest(digest, key, string))
 = l9Fb6roGDQc47HWeoxhlF4q4u3gbLSEHZEuogfOZ2NY=\n


 I need to send the base64 encoded string to the web service. I tried with 
 pandec and base64-clj:

 ✓ ~ ➤ lein try [pandect] [base64-clj]
 ...
 user= (require '[base64-clj.core :as base64])
 nil
 user= (require '[pandect.core :as p])
 nil
 user= (p/sha256-hmac string key)
 97d15beaba060d0738ec759ea31865178ab8bb781b2d2107644ba881f399d8d6
 user= (base64/encode (p/sha256-hmac string key))

 OTdkMTViZWFiYTA2MGQwNzM4ZWM3NTllYTMxODY1MTc4YWI4YmI3ODFiMmQyMTA3NjQ0YmE4ODFmMzk5ZDhkNg==

 As you can see the generated sha-256 is similar to the ruby digest, but 
 it's not the same and the base64 is completely different. I've also tried 
 using javax.crypto.Mac directly but it's the same:

 (defn- secret-key-inst [key mac]
   (SecretKeySpec. (.getBytes key) (.getAlgorithm mac)))

 (defn- sign* [key string]
   Returns the signature of a string with a given
   key, using a SHA-256 HMAC.
   (let [mac (Mac/getInstance HMACSHA256)
 secretKey (secret-key-inst key mac)]
 (- (doto mac
   (.init secretKey)
   (.update (.getBytes string)))
 .doFinal)))

 (defn sign [key string]
   (let [bytes (sign* key string)]
 (apply str (map #(format 2%x %) bytes

 Does anybody has an idea of how can I produce the same result as ruby? I 
 really don't want to resort to calling jruby snippet from clojure :(

 Thanks
 -- 
 Haim
  

-- 
You 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: Need help interfacing with ruby digest(hmac-sha256)

2014-02-07 Thread Haim Ashkenazi
Thanks. This solved the problem :)

Bye


On Fri, Feb 7, 2014 at 12:57 PM, Thomas Heller th.hel...@gmail.com wrote:

 Just a quick guess but it seems like the ruby version base64 encodes the
 BINARY version of the digest, while the clojure version encodes the HEX
 version of the digest.

 The sign function also converts to hex, so if you put that into base64
 encode you get the same (wrong) result, use the returned bytes of .doFinal
 and use that to generate the base64 and you should be fine.

 HTH,
 /thomas


 On Friday, February 7, 2014 10:08:27 AM UTC+1, babysnakes wrote:

 Hi

 I'm trying to interface with a web service that expects a base64 code
 produced as followed (I included both the direct output of digest and the
 base64 encoding):

 require 'openssl'
 digest = OpenSSL::Digest::Digest.new('sha256')
 OpenSSL::HMAC.digest(digest, key, string)
 = \x97\xD1[\xEA\xBA\x06\r\a8\xECu\x9E\xA3\x18e\x17\x8A\xB8\
 xBBx\e-!\adK\xA8\x81\xF3\x99\xD8\xD6
 Base64.encode64(OpenSSL::HMAC.digest(digest, key, string))
 = l9Fb6roGDQc47HWeoxhlF4q4u3gbLSEHZEuogfOZ2NY=\n


 I need to send the base64 encoded string to the web service. I tried with
 pandec and base64-clj:

 ✓ ~ ➤ lein try [pandect] [base64-clj]
 ...
 user= (require '[base64-clj.core :as base64])
 nil
 user= (require '[pandect.core :as p])
 nil
 user= (p/sha256-hmac string key)
 97d15beaba060d0738ec759ea31865178ab8bb781b2d2107644ba881f399d8d6
 user= (base64/encode (p/sha256-hmac string key))
 OTdkMTViZWFiYTA2MGQwNzM4ZWM3NTllYTMxODY1MTc4YWI4YmI3ODFiMmQy
 MTA3NjQ0YmE4ODFmMzk5ZDhkNg==

 As you can see the generated sha-256 is similar to the ruby digest, but
 it's not the same and the base64 is completely different. I've also tried
 using javax.crypto.Mac directly but it's the same:

 (defn- secret-key-inst [key mac]
   (SecretKeySpec. (.getBytes key) (.getAlgorithm mac)))

 (defn- sign* [key string]
   Returns the signature of a string with a given
   key, using a SHA-256 HMAC.
   (let [mac (Mac/getInstance HMACSHA256)
 secretKey (secret-key-inst key mac)]
 (- (doto mac
   (.init secretKey)
   (.update (.getBytes string)))
 .doFinal)))

 (defn sign [key string]
   (let [bytes (sign* key string)]
 (apply str (map #(format 2%x %) bytes

 Does anybody has an idea of how can I produce the same result as ruby? I
 really don't want to resort to calling jruby snippet from clojure :(

 Thanks
 --
 Haim

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




-- 
Haim

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


ISeq documentation and mutual deftypes.

2014-02-07 Thread Phillip Lord


I've been playing with some code recently. I was wondering how hard
would it be to implement, for example ISeq in clojure. The plan was to
use deftype and a few bits of other code. 

The ISeq interface looks like this:

public interface ISeq extends IPersistentCollection {

Object first();

ISeq next();

ISeq more();

ISeq cons(Object o);

}


And here is the problem -- it looks exactly like this! There is no
documentation. While first and cons are guessable, I am still not sure
of the difference between next and more. Likewise, IPersistentCollection
has equiv and empty -- guessable again.

The other question: is it possible to have two mutually refering deftype
definitions.

So

(deftype Alice ()
   (other [] (Brian.)))

(deftype Brian ()
   (other [] (Alice.)))

The closest I have got it:

(declare create-alice)
(declare create-brian)

(deftype Alice ()
(other [] (create-brian)))
(deftype Brian ()
(other [] (create-alice)))

The last could be

(deftype Brian ()
(other [] (Alice.)))

but the symmetry seemed good.

-- 
You 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: Parsing Clojure with instaparse: how to handle special forms?

2014-02-07 Thread Reid McKenzie
Okay. So there's one big thing you're doing wrong here just from reading 
your grammars: you are complecting the datastructures and valid _tokens_ 
which make up the clojure language with the _meaing_ associated therewith 
by the language. If you discard such things as destructuring as part of 
the grammar and instead just provide the parse grammars for basic 
datastructures like symbols, maps, keywords sets and soforth it's trivial 
to produce a grammar which can _parse_ valid clojure code. _Reading_ 
clojure code from such a parse tree is and should be an entirely seperate 
concern, implemented as a pass over the generated parse structure.

- Reid

On Thursday, February 6, 2014 9:28:08 PM UTC-6, Travis Moy wrote:

 I'm trying to use instaparse to parse Clojure code so that I can reformat 
 it, but I'm having an issue with how to handle special forms. Should I 
 attempt to parse special forms such as let and defn into their own rules, 
 or should I rely instead on the actual content of the terminal to determine 
 what lists should be treated as special forms?

 For example, let's say I want to write a function which takes the parse 
 tree returned by instaparse and arranges all the let bindings as 
 recommended by the Clojure style guide (
 https://github.com/bbatsov/clojure-style-guide#source-code-layout--organization).
  
 There are two approaches I could take:

 1) Build the recognition into the grammar itself:

 S = Form*

 Form = !SpecialForm List | ReaderMacro | Literal | Vector | Map | 
  SpecialForm | !SpecialForm Symbol
 
 List = '(' Form* ')'

...

 SpecialForm = defn | let | try | JavaMemberAccess | JavaConstructor
 defn = '(' defn Symbol String? MapMetadata? VectorDestructuring 
 Form* ')'

 Destructuring = VectorDestructuring | MapDestructuring
 VectorDestructuring = '[' (Symbol | Destructuring)* ('' (Symbol | 
 Destructuring))? ']'
 MapDestructuring = Map


 2) Don't try to detect the let bindings in the grammar. Instead, search 
 the resulting parse tree for lists with let content.

 Which of these is a better approach? I sadly didn't take compilers in 
 college so I'm kind of playing this by ear; I'm sure if I had I'd have a 
 better idea of what the best practice is here.

 Thanks!

 (Full code for my project is at 
 https://github.com/MoyTW/clojure-toys/tree/master/formatter if needed)



-- 
You 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: GSoC 2014: We need ideas and mentors

2014-02-07 Thread Nikita Beloglazov
Hi 

I don't have editing rights for wiki so I post project idea here:
*Quil on ClojureScript**Brief explanation: *Quilhttp://github.com/quil/quilis 
a drawing and animation library for clojure. It is basically wrapper 
over Processing http://processing.org. Currently Quil works only on 
vanilla clojure (JVM based). It would be cool to have it also on 
ClojureScript. Processing already have javascript version: 
Processing.jshttp://processingjs.org, 
so it can be used for our goals.*Expected results: *quil clojurescript 
library capable of running regular quil sketches, documentation how to use 
it in clojurescript project.*Knowledge prerequisites: *familiarity with 
clojurescript, javascript*Skill level: *medium*Mentor: *Nikita Beloglazov 
(nikelandj...@gmail.com)

Thank you,
Nikita

On Wednesday, February 5, 2014 6:19:55 PM UTC, Daniel Solano Gómez wrote:

 Hello, all, 

 It's time once again to prepare our application for Google Summer of 
 Code, a program where Google pays students from around the world to work 
 on open source projects.  Clojure has successfully participated in the 
 program for two years now, and I would love to make it a third.  GSoC 
 has helped projects like Typed Clojure, Clojure in Clojure, Clojure 
 on Android, core.matrix, and ClojureScript. 

 In order to have a strong application, we need you to help populate our 
 project ideas page [1].  You can also review the ideas for 2012 [2] and 
 2013 [3] to help you come up with new ideas.  Having a great ideas page 
 is key to a successful application, and having many members from the 
 community participate as potential mentors will be a big boost.  At this 
 point, you are not committing to anything—we just need your ideas. 

 If you don't have edit rights to the wiki and don't want to sign up for 
 an account, just post to the mailing list using '[GSoC Idea]' in the 
 subject line, and I'll add it for you. 

 Lastly, if you would like to review the answers to the organization 
 application [4], I would appreciate the input. 

 The application deadline the 14th of February. 

 Thank you for time and ideas. 

 Sincerely, 

 Daniel 


 [1]: http://dev.clojure.org/display/community/Project+Ideas 
 [2]: http://dev.clojure.org/display/community/Google+Summer+of+Code+2012 
 [3]: http://dev.clojure.org/display/community/Project+Ideas+2013 
 [4]: 
 http://dev.clojure.org/display/community/Mentoring+Organization+Application 


-- 
You 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] durable-queue: an in-process disk-backed queue

2014-02-07 Thread Bob Hutchison

On Feb 6, 2014, at 6:45 PM, Zach Tellman z...@factual.com wrote:

 At Factual we get a lot of data thrown at us, and often don't have control 
 over the rate at which it comes in.  As such, it's preferable that our buffer 
 isn't bounded by the process' memory, since a temporary blip in throughput 
 may cause GC pauses, OOM exceptions, and other things that will only 
 exacerbate the problem.  It's also preferable that if the process dies, we 
 won't lose any data which hasn't yet escaped the process.  A disk-backed 
 queue satisfies both of these requirements.
 
 As such, I'm happy to announce that we're open sourcing 'durable-queue': 
 https://github.com/Factual/durable-queue.  It's a small, fast, pure-Clojure 
 implementation that in our production systems is responsible for processing 
 billions of entries daily.  We believe it has broad applications, and are 
 excited to see how others will use it.

What excellent timing! I've been looking at ZeroMQ, RabbitMQ, and Kafka for the 
last week or so. ZMQ is awfully attractive for what I'm trying to do, but there 
are a few things it doesn't do that I need done. I had begun thinking of 
building something similar on top of Redis.

You mention the idea of batching to reduce the impact of fsync. Is there an API 
for batching puts? Is there a way to batch a complete! and put! new tasks to 
the queue?

One pattern that keeps coming up is:
   - take a single task from the queue
   - execute the task, which might generate a set of new tasks to be queued on 
the same queue (and likely on other queues too)
   - signal completion, and put the new tasks

Cheers,
Bob

 
 Zach
 
 P.S. If this sort of work is interesting to you, Factual is hiring: 
 https://groups.google.com/forum/#!searchin/clojure/factual/clojure/8bPIEnNpfyQ/lvv-9gkVozAJ
 
 -- 
 You 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] clara-rules 0.4 released

2014-02-07 Thread Michael Fogus
 The theme of this release is rules as data

Yay!

Great job Ryan.  I look forward to checking out your changes.


On Thu, Feb 6, 2014 at 10:15 PM, Ryan Brush rbr...@gmail.com wrote:
 The 0.4.0 release of Clara is up on Clojars. The github page is at [1].

 The theme of this release is rules as data, which I wrote about at [2]. In
 a nutshell, all rules and the Rete network itself are defined by
 well-defined data structures (via Prismatic Schema), which opens a lot of
 doors:

 * Alternate front ends to Clara can now be written, generating rules in the
 schema-compliant format. If the defrule-style DSL isn't your thing, you
 can generate rules via any mechanism you want.
 * Tooling can now be written to inspect the rules and their relationships,
 with some examples in the blog at [2].
 * The Rete network itself is also a schema-defined data structure, opening
 the door for visualizing the working memory itself.

 There are some breaking changes for the ClojureScript support: I moved the
 logic to generate a Rete network in ClojureScript to be driven at compile
 time...meaning we can assemble an optimized network on the server, rather
 than having the client do that computation every time it loads. Details and
 an example are linked at [3]. I haven't yet used the ClojureScript version
 in anger, but am maintaining it because there is interest and it's cool to
 see this running in a browser. ;)

 I expect future releases to be smaller and more frequent. Getting Clara on a
 solid basis of well-defined structures was a significant effort, but I think
 it puts it in a stronger position with a number of advantages over existing
 rule engines.

 [1]
 https://github.com/rbrush/clara-rules
 [2]
 http://www.toomuchcode.org/blog/2014/01/19/rules-as-data/
 [3]
 https://github.com/rbrush/clara-rules/wiki/ClojureScript

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



-- 
-- http://blog.fogus.me
-- http://github.com/fogus
--

-- 
You 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: Alternative - macro for threading sequences?

2014-02-07 Thread Korny Sietsma
I tend to agree, I think.  I certainly can't think of a syntax that would
make me happy.  It just feels like a bit of a smell that I keep using -
to process sequences in similar ways.

The data.zip xml- macro is an example of something like what I'm
thinking about - it lets you process sequences of xml data nicely:
http://clojure.github.io/data.zip/#clojure.data.zip.xml/xml-

... but I can't see a way to use something similar for the sort of data I'm
processing.  I'll let this percolate, and stick to just using lots of (map)
and (filter) instead.

- Korny


On 6 February 2014 18:34, Jozef Wagner jozef.wag...@gmail.com wrote:

 I agree with Colin, the cognitive load is greater than benefits of such
 approach. BTW you can use comp to chain consecutive map transformation
 functions. (map (comp pacify wrangle) things)

 JW


 On Thu, Feb 6, 2014 at 3:40 PM, Korny Sietsma ko...@sietsma.com wrote:

  Hi folks,

 I seem to regularly find myself writing - threaded code that follows
 similar patterns:

 (- things
 (map wrangle)
 (map pacify)
 (filter effable)
 (map #(aggravate % :bees :sharks))
 (reduce mapinate {})

 i.e. all stages of the code actually operate on a collection rather than
 a single value - usually with a call to map at each stage.  This example
 is over simplified - often many of the calls to map are inline functions,
 which makes this even more verbose.

 I wonder if there would be value in (yet another) variant on '-' that
 assumes you are threading a collection and calling 'map' by default.  I'm
 not sure of the syntax that would work though.  Something like:

 ([]- things
 wrangle
 pacify
 [:filter effable]
 (aggravate :bees :sharks)
 [:reduce mapinate {}])

 I'm not sure about the syntax for non-map functions, I'm not even sure if
 this is worthwhile.  Thoughts?

 - Korny

 --
 Kornelis Sietsma  korny at my surname dot com http://korny.info
 .fnord { display: none !important; }

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




-- 
Kornelis Sietsma  korny at my surname dot com http://korny.info
.fnord { display: none !important; }

-- 
You 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: GSoC 2014: We need ideas and mentors

2014-02-07 Thread Ambrose Bonnaire-Sergeant
Thank Nikita, added.

Ambrose


On Fri, Feb 7, 2014 at 9:17 PM, Nikita Beloglazov nikelandj...@gmail.comwrote:

 Hi

 I don't have editing rights for wiki so I post project idea here:
 *Quil on ClojureScript**Brief explanation: 
 *Quilhttp://github.com/quil/quilis a drawing and animation library for 
 clojure. It is basically wrapper
 over Processing http://processing.org. Currently Quil works only on
 vanilla clojure (JVM based). It would be cool to have it also on
 ClojureScript. Processing already have javascript version: 
 Processing.jshttp://processingjs.org,
 so it can be used for our goals. *Expected results: *quil clojurescript
 library capable of running regular quil sketches, documentation how to use
 it in clojurescript project. *Knowledge prerequisites: *familiarity with
 clojurescript, javascript *Skill level: *medium *Mentor: *Nikita
 Beloglazov (nikelandj...@gmail.com)

 Thank you,
 Nikita

 On Wednesday, February 5, 2014 6:19:55 PM UTC, Daniel Solano Gómez wrote:

 Hello, all,

 It's time once again to prepare our application for Google Summer of
 Code, a program where Google pays students from around the world to work
 on open source projects.  Clojure has successfully participated in the
 program for two years now, and I would love to make it a third.  GSoC
 has helped projects like Typed Clojure, Clojure in Clojure, Clojure
 on Android, core.matrix, and ClojureScript.

 In order to have a strong application, we need you to help populate our
 project ideas page [1].  You can also review the ideas for 2012 [2] and
 2013 [3] to help you come up with new ideas.  Having a great ideas page
 is key to a successful application, and having many members from the
 community participate as potential mentors will be a big boost.  At this
 point, you are not committing to anything--we just need your ideas.

 If you don't have edit rights to the wiki and don't want to sign up for
 an account, just post to the mailing list using '[GSoC Idea]' in the
 subject line, and I'll add it for you.

 Lastly, if you would like to review the answers to the organization
 application [4], I would appreciate the input.

 The application deadline the 14th of February.

 Thank you for time and ideas.

 Sincerely,

 Daniel


 [1]: http://dev.clojure.org/display/community/Project+Ideas
 [2]: http://dev.clojure.org/display/community/Google+Summer+of+Code+2012
 [3]: http://dev.clojure.org/display/community/Project+Ideas+2013
 [4]: http://dev.clojure.org/display/community/Mentoring+
 Organization+Application

  --
 You 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: Alternative - macro for threading sequences?

2014-02-07 Thread t x
 I think

(- things
(map wrangle)
(map pacify)
(filter effable)
(map #(aggravate % :bees :sharks))
(reduce mapinate {})


is optimal for the following reason:


If you're doing map and map alone, i.e.

(- things
  (map f1)
  (map f2)
  (map f3)
  (map f4))

then you can do:

(map #(f4 (f3 (f2 (f1 % things)


Now, if you're not doing pure maps, i.e. maps + filters

Then for each function call, from an information theoretic
perspective, you have to, at the very least, specify:

  (*) the function to be called
  (*) whether it's a filter or a map

in this case,

what you initially have is optimal.

On Fri, Feb 7, 2014 at 6:33 AM, Korny Sietsma ko...@sietsma.com wrote:
 I tend to agree, I think.  I certainly can't think of a syntax that would
 make me happy.  It just feels like a bit of a smell that I keep using - to
 process sequences in similar ways.

 The data.zip xml- macro is an example of something like what I'm thinking
 about - it lets you process sequences of xml data nicely:
 http://clojure.github.io/data.zip/#clojure.data.zip.xml/xml-

 ... but I can't see a way to use something similar for the sort of data I'm
 processing.  I'll let this percolate, and stick to just using lots of (map)
 and (filter) instead.

 - Korny


 On 6 February 2014 18:34, Jozef Wagner jozef.wag...@gmail.com wrote:

 I agree with Colin, the cognitive load is greater than benefits of such
 approach. BTW you can use comp to chain consecutive map transformation
 functions. (map (comp pacify wrangle) things)

 JW


 On Thu, Feb 6, 2014 at 3:40 PM, Korny Sietsma ko...@sietsma.com wrote:

 Hi folks,

 I seem to regularly find myself writing - threaded code that follows
 similar patterns:

 (- things
 (map wrangle)
 (map pacify)
 (filter effable)
 (map #(aggravate % :bees :sharks))
 (reduce mapinate {})

 i.e. all stages of the code actually operate on a collection rather than
 a single value - usually with a call to map at each stage.  This example
 is over simplified - often many of the calls to map are inline functions,
 which makes this even more verbose.

 I wonder if there would be value in (yet another) variant on '-' that
 assumes you are threading a collection and calling 'map' by default.  I'm
 not sure of the syntax that would work though.  Something like:

 ([]- things
 wrangle
 pacify
 [:filter effable]
 (aggravate :bees :sharks)
 [:reduce mapinate {}])

 I'm not sure about the syntax for non-map functions, I'm not even sure if
 this is worthwhile.  Thoughts?

 - Korny

 --
 Kornelis Sietsma  korny at my surname dot com http://korny.info
 .fnord { display: none !important; }

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




 --
 Kornelis Sietsma  korny at my surname dot com http://korny.info
 .fnord { display: none !important; }

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

Re: stch.schema a Prismatic Schema fork

2014-02-07 Thread david
Thanks for pointing that out.  Changed defn*, defrecord*, fn*, letfn* to 
defn', defrecord', fn', and letfn'.  Added tests for fn' and letfn'.

-- 
You 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: Confused by Clojure floating-point differences (compared to other languages)

2014-02-07 Thread Lee Spector

On Feb 5, 2014, at 11:42 PM, Michał Marczyk wrote:

 This returns
 
 (.getTotalPhysicalMemorySize
 (java.lang.management.ManagementFactory/getOperatingSystemMXBean))
 
 You could use this in your project.clj, perhaps by including
 
 ~(str -Xms (quot (.getTotalPhysicalMemorySize ...) appropriate-number))
 
 in :jvm-opts.


Very cool. I had no idea I could do computation in project.clj. The following 
seems to work to allocate 80% of the a machine's RAM to my process (launched 
with lein trampoline with-profile production run):

  :jvm-opts [~(str -Xmx
   (long (* (.getTotalPhysicalMemorySize
  
(java.lang.management.ManagementFactory/getOperatingSystemMXBean))
0.8)))
 ~(str -Xms
   (long (* (.getTotalPhysicalMemorySize
  
(java.lang.management.ManagementFactory/getOperatingSystemMXBean))
0.8)))
 -XX:+UseParallelGC]

I'll ask more about the GC part in another thread.

 Also, you can absolutely use your own :jvm-opts with :replace.

How do I combine them? Does the big vector above just replace the [] in 
:jvm-opts ^:replace []?

Also, does this (the :replace part) in fact do the same thing as putting 
with-profile production on the command line? So if I do this I can simplify 
my command line to lein trampoline run?

Thanks!

 -Lee

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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.


how to use the G1 garbage collector

2014-02-07 Thread Lee Spector

Does anyone know what to put in :jvm-opts in project.clj to use the G1 garbage 
collector? I see a lot about how G1 works and how to configure it in web search 
results, but not this little nugget of info.

Also, if anyone has any advice about GC for my use case I'd love to hear it. My 
use case is: generating lots and lots of garbage in long-running, 
CPU-intensive, multicore processes. I want to minimize overall runtime and 
don't much care about responsiveness at all.

Thanks,

 -Lee

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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: how to use the G1 garbage collector

2014-02-07 Thread Gary Trakhman
I do it like this:

in my .bashrc

export JVM_OPTS=-XX:+UseG1GC
export LEIN_JVM_OPTS=-XX:+UseG1GC


You can verify that it's working by checking jvisualvm's view of the
jvm-opts on the relevant processes.  Running it system-wide has given me
reduced memory-pressure on my lappie with no downside.


On Fri, Feb 7, 2014 at 11:29 AM, Lee Spector lspec...@hampshire.edu wrote:


 Does anyone know what to put in :jvm-opts in project.clj to use the G1
 garbage collector? I see a lot about how G1 works and how to configure it
 in web search results, but not this little nugget of info.

 Also, if anyone has any advice about GC for my use case I'd love to hear
 it. My use case is: generating lots and lots of garbage in long-running,
 CPU-intensive, multicore processes. I want to minimize overall runtime and
 don't much care about responsiveness at all.

 Thanks,

  -Lee

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 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: how to use the G1 garbage collector

2014-02-07 Thread Lee Spector

On Feb 7, 2014, at 11:35 AM, Gary Trakhman wrote:

 I do it like this:
 
 in my .bashrc
 
 export JVM_OPTS=-XX:+UseG1GC
 export LEIN_JVM_OPTS=-XX:+UseG1GC
 
 
 You can verify that it's working by checking jvisualvm's view of the jvm-opts 
 on the relevant processes.  Running it system-wide has given me reduced 
 memory-pressure on my lappie with no downside.

Interesting, but this is for processes that I'll be running on remote machines 
and I'd like all of the configuration to be in the Clojure project (ideally) or 
on the command line.

 -Lee

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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: how to use the G1 garbage collector

2014-02-07 Thread Laurent PETIT
What if you put -XX:+UseG1GC in :jvm-opts ?


2014-02-07 17:38 GMT+01:00 Lee Spector lspec...@hampshire.edu:


 On Feb 7, 2014, at 11:35 AM, Gary Trakhman wrote:

  I do it like this:
 
  in my .bashrc
 
  export JVM_OPTS=-XX:+UseG1GC
  export LEIN_JVM_OPTS=-XX:+UseG1GC
 
 
  You can verify that it's working by checking jvisualvm's view of the
 jvm-opts on the relevant processes.  Running it system-wide has given me
 reduced memory-pressure on my lappie with no downside.

 Interesting, but this is for processes that I'll be running on remote
 machines and I'd like all of the configuration to be in the Clojure project
 (ideally) or on the command line.

  -Lee

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 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: how to use the G1 garbage collector

2014-02-07 Thread Niels van Klaveren
Both G1 and ConcurrentMarkSweep GC are meant to lower pauses (increase 
responsiveness), but generally increase total running time. So I don't know 
if it's ideal for the scenario you describe.

On Friday, February 7, 2014 5:38:09 PM UTC+1, Lee wrote:


 On Feb 7, 2014, at 11:35 AM, Gary Trakhman wrote: 

  I do it like this: 
  
  in my .bashrc 
  
  export JVM_OPTS=-XX:+UseG1GC 
  export LEIN_JVM_OPTS=-XX:+UseG1GC 
  
  
  You can verify that it's working by checking jvisualvm's view of the 
 jvm-opts on the relevant processes.  Running it system-wide has given me 
 reduced memory-pressure on my lappie with no downside. 

 Interesting, but this is for processes that I'll be running on remote 
 machines and I'd like all of the configuration to be in the Clojure project 
 (ideally) or on the command line. 

  -Lee 



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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: Confused by Clojure floating-point differences (compared to other languages)

2014-02-07 Thread Andy Fingerhut
You may also use a let form wrapped around your entire defproject if you
want to avoid the duplication of code present in your example.

Andy


On Fri, Feb 7, 2014 at 8:22 AM, Lee Spector lspec...@hampshire.edu wrote:


 On Feb 5, 2014, at 11:42 PM, Michał Marczyk wrote:

  This returns
 
  (.getTotalPhysicalMemorySize
  (java.lang.management.ManagementFactory/getOperatingSystemMXBean))
 
  You could use this in your project.clj, perhaps by including
 
  ~(str -Xms (quot (.getTotalPhysicalMemorySize ...) appropriate-number))
 
  in :jvm-opts.


 Very cool. I had no idea I could do computation in project.clj. The
 following seems to work to allocate 80% of the a machine's RAM to my
 process (launched with lein trampoline with-profile production run):

   :jvm-opts [~(str -Xmx
(long (* (.getTotalPhysicalMemorySize

 (java.lang.management.ManagementFactory/getOperatingSystemMXBean))
 0.8)))
  ~(str -Xms
(long (* (.getTotalPhysicalMemorySize

 (java.lang.management.ManagementFactory/getOperatingSystemMXBean))
 0.8)))
  -XX:+UseParallelGC]

 I'll ask more about the GC part in another thread.

  Also, you can absolutely use your own :jvm-opts with :replace.

 How do I combine them? Does the big vector above just replace the [] in
 :jvm-opts ^:replace []?

 Also, does this (the :replace part) in fact do the same thing as putting
 with-profile production on the command line? So if I do this I can
 simplify my command line to lein trampoline run?

 Thanks!

  -Lee

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 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: how to use the G1 garbage collector

2014-02-07 Thread Lee Spector
On Feb 7, 2014, at 11:41 AM, Laurent PETIT wrote:

 What if you put -XX:+UseG1GC in :jvm-opts ?

Ah yes -- I should have seen that even though I may not want to take Gary's 
suggestion of putting it in .bashrc, he had given me the magic string to 
include in :jvm-opts too!

I will give that a try. Thanks so much, -Lee


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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: Confused by Clojure floating-point differences (compared to other languages)

2014-02-07 Thread Lee Spector
On Feb 7, 2014, at 11:45 AM, Andy Fingerhut wrote:

 You may also use a let form wrapped around your entire defproject if you want 
 to avoid the duplication of code present in your example.

Thanks -- I actually noticed that after I posted. I don't know why, but I never 
thought of project.clj as containing code that gets executed before. Opens up 
lots of possibilities, I think.

 -Lee

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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: ISeq documentation and mutual deftypes.

2014-02-07 Thread Alex Miller
next() should return either the remaining seq or null (think Clojure 
function next)
more() should return either the remaining seq or empty list (like Clojure 
function rest)

Inside Clojure, most seqs extend ASeq, which implements more() on top of 
the abstract next():

public ISeq more(){
ISeq s = next();
if(s == null)
return PersistentList.EMPTY;
return s;
}

equiv() is like equals() but equals() follows Java semantics and equiv() 
follows Clojure semantics. For your custom types, it's likely they mean the 
same thing.  

empty() returns a collection of the same type without any elements.

Not sure on mutually recurring deftypes - sounds tricky. It is entirely 
possible this has come up on clojure or clojure-dev mailing lists in the 
past so I would start by searching there.

Alex


On Friday, February 7, 2014 6:00:41 AM UTC-6, Phillip Lord wrote:



 I've been playing with some code recently. I was wondering how hard 
 would it be to implement, for example ISeq in clojure. The plan was to 
 use deftype and a few bits of other code. 

 The ISeq interface looks like this: 

 public interface ISeq extends IPersistentCollection { 

 Object first(); 

 ISeq next(); 

 ISeq more(); 

 ISeq cons(Object o); 

 } 


 And here is the problem -- it looks exactly like this! There is no 
 documentation. While first and cons are guessable, I am still not sure 
 of the difference between next and more. Likewise, IPersistentCollection 
 has equiv and empty -- guessable again. 

 The other question: is it possible to have two mutually refering deftype 
 definitions. 

 So 

 (deftype Alice () 
(other [] (Brian.))) 

 (deftype Brian () 
(other [] (Alice.))) 

 The closest I have got it: 

 (declare create-alice) 
 (declare create-brian) 

 (deftype Alice () 
 (other [] (create-brian))) 
 (deftype Brian () 
 (other [] (create-alice))) 

 The last could be 

 (deftype Brian () 
 (other [] (Alice.))) 

 but the symmetry seemed good. 


-- 
You 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] durable-queue: an in-process disk-backed queue

2014-02-07 Thread Zach Tellman
Hi Bob,

Right now the API only allows for single puts, and fsyncing is
all-or-nothing.  However, this is just an artifact of my major use case for
the library, which relies on upstream batching of tasks.  I'm planning an
0.1.1 release which has an explicit `sync` method, and support for
sync-intervals (i.e. sync twice a second) and sync-thresholds (i.e. sync
every ten puts or takes).  The use case you describe could be achieved by
disabling automatic syncing, and doing a series of puts and takes followed
by a call to `sync`.

If you have thoughts or suggestions on how this can be more useful for you,
please let me know.

Zach


On Fri, Feb 7, 2014 at 5:26 AM, Bob Hutchison hutch-li...@recursive.cawrote:


 On Feb 6, 2014, at 6:45 PM, Zach Tellman z...@factual.com wrote:

 At Factual we get a lot of data thrown at us, and often don't have control
 over the rate at which it comes in.  As such, it's preferable that our
 buffer isn't bounded by the process' memory, since a temporary blip in
 throughput may cause GC pauses, OOM exceptions, and other things that will
 only exacerbate the problem.  It's also preferable that if the process
 dies, we won't lose any data which hasn't yet escaped the process.  A
 disk-backed queue satisfies both of these requirements.

 As such, I'm happy to announce that we're open sourcing 'durable-queue':
 https://github.com/Factual/durable-queue.  It's a small, fast,
 pure-Clojure implementation that in our production systems is responsible
 for processing billions of entries daily.  We believe it has broad
 applications, and are excited to see how others will use it.


 What excellent timing! I've been looking at ZeroMQ, RabbitMQ, and Kafka
 for the last week or so. ZMQ is awfully attractive for what I'm trying to
 do, but there are a few things it doesn't do that I need done. I had begun
 thinking of building something similar on top of Redis.

 You mention the idea of batching to reduce the impact of fsync. Is there
 an API for batching puts? Is there a way to batch a complete! and put! new
 tasks to the queue?

 One pattern that keeps coming up is:
- take a single task from the queue
- execute the task, which might generate a set of new tasks to be
 queued on the same queue (and likely on other queues too)
- signal completion, and put the new tasks

 Cheers,
 Bob


 Zach

 P.S. If this sort of work is interesting to you, Factual is hiring:
 https://groups.google.com/forum/#!searchin/clojure/factual/clojure/8bPIEnNpfyQ/lvv-9gkVozAJ

 --
 You 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/4tZFWdMKvjw/unsubscribe.
 To unsubscribe from this group and all its topics, 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.


[ANN] Framework One for Clojure 0.2.4 released (MVC mini-framework for web apps)

2014-02-07 Thread Sean Corfield
In case anyone cares :)

https://github.com/framework-one/fw1-clj

FW/1 is a lightweight, convention-based MVC framework. It is a port to Clojure 
of FW/1 for CFML (the most popular MVC framework for the ColdFusion Markup 
Language, in active development since mid-2009).

Release 0.2.4
• Added verb support to routes
• Ensure UTF-8 output
• Add :middleware support
• Fix JSON MIME type
• Update dependencies

The simplest way to get up and running:

lein new fw1 myapp
cd myapp
PORT= lein run

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

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





signature.asc
Description: Message signed with OpenPGP using GPGMail


Refactoring as an nREPL middleware

2014-02-07 Thread Curtis Gagliardi
Hey everyone, I just wanted to get some feedback on whether or not this is 
a good idea.  I've seen clj-refactor.el recommended a decent amount, but as 
a dyed-in-the-wool take-no-prisoners vim user, I can't use it.  I've always 
thought it was weird that refactoring was so tightly coupled to editors and 
IDEs, so I thought I'd try writing some refactors as an nrepl middleware, 
that would ideally be able to be used across editors.  I've only 
re-implemented the threading and some of the cycling refactors from 
clj-refactor.el, but it's to the point where I'm going to investigate 
actually integrating with vim or light table.  I've never written any 
plugins for either of these editors so I might discover there are good 
reasons I haven't seen refactoring done as a client/server type thing.  
Anyway, the code is here: https://github.com/cgag/nrepl-refactor , if 
anyone has any has any feedback I'd love to hear it, and if anyone has 
vimscript or lighttable plugin experience and wants to help, that'd be 
great as well.

Curtis

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


Is there a prettify command in emacs for clojure?

2014-02-07 Thread Taylor Sando
Let us say you had this:

(defn create-new-canvas-text [inputs]  
  (let [{text-selected-id :new} (dataflow/old-and-new inputs [:design 
:params :text :selected-id])
{text-params :new} (dataflow/old-and-new inputs [:design :params 
:text])
text-value (:value text-params)

]
;; When there is no previous selected id and there is now non-empty 
text in the params text
;; it means that a new canvas text entry should occur
(when
(and (nil? text-selected-id) (not (empty? text-value)))
  ;; Get the previous text entries in canvas
  ;; Create a new key, which will become selected-id
  ;; Add the new text entries into canvas
(let [{prev-text :new} (dataflow/old-and-new inputs 
[:design :canvas :text])
  old-keys (keys prev-text)
new-id (if (seq old-keys) (inc (apply max (keys old-keys))) 0)
new-text (assoc old-keys new-id (select-keys text-params 
[:value]))]
[
 ^:input {msg/topic [:design :params :text :selected-id] msg/type 
:set-value :value new-id}
 ^:input {msg/topic [:design :canvas :text] msg/type :set-value 
:value new-text}]))


)

  )

Is there a way to get it into this:

(defn create-new-canvas-text [inputs]  
  (let [{text-selected-id :new} (dataflow/old-and-new inputs [:design 
:params :text :selected-id])
{text-params :new} (dataflow/old-and-new inputs [:design :params 
:text])
text-value (:value text-params)]
;; When there is no previous selected id and there is now non-empty 
text in the params text
;; it means that a new canvas text entry should occur
(when (and (nil? text-selected-id) (not (empty? text-value)))
  ;; Get the previous text entries in canvas
  ;; Create a new key, which will become selected-id
  ;; Add the new text entries into canvas
  (let [{prev-text :new} (dataflow/old-and-new inputs [:design :canvas 
:text])
old-keys (keys prev-text)
new-id (if (seq old-keys) (inc (apply max (keys old-keys))) 0)
new-text (assoc old-keys new-id (select-keys text-params 
[:value]))]
[^:input {msg/topic [:design :params :text :selected-id] msg/type 
:set-value :value new-id}
 ^:input {msg/topic [:design :canvas :text] msg/type :set-value 
:value new-text}]


Seems like it would be a combination of indent-sexp, and then identifying 
unnecessary white space and deleting it.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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.


Room Key is Hiring!

2014-02-07 Thread Thomas Steffes
Room Key is hiring Clojure developers to work at our technology 
headquarters in beautiful Charlottesville, Virginia.

Our backend stack is Clojure / AWS / Solr / Postgres, which fronts a JSON 
API for our single-page javascript application. See this job posting, or 
reach out to j...@roomkey.com if interested!

http://charlottesville.craigslist.org/sof/4319601411.html

-- 
You 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: Refactoring as an nREPL middleware

2014-02-07 Thread Jason Felice
I think this is an awesome idea.  I think it should be easy to build on top
of vim-fireplace to integrate with vim, and I will surely beta test for you.
On Feb 7, 2014 4:51 PM, Curtis Gagliardi gagliardi.cur...@gmail.com
wrote:

 Hey everyone, I just wanted to get some feedback on whether or not this is
 a good idea.  I've seen clj-refactor.el recommended a decent amount, but as
 a dyed-in-the-wool take-no-prisoners vim user, I can't use it.  I've always
 thought it was weird that refactoring was so tightly coupled to editors and
 IDEs, so I thought I'd try writing some refactors as an nrepl middleware,
 that would ideally be able to be used across editors.  I've only
 re-implemented the threading and some of the cycling refactors from
 clj-refactor.el, but it's to the point where I'm going to investigate
 actually integrating with vim or light table.  I've never written any
 plugins for either of these editors so I might discover there are good
 reasons I haven't seen refactoring done as a client/server type thing.
 Anyway, the code is here: https://github.com/cgag/nrepl-refactor , if
 anyone has any has any feedback I'd love to hear it, and if anyone has
 vimscript or lighttable plugin experience and wants to help, that'd be
 great as well.

 Curtis

 --
 You 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: GSoC 2014: org applications now open

2014-02-07 Thread A

A couple ideas put forth:

1. Incanter charts with d3 (http://d3js.org/) ?  Perhaps facilitated by 
Dribnet's Strokes library (https://github.com/dribnet/strokes).

2. Finding ways to integrate Incanter and Clojurescript.

Thoughts?

-Avram




On Monday, February 3, 2014 11:59:24 AM UTC-8, Daniel Solano Gómez wrote:

 Hello, all, 

 Apparently, it's already time for organisations to apply for Google Summer 
 of Coder 2014 [1].   This is a great program, and there have been several 
 notable projects that have benefited as a result.  For example, last year's 
 successful projects included: 

 * Enhance Neko for Android, Alexander Yakushev 
 * core.typed: Extensions and Documentation, Ambrose Bonnaire-Sergeant 
 * Clojure Compiler port to Clojure (CinC), Bronsa 
 * Implementation of core.matrix-compatible multidimensional array in 
 Clojure, Dmitry Groshev 
 * Algebraic Expressions, Maik Schünemann 
 * ClojureScript optimization and source maps support, Michal Marczyk 

 I would love to see Clojure participate again this year.  In order to do 
 so, we need to start our application which is due in less than two weeks. 
  We need volunteers to help prepare our application, and in particular it 
 would be great to have administrators that can help lead the process.  I am 
 certainly willing to help out, but if there is someone who wants to lead up 
 this effort, I would happy to assist. 

 Ideally, we could have multiple administrators to spread out the following 
 duties: 

 * Updating the community wiki for the year [2] 
 * Recruiting potential mentors 
 * Raising the profile of GSoC within the community 

 If we are accepted as a GSoC organisation, administrator duties include: 

 * Ensuring we meet the deadlines 
 * Arranging for travel to the mentor submit 
 * Arranging for students' travel to conferences 
 * If necessary, solve problems 

 I am afraid that last year I let the ball drop a bit with the mentor 
 summit and getting students to conferences.  With multiple administrators 
 to help spread the work around, I am sure we can make GSoC an even better 
 experience for everyone involved. 

 If you are interested in helping out in this effort, please set up a 
 profile on Melange [3] and e-mail me your profile name.   

 Thanks for your help. 

 Sincerely, 

 Daniel 


 [1]: 
 http://google-opensource.blogspot.com/2014/02/mentoring-organization-applications-now.html
  
 [2]: http://dev.clojure.org/display/community/Google+Summer+of+Code+2013 
 [3]: http://en.flossmanuals.net/melange/ 


-- 
You 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: Refactoring as an nREPL middleware

2014-02-07 Thread John D. Hume
I haven't attempted any code manipulation, just analysis and indexing, but
I embarked on a similar idea here:
https://github.com/duelinmarkers/insfactor and here:
http://github.com/duelinmarkers/insfactor.el. (Nothing Vim-related there,
the similar part is trying to put as much as possible of the smarts into
the same JVM as the project.) It indexes a simple clojure project and
provides a find-usages command, the idea being that find-usages is the
first useful step toward rename-var and move-var commands. (I say simple
because it still barfs on some common stuff, including defprotocol, IIRC.)

Focusing on what you're doing in http://github.com/cgag/nrepl-refactor, the
mess I came upon and backed away from when I initially played with
transforming code in Clojure is that the forms are easy to manipulate but
formatting is hard to maintain. There are also several non-whitespace bits
of source that the reader will hide away from you (including comments and
#_ forms) but that a proper refactoring tool won't clobber.

If you haven't already, you might take a look at
https://github.com/cgrand/sjacket.

I've been hoping that the new https://github.com/clojure/tools.analyzer work
will support some of what source manipulation tools are likely to need, but
I haven't looked into it. For example, one hassle with
jvm.tools.analyzer (at least the now outdated version I've been using) is
that the reader doesn't provide line and column metadata in many places
where you'd expect to find it. Another is that it can only show you the
post-macro-expansion view of the world.



On Fri, Feb 7, 2014 at 3:51 PM, Curtis Gagliardi gagliardi.cur...@gmail.com
 wrote:

 Hey everyone, I just wanted to get some feedback on whether or not this is
 a good idea.  I've seen clj-refactor.el recommended a decent amount, but as
 a dyed-in-the-wool take-no-prisoners vim user, I can't use it.  I've always
 thought it was weird that refactoring was so tightly coupled to editors and
 IDEs, so I thought I'd try writing some refactors as an nrepl middleware,
 that would ideally be able to be used across editors.  I've only
 re-implemented the threading and some of the cycling refactors from
 clj-refactor.el, but it's to the point where I'm going to investigate
 actually integrating with vim or light table.  I've never written any
 plugins for either of these editors so I might discover there are good
 reasons I haven't seen refactoring done as a client/server type thing.
 Anyway, the code is here: https://github.com/cgag/nrepl-refactor , if
 anyone has any has any feedback I'd love to hear it, and if anyone has
 vimscript or lighttable plugin experience and wants to help, that'd be
 great as well.

 Curtis

 --
 You 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: Is there a prettify command in emacs for clojure?

2014-02-07 Thread Devin Walters
This is something I stole from Phil Hagelberg's starter kit. 

It doesn't work all the time, and in some cases might do some things you don't 
particularly want, but I still use it:

(defun untabify-buffer ()
  (interactive)
  (untabify (point-min) (point-max)))

(defun indent-buffer ()
  (interactive)
  (indent-region (point-min) (point-max)))

(defun cleanup-buffer ()
  perform a bunch of operations on the whitespace content of a buffer
  (interactive)
  (indent-buffer)
  (untabify-buffer)
  (delete-trailing-whitespace))


(global-set-key (kbd C-c n) 'cleanup-buffer)

The other thing you can do is mark the region you want to clean up and hit TAB. 
It does most of what you want. 

Cheers,
-- 
Devin Walters


On Friday, February 7, 2014 at 4:20 PM, Taylor Sando wrote:

 Let us say you had this:
 
 (defn create-new-canvas-text [inputs]  
   (let [{text-selected-id :new} (dataflow/old-and-new inputs [:design :params 
 :text :selected-id])
 {text-params :new} (dataflow/old-and-new inputs [:design :params 
 :text])
 text-value (:value text-params)
 
 ]
 ;; When there is no previous selected id and there is now non-empty text 
 in the params text
 ;; it means that a new canvas text entry should occur
 (when
 (and (nil? text-selected-id) (not (empty? text-value)))
   ;; Get the previous text entries in canvas
   ;; Create a new key, which will become selected-id
   ;; Add the new text entries into canvas
 (let [{prev-text :new} (dataflow/old-and-new inputs 
 [:design :canvas :text])
   old-keys (keys prev-text)
 new-id (if (seq old-keys) (inc (apply max (keys old-keys))) 0)
 new-text (assoc old-keys new-id (select-keys text-params 
 [:value]))]
 [
  ^:input {msg/topic [:design :params :text :selected-id] msg/type 
 :set-value :value new-id}
  ^:input {msg/topic [:design :canvas :text] msg/type :set-value 
 :value new-text}]))
 
 
 )
 
   )
 
 Is there a way to get it into this:
 
 (defn create-new-canvas-text [inputs]  
   (let [{text-selected-id :new} (dataflow/old-and-new inputs [:design :params 
 :text :selected-id])
 {text-params :new} (dataflow/old-and-new inputs [:design :params 
 :text])
 text-value (:value text-params)]
 ;; When there is no previous selected id and there is now non-empty text 
 in the params text
 ;; it means that a new canvas text entry should occur
 (when (and (nil? text-selected-id) (not (empty? text-value)))
   ;; Get the previous text entries in canvas
   ;; Create a new key, which will become selected-id
   ;; Add the new text entries into canvas
   (let [{prev-text :new} (dataflow/old-and-new inputs [:design :canvas 
 :text])
 old-keys (keys prev-text)
 new-id (if (seq old-keys) (inc (apply max (keys old-keys))) 0)
 new-text (assoc old-keys new-id (select-keys text-params 
 [:value]))]
 [^:input {msg/topic [:design :params :text :selected-id] msg/type 
 :set-value :value new-id}
  ^:input {msg/topic [:design :canvas :text] msg/type :set-value 
 :value new-text}]
 
 
 
 Seems like it would be a combination of indent-sexp, and then identifying 
 unnecessary white space and deleting 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 
 (mailto: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 
 (mailto: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 
 (mailto: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.


unconditional append to end

2014-02-07 Thread t x
Consider the following:

(cons 1 '(2 3 4)) == (1 2 3 4)
(cons 1 [2 3 4])  == (1 2 3 4)

(conj '(a b c) 1) == (1 a b c)
(conj '[a b c] 1) == [a b c 1]




Now, I would like something that _always_
  * appends to the end

cons is almost what I want, except it always appends to front.

conj is not what I want -- in fact, I'm afraid of conj. Often times,
I'll run map/filter on something, and suddenly, instead of a vector, I
now have a list -- and conj changes the order of the item added.

Thus, my question: is there a builtin to _unconditinoally_ append to
the end of a list/sequence/vector?

Thanks!

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To 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: Refactoring as an nREPL middleware

2014-02-07 Thread Alex Miller
This might be an interesting area for a Google Summer of Code project if 
someone would be willing to mentor such a thing and come up with a 
high-level plan. 

http://dev.clojure.org/display/community/Project+Ideas


On Friday, February 7, 2014 3:51:29 PM UTC-6, Curtis Gagliardi wrote:

 Hey everyone, I just wanted to get some feedback on whether or not this is 
 a good idea.  I've seen clj-refactor.el recommended a decent amount, but as 
 a dyed-in-the-wool take-no-prisoners vim user, I can't use it.  I've always 
 thought it was weird that refactoring was so tightly coupled to editors and 
 IDEs, so I thought I'd try writing some refactors as an nrepl middleware, 
 that would ideally be able to be used across editors.  I've only 
 re-implemented the threading and some of the cycling refactors from 
 clj-refactor.el, but it's to the point where I'm going to investigate 
 actually integrating with vim or light table.  I've never written any 
 plugins for either of these editors so I might discover there are good 
 reasons I haven't seen refactoring done as a client/server type thing.  
 Anyway, the code is here: https://github.com/cgag/nrepl-refactor , if 
 anyone has any has any feedback I'd love to hear it, and if anyone has 
 vimscript or lighttable plugin experience and wants to help, that'd be 
 great as well.

 Curtis


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


map semantics

2014-02-07 Thread Andy C
Hi,

I have a short question, why map builds up a LazySeq instead of an input
collection as found below:

user= (type (map #(mod % 3) #{3 6}))
clojure.lang.LazySeq
user= (type (map #(mod % 3) '(3 6)))
clojure.lang.LazySeq
user= (type (map #(mod % 3) [3 6]))
clojure.lang.LazySeq
user= (type (map #(mod (% 1) 3) {:a 3, :b 6}))
clojure.lang.LazySeq


One would expect to (map #(mod % 3) #{3 6}) evaluate into #{0}. Is it
arbitrary decision or there is a theory behind it?

Best,
Andy

-- 
You 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: map semantics

2014-02-07 Thread Atamert Ölçgen
Why should it build a concrete result?

Here's my reasons why it makes sense to be lazy here:

- It would use more memory otherwise. Since, if you are transforming a list
to a set there's got to a transformed copy of the original data structure
when it's materialized.
- It might take longer than necessary to calculate. Suppose you've threaded
the result into (take n), now, you need to call the predicate of map only n
times.

If you think about large data structures (maybe even infinite sequences),
laziness makes more sense.



On Sat, Feb 8, 2014 at 2:19 AM, Andy C andy.coolw...@gmail.com wrote:

 Hi,

 I have a short question, why map builds up a LazySeq instead of an input
 collection as found below:

 user= (type (map #(mod % 3) #{3 6}))
 clojure.lang.LazySeq
 user= (type (map #(mod % 3) '(3 6)))
 clojure.lang.LazySeq
 user= (type (map #(mod % 3) [3 6]))
 clojure.lang.LazySeq
 user= (type (map #(mod (% 1) 3) {:a 3, :b 6}))
 clojure.lang.LazySeq


 One would expect to (map #(mod % 3) #{3 6}) evaluate into #{0}. Is it
 arbitrary decision or there is a theory behind it?

 Best,
 Andy

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




-- 
Kind Regards,
Atamert Ölçgen

-+-
--+
+++

www.muhuk.com

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To 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.


ANN: core.logic 0.8.6

2014-02-07 Thread David Nolen
The main change is the introduction of a new protocol IVerifyConstraint.
Implementations of it will be called before a constraint is added to the
constraint store - this is the hook needed for detecting incompatible
constraints.

More information here: http://github.com/clojure/core.logic

Feedback welcome!

-- 
You 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: map semantics

2014-02-07 Thread Atamert Ölçgen
On Sat, Feb 8, 2014 at 3:05 AM, Andy C andy.coolw...@gmail.com wrote:


 set-s are indeed a sticky point here since the result of a map would
 different depending in the convention.


No the result would be the same. Only the order of the elements in the lazy
sequence would differ, but that's to be expected since sets are not ordered.


-- 
Kind Regards,
Atamert Ölçgen

-+-
--+
+++

www.muhuk.com

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To 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: map semantics

2014-02-07 Thread Andy C
user= (map #(mod % 3) #{3 6})
(0 0)
user= (set (map #(mod % 3) #{3 6}))
#{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
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: map semantics

2014-02-07 Thread Andy C
I do perceive sets, lists, vector as atoms which are indivisible (well,
this is not true but this is popular meaning) from semantics standpoint.
Therefore map is just a function which processes them as whole, again from
semantics point of view. Implementation and laziness should not matter
really and we still should get the same result.


-- 
You 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: map semantics

2014-02-07 Thread Mars0i
Andy C, I think that in the Clojure world, there is a widespread view that 
lazy sequences should be the (or one of the) primary datatypes, that 
iteration should usually produce lazy sequences, etc.  They are something 
like the default in Clojure.  Clojure includes a systematically organized 
and very handy collection of functions all of which are designed to produce 
and/or use lazy sequences.  That collection of tools is one of Clojure's 
strengths.  From this point of view, it's very natural that map should 
return a lazy sequence, no matter what kind of collection(s) is (are) 
passed into it.  And then if one doesn't want a lazy sequence as output, 
there are various ways to realize the output or convert it.   The into 
function is a general-purpose tool that can often be used for this purpose.

(That said, I currently hold the heretical view that laziness should be 
optional in Clojure--that maybe there should be a parallel set of non-lazy 
tools, or even, possibly, that there should be a switch to turn laziness on 
or off before compilation.  I suspect that most Clojure programmers would 
disagree with me, and I am a relative newbie in any event.  (If anyone 
wants to discuss this point now, we should probably start another thread.))


-- 
You 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 is # doing in #+cljs [cljs.reader :as reader]

2014-02-07 Thread larry google groups

I am looking here:

https://github.com/jkk/formative/blob/master/src/formative/parse.cljx

and I see this line:

#+cljs [cljs.reader :as reader]

So I look here to see what the # is doing: 

http://clojure.org/reader

and I read: 

Dispatch (#)
The dispatch macro causes the reader to use a reader macro from another 
table, indexed by the character following #:

However, this is not a set, a regex, a var-quote, an Anonymous function 
literal, nor a comment/ignore, so what is this exactly? 


-- 
You 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: Alternative - macro for threading sequences?

2014-02-07 Thread Mars0i
Since a few of these higher order functions--map, filter, reduce, etc.--are 
so common and useful, I wonder whether there could be sufficient benefit to 
having some abbreviations for them.  I know that some of these characters 
are already taken, but just to sketch the idea:

(-- things  %wrangle  %pacify  |effable  %#(aggravate % :bees :sharks)  
\(mapinate {}) )

In one sense this reduces the visual complexity of Korny's example.  In 
another sense it increases it.  I thought this option was worth mentioning, 
but I don't think I like it.  It makes the syntax closer to line noise, and 
if there are too many magical characters, no one will remember what they 
mean except the people who use them all of the time (like some of the 
options in Perl regexps).  Why not go all the way, and provide an alternate 
APL-style 
syntax http://c2.com/cgi/wiki?AplLanguage for Clojure?

On Friday, February 7, 2014 9:14:27 AM UTC-6, t x wrote:

 I think 

 (- things 
 (map wrangle) 
 (map pacify) 
 (filter effable) 
 (map #(aggravate % :bees :sharks)) 
 (reduce mapinate {}) 


 is optimal for the following reason: 


 If you're doing map and map alone, i.e. 

 (- things 
   (map f1) 
   (map f2) 
   (map f3) 
   (map f4)) 

 then you can do: 

 (map #(f4 (f3 (f2 (f1 % things) 


 Now, if you're not doing pure maps, i.e. maps + filters 

 Then for each function call, from an information theoretic 
 perspective, you have to, at the very least, specify: 

   (*) the function to be called 
   (*) whether it's a filter or a map 

 in this case, 

 what you initially have is optimal. 

 On Fri, Feb 7, 2014 at 6:33 AM, Korny Sietsma 
 ko...@sietsma.comjavascript: 
 wrote: 
  I tend to agree, I think.  I certainly can't think of a syntax that 
 would 
  make me happy.  It just feels like a bit of a smell that I keep using 
 - to 
  process sequences in similar ways. 
  
  The data.zip xml- macro is an example of something like what I'm 
 thinking 
  about - it lets you process sequences of xml data nicely: 
  http://clojure.github.io/data.zip/#clojure.data.zip.xml/xml- 
  
  ... but I can't see a way to use something similar for the sort of data 
 I'm 
  processing.  I'll let this percolate, and stick to just using lots of 
 (map) 
  and (filter) instead. 
  
  - Korny 
  
  
  On 6 February 2014 18:34, Jozef Wagner jozef@gmail.comjavascript: 
 wrote: 
  
  I agree with Colin, the cognitive load is greater than benefits of such 
  approach. BTW you can use comp to chain consecutive map transformation 
  functions. (map (comp pacify wrangle) things) 
  
  JW 
  
  
  On Thu, Feb 6, 2014 at 3:40 PM, Korny Sietsma 
  ko...@sietsma.comjavascript: 
 wrote: 
  
  Hi folks, 
  
  I seem to regularly find myself writing - threaded code that follows 
  similar patterns: 
  
  (- things 
  (map wrangle) 
  (map pacify) 
  (filter effable) 
  (map #(aggravate % :bees :sharks)) 
  (reduce mapinate {}) 
  
  i.e. all stages of the code actually operate on a collection rather 
 than 
  a single value - usually with a call to map at each stage.  This 
 example 
  is over simplified - often many of the calls to map are inline 
 functions, 
  which makes this even more verbose. 
  
  I wonder if there would be value in (yet another) variant on '-' that 
  assumes you are threading a collection and calling 'map' by default. 
  I'm 
  not sure of the syntax that would work though.  Something like: 
  
  ([]- things 
  wrangle 
  pacify 
  [:filter effable] 
  (aggravate :bees :sharks) 
  [:reduce mapinate {}]) 
  
  I'm not sure about the syntax for non-map functions, I'm not even sure 
 if 
  this is worthwhile.  Thoughts? 
  
  - Korny 
  
  -- 
  Kornelis Sietsma  korny at my surname dot com http://korny.info 
  .fnord { display: none !important; } 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  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 javascript: 
  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 javascript:. 
  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.comjavascript: 
  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 

Re: unconditional append to end

2014-02-07 Thread Armando Blancas
For efficient appends at the end you need a vector. Using the sequence 
library can be tricky while you're putting together your data structures 
because it's likely that you'll not done yet with type-specific functions. 
You'll need to re-create your vector after using map/filter/etc to be able 
to keep adding at the end. 

On Friday, February 7, 2014 4:20:09 PM UTC-8, t x wrote:

 Consider the following: 

 (cons 1 '(2 3 4)) == (1 2 3 4) 
 (cons 1 [2 3 4])  == (1 2 3 4) 

 (conj '(a b c) 1) == (1 a b c) 
 (conj '[a b c] 1) == [a b c 1] 


  

 Now, I would like something that _always_ 
   * appends to the end 

 cons is almost what I want, except it always appends to front. 

 conj is not what I want -- in fact, I'm afraid of conj. Often times, 
 I'll run map/filter on something, and suddenly, instead of a vector, I 
 now have a list -- and conj changes the order of the item added. 

 Thus, my question: is there a builtin to _unconditinoally_ append to 
 the end of a list/sequence/vector? 

 Thanks! 


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To 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: Parsing Clojure with instaparse: how to handle special forms?

2014-02-07 Thread Travis Moy
That answers my question pretty well, thanks.

On Thursday, February 6, 2014 11:20:42 PM UTC-8, Reid McKenzie wrote:

 Okay. So there's one big thing you're doing wrong here just from reading 
 your grammars: you are complecting the datastructures and valid _tokens_ 
 which make up the clojure language with the _meaing_ associated therewith 
 by the language. If you discard such things as destructuring as part of 
 the grammar and instead just provide the parse grammars for basic 
 datastructures like symbols, maps, keywords sets and soforth it's trivial 
 to produce a grammar which can _parse_ valid clojure code. _Reading_ 
 clojure code from such a parse tree is and should be an entirely seperate 
 concern, implemented as a pass over the generated parse structure.

 - Reid

 On Thursday, February 6, 2014 9:28:08 PM UTC-6, Travis Moy wrote:

 I'm trying to use instaparse to parse Clojure code so that I can reformat 
 it, but I'm having an issue with how to handle special forms. Should I 
 attempt to parse special forms such as let and defn into their own rules, 
 or should I rely instead on the actual content of the terminal to determine 
 what lists should be treated as special forms?

 For example, let's say I want to write a function which takes the parse 
 tree returned by instaparse and arranges all the let bindings as 
 recommended by the Clojure style guide (
 https://github.com/bbatsov/clojure-style-guide#source-code-layout--organization).
  
 There are two approaches I could take:

 1) Build the recognition into the grammar itself:

 S = Form*

 Form = !SpecialForm List | ReaderMacro | Literal | Vector | Map | 
  SpecialForm | !SpecialForm Symbol
 
 List = '(' Form* ')'

...

 SpecialForm = defn | let | try | JavaMemberAccess | JavaConstructor
 defn = '(' defn Symbol String? MapMetadata? 
 VectorDestructuring Form* ')'

 Destructuring = VectorDestructuring | MapDestructuring
 VectorDestructuring = '[' (Symbol | Destructuring)* ('' (Symbol | 
 Destructuring))? ']'
 MapDestructuring = Map


 2) Don't try to detect the let bindings in the grammar. Instead, search 
 the resulting parse tree for lists with let content.

 Which of these is a better approach? I sadly didn't take compilers in 
 college so I'm kind of playing this by ear; I'm sure if I had I'd have a 
 better idea of what the best practice is here.

 Thanks!

 (Full code for my project is at 
 https://github.com/MoyTW/clojure-toys/tree/master/formatter if needed)



-- 
You 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: map semantics

2014-02-07 Thread Andy C
I actually like the laziness by default but as you suggest, wish there is a
way to switch it on/off for blocks of the code (rather than compiler
option). Scala guys did some research and in most practical cases Lists are
very short hence they are not lazy and evaluated at once. Just an
interesting tidbit, not an argument.

But what really bothers me is that laziness / not laziness affects the
result of evaluation as in above example. That is against some fundamental
rules of FP (gotta check how Haskell does it :-P).

Again, question is what map really is, and why it gotta be invertible.
Let's say that we have a new collection type, a tree. And mapping every
node in the tree to a new value rearranges entire construct. Having map to
produce a lazy seq implies that the input must be serializable (or linear).

-- 
You 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: map semantics

2014-02-07 Thread Michael Gardner
On Feb 7, 2014, at 22:17 , Andy C andy.coolw...@gmail.com wrote:

 Having map to produce a lazy seq implies that the input must be serializable 
 (or linear).

That's just what map is in Clojure: an operation on sequences. It works on 
various concrete types because those can be viewed as sequences; map knows 
nothing of their structure. What you're looking for is another abstraction 
entirely (see clojure.walk, 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
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: unconditional append to end

2014-02-07 Thread Travis Moy
You should use a vector, but it's also possible to use concat. For example, 
(concat '(1 2 3) [4]) will give you (1 2 3 4).

This made me curious as to the best way to get a collection into vector, so 
I played around with it some:

user= (def r 10)
 #'user/r
 user= (def coll (range 1))
 #'user/coll
 user= (def coll-v (into [] coll))
 #'user/coll-v
 user= (time (dotimes [_ r] (conj (into [] coll) :a)))
 Elapsed time: 14074.018464 msecs
 nil
 user= (time (dotimes [_ r] (conj (apply vector coll) :a)))
 Elapsed time: 22565.594515 msecs
 nil
 user= (time (dotimes [_ r] (conj (vec coll) :a)))
 Elapsed time: 22424.174719 msecs
 nil
 user= (time (dotimes [_ r] (concat coll '(:a
 Elapsed time: 5.366059 msecs
 nil
 user= (time (dotimes [_ r] (concat coll-v '(:a
 Elapsed time: 5.56465 msecs
 nil
 user= (time (dotimes [_ r] (conj coll-v :a)))
 Elapsed time: 10.65771 msecs
 nil
 user= (time (dotimes [_ r] (concat coll coll)))
 Elapsed time: 6.048041 msecs
 nil
 user= (time (dotimes [_ r] (apply conj coll-v coll-v)))
 Elapsed time: 72414.847105 msecs
 nil


Surprisingly it looks like (concat coll '(:a)) is faster than (conj coll-v 
:a). That's not really what I would expect; does anybody have a good 
explanation for this? Did I just bork the test somehow, or - I mean, 
obviously concat's pretty fast but I was expecting conj to be on the level. 
In fact, if you convert and then conj it's significantly slower than using 
concat.

...not that it'd really matter, in basically all cases, since (into [] ...) 
is definitely still in the fast enough category. Still, if you're 
building a sequence, what's the reasoning against using (concat coll ...) 
instead of (conj (into [] ...) ...)? Is it a matter of elegance, or is 
there a specific practical reason?

On Friday, February 7, 2014 8:06:20 PM UTC-8, Armando Blancas wrote:

 For efficient appends at the end you need a vector. Using the sequence 
 library can be tricky while you're putting together your data structures 
 because it's likely that you'll not done yet with type-specific functions. 
 You'll need to re-create your vector after using map/filter/etc to be able 
 to keep adding at the end. 

 On Friday, February 7, 2014 4:20:09 PM UTC-8, t x wrote:

 Consider the following: 

 (cons 1 '(2 3 4)) == (1 2 3 4) 
 (cons 1 [2 3 4])  == (1 2 3 4) 

 (conj '(a b c) 1) == (1 a b c) 
 (conj '[a b c] 1) == [a b c 1] 


  

 Now, I would like something that _always_ 
   * appends to the end 

 cons is almost what I want, except it always appends to front. 

 conj is not what I want -- in fact, I'm afraid of conj. Often times, 
 I'll run map/filter on something, and suddenly, instead of a vector, I 
 now have a list -- and conj changes the order of the item added. 

 Thus, my question: is there a builtin to _unconditinoally_ append to 
 the end of a list/sequence/vector? 

 Thanks! 



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To 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: unconditional append to end

2014-02-07 Thread Mark Engelberg
On Fri, Feb 7, 2014 at 9:08 PM, Travis Moy moytra...@gmail.com wrote:

 Surprisingly it looks like (concat coll '(:a)) is faster than (conj coll-v
 :a). That's not really what I would expect; does anybody have a good
 explanation for this? Did I just bork the test somehow, or - I mean,
 obviously concat's pretty fast but I was expecting conj to be on the level.
 In fact, if you convert and then conj it's significantly slower than using
 concat.


concat is lazy, so it's not really doing any work until you try to realize
the sequence -- that's why it is so fast.

-- 
You 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: map semantics

2014-02-07 Thread John D. Hume
On Fri, Feb 7, 2014 at 9:41 PM, Andy C andy.coolw...@gmail.com wrote:

 I do perceive sets, lists, vector as atoms which are indivisible (well,
 this is not true but this is popular meaning) from semantics standpoint.
 Therefore map is just a function which processes them as whole, again from
 semantics point of view. Implementation and laziness should not matter
 really and we still should get the same result.


Following your intuition, what would you expect from the following?
 (map + [1 3 5] '(2 4 6))
# = ?

-- 
You 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: use/require/import and quoted form

2014-02-07 Thread Matt Mitchell
Can you give a code example?

- Matt

On Thursday, February 6, 2014 3:15:13 AM UTC-5, Andy Smith wrote:

 Hi,

 I was wondering why use/require and import take quoted forms as their 
 arguments, other alternatives could be strings or keywords, so what is 
 special about the choice of quoted form here?

 Andy


-- 
You 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: map semantics

2014-02-07 Thread Mars0i
On Friday, February 7, 2014 10:17:15 PM UTC-6, Andy C wrote:

 But what really bothers me is that laziness / not laziness affects the 
 result of evaluation as in above example. That is against some fundamental 
 rules of FP (gotta check how Haskell does it :-P).


Well, it's not really laziness that's affecting the result of evaluation, 
in the sense that you mean.  It's just the design decision that the result 
of evaluation should always be the same type.  mapv does the same thing, 
but returns a vector.  Giving functions polymorphic return types makes 
things more complicated.

-- 
You 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: map semantics

2014-02-07 Thread Sean Corfield
But you're misunderstanding what map does: it converts its collection
arguments to _sequences_ and then it processes those sequences. Map
doesn't operate on sets, or vectors, or maps, only on sequences.

Scala goes out of its way to retain input types as output types on
many of its collection operations, and that's its choice. But it's not
how Clojure is defined - Clojure operates on abstractions above the
concrete types.

Sean

On Fri, Feb 7, 2014 at 10:43 PM, Andy C andy.coolw...@gmail.com wrote:

 Following your intuition, what would you expect from the following?
  (map + [1 3 5] '(2 4 6))
 # = ?


 It only gets worse, as the result of below should be undefined (using
 classic set definition):

 user= (map + #{0 1} #{0 1})
 (0 2)
 user= (map + #{1 0} #{1 0})
 (0 2)

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



-- 
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: unconditional append to end

2014-02-07 Thread Travis Moy
Ah! That makes more sense. Yeah, after I forced it to realize the sequence, 
it turned out that concat was a lot slower than sticking it into an array:

#'user/r
 user= (def coll (range 1))
 #'user/coll
 user= (def coll-v (into [] coll))
 #'user/coll-v
 user= (time (dotimes [_ r] (count (concat coll '(:a)
 Elapsed time: 55803.147526 msecs
 nil
 user= (time (dotimes [_ r] (count (conj coll-v :a
 Elapsed time: 18.591737 msecs
 nil
 user= (time (dotimes [_ r] (count (conj (into [] coll) :a
 Elapsed time: 16224.79319 msecs
 nil


On Friday, February 7, 2014 9:26:05 PM UTC-8, puzzler wrote:

 On Fri, Feb 7, 2014 at 9:08 PM, Travis Moy moyt...@gmail.comjavascript:
  wrote:

 Surprisingly it looks like (concat coll '(:a)) is faster than (conj 
 coll-v :a). That's not really what I would expect; does anybody have a good 
 explanation for this? Did I just bork the test somehow, or - I mean, 
 obviously concat's pretty fast but I was expecting conj to be on the level. 
 In fact, if you convert and then conj it's significantly slower than using 
 concat.


 concat is lazy, so it's not really doing any work until you try to realize 
 the sequence -- that's why it is so fast. 


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