How to unit test (defn-) functions?

2014-06-12 Thread Hussein B.
Hi,

I like to use (defn-) when it comes to internal implementation functions. 
But since they aren't exposed, how to unit test them?

Of course, I'm using Lein and clojure.test

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/d/optout.


Re: How to unit test (defn-) functions?

2014-06-12 Thread Ray Miller
On 12 June 2014 09:44, Hussein B. hubaghd...@gmail.com wrote:
 Hi,

 I like to use (defn-) when it comes to internal implementation functions.
 But since they aren't exposed, how to unit test them?

 Of course, I'm using Lein and clojure.test

It feels like a bit of a hack, but:

(#'other-ns/private-fn ...)

should get you by.

-- 
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/d/optout.


Re: [ANN] CrossClj, a tool for cross-referencing the clojure ecosystem

2014-06-12 Thread Francesco Bellomi
Hi Devin,

I'm a strong believer in contributing to the community. CrossClj is my 
first attempt to contribute to the clojure community, and I hope to do more 
in the future, even in source code form. 

At the moment, I don't feel like it's the right time to release the source 
code: it's a sort of personal playground on a series of themes I'm 
interested in (like static code analysis), and I'd like to figure out where 
it's headed, with the freedom to steer it into opinionated directions, 
whereas starting a community effort around it (like you suggest) would 
require a different *kind* of engagement

The sites you mentioned are all fantastic contributions (the way I hope 
CrossClj will be), but I'm not sure whether they need (or would be better) 
to be unified. They have, so to speak, different editorial voices, and I 
think this diversity is a value. For sure, I am favourable to integrate 
them (where appropriate) by linking their content and using their APIs, and 
I welcome them if they feel to do the same with CrossClj.
I think it's the same for all other language communities.

I really value all feedback, but I have my rationales.

I hope I don't sound arrogant: as a contemporary IT practitioner, I'm 
totally aware that I'm a dwarf standing on the shoulders of open-sourced 
giants, and that there are a lot of positive network effects; still, I 
don't feel I have a moral obligation to rush into releasing everything I 
do. 

thanks for your ideas, and I hope we will do something together in the 
future.

Francesco




On Thursday, June 12, 2014 3:23:31 AM UTC+2, Devin Walters (devn) wrote:

 Thanks for the reply Francesco. I know you said the code needs clean up 
 and all, but FWIW I haven't seen any project where that wasn't the case. 
 I'd encourage you to put it up on github. I for one would be interested in 
 contributing. I want to merge GetClojure, crossclj, clojuredocs, 
 clojuresphere, Clojars, and Clojure-doc into a one stop shop for all things 
 Clojure. All of the pieces have been worked out separately. With a little 
 bit of collaboration I think those of us interested in these sorts of 
 projects could build something really fantastic for the community.

 @Francesco  @All: Drop me a private email if you'd be interested in 
 discussing working on something like this. I'll set up a google hangout and 
 we can get together and talk about it. Think of the songs they'll write 
 about us if we succeed! :)

 Cheers,
 '(Devin Walters)

 On Jun 11, 2014, at 18:05, Francesco Bellomi francesc...@gmail.com 
 javascript: wrote:

 Devin,

 On Wednesday, June 11, 2014 6:25:13 PM UTC+2, Devin Walters (devn) wrote:

 A few nitpicks:


 Thanks for your feedback; I really appreciate any opinion or suggestion, 
 especially related to the UI
  

  
 - I find the usability to be a bit difficult in some places. For 
 instance, search results and specific function pages feel kind of cluttered.


 I understand that. I was trying to cram as much info as possible, and I 
 was too lazy to write some basic pagination facility. I think that the 
 problem is especially relevant when you have a lot of results. 
  

 - What does Some other projects... mean? Are they related to the 
 function I'm viewing, or are they just random projects?


 Totally random. I was trying to enable/facilitate some serendipitous 
 exploration.
  

 - It's not clear what kind of interaction is being encouraged by adding 
 the Google+ comments box. Maybe a slightly longer up-front explanation 
 about how you envision people using the site would be useful to people 
 trying it out?


 I agree with you, comments are not well-integrated and not really usable 
 right now, and it's not clear if (or how) they fit in the current iteration 
 of the project.
 I was inspired by clojuredocs.org commenting system, which I think is 
 really useful, but I don't have a clear answer right now on how it's 
 possible to bootstrap some kind of community activity around CrossClj. 
 Maybe it's a viable and good idea, maybe not.
  


 Finally, maybe you already explained this somewhere, so forgive me if I'm 
 adding noise, but are you using tools.analyze, codeq, etc. to do this? If 
 not, I'd be interested in hearing more about how you built it.


 It's not much complicated: for each namespace in each project, 
 tools.analyzer.* produces an AST that resolves var occurrences (definitions 
 and applications) in the source code into their fully namespace-qualified 
 vars; pomegranate resolves namespaces into their fully qualified artifacts 
 (in terms of maven coordinates). The combination of the two generates a 
 coherent addressing space that is used to generate the hyperlinks. Actual 
 links are positioned in the source code using the metadata in the AST.
 Lucene is used to maintain the inverse index (ie. var definition - var 
 application).
 Of course namespaces need to be macroexpanded and fully evaluated, which 
 causes a lot of funny side effects ;-) 

 Hope 

Re: How to unit test (defn-) functions?

2014-06-12 Thread James Reeves
On 12 June 2014 09:44, Hussein B. hubaghd...@gmail.com wrote:


 I like to use (defn-) when it comes to internal implementation functions.
 But since they aren't exposed, how to unit test them?


Generally speaking it's a bad idea to unit-test private functions (in any
language), as they're implementation details.

- James

-- 
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/d/optout.


Re: Clojure on iOS devices - Swift as a host?

2014-06-12 Thread Mike Fikes
Hi Devin,

A great place to start is 
http://web.cecs.pdx.edu/~cpinera/javascriptcore-integration-with-clojurescript-in-ios.html
 (some slight modifications are required to get that blog post examples working 
with the latest, but it's not that hard).

Another great resource is the WWDC 2013 video on JavaScriptCore.

Once you have a sample project up and running, then you are “cooking with 
fire.” Roughly the workflow involves editing ClojureScript (I use Cursive in 
IntelliJ, but any IDE would do) where the results of lein cljsbuild auto are 
being consumed in a “sibling” Xcode workspace. Make a change to ClojureScript, 
rebuild your Xcode app, observe the change in behavior, repeat.

Debugging is nearly impossible, so I rely heavily on logging, and on producing 
lots of pure functions that can be independently verified in a REPL. So the 
first thing you would want to do is set up things do that when you call a 
logging function in your ClojureScript, it is routed to iOS and logged in the 
console.

To avoid needing to add lots of new JSExport methods for new functionality, I 
take the approach of writing some plumbing code that can work with the UI by 
referencing UIComponents via their “tag” integer, which I manually set in IB 
and then call a “bind!” function in ClojureScript to set up the needed 
interactions.

For example, I might have a (def text-field (atom {})) and then in an init 
method marked ^:export that takes a view argument, I do (bind! text-field view 
1), where the literal 1 is the tag for a text field in IB. I've written bind to 
call into Objective C and register for notifications on that tag, setting 
things so that, for example, whenever the text changes, it calls back into 
ClojureScript executing a function that ends up calling (swap! text-view assoc 
:text updated-text).

You can take a similar approach to have button tap events drop a message into a 
core.async channel, and associated plumbing to bind a UI button to the channel.

The end result is that you can essentially write what would normally be view 
controller code in ClojureScript.

A lot of the above (especially the code fragments) are from memory—ask if you'd 
like more elaboration. But in the end, it's simpler and less elaborate than you 
might initially think.

- Mike

-- 
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/d/optout.


Re: [ANN] CrossClj, a tool for cross-referencing the clojure ecosystem

2014-06-12 Thread Devin Walters
You may be right about the union of all of these sites being difficult to 
harmonize editorially, but I will stubbornly continue to dream of that 
tool/explorer anyhow. :)

As for open source, no big deal if you don't ultimately decide to make your 
code available. You seem to know the drill, and no you don't come off as 
arrogant. To each their own.

Cheers,
'(Devin Walters)

 On Jun 12, 2014, at 6:05, Francesco Bellomi francesco.bell...@gmail.com 
 wrote:
 
 Hi Devin,
 
 I'm a strong believer in contributing to the community. CrossClj is my first 
 attempt to contribute to the clojure community, and I hope to do more in the 
 future, even in source code form. 
 
 At the moment, I don't feel like it's the right time to release the source 
 code: it's a sort of personal playground on a series of themes I'm interested 
 in (like static code analysis), and I'd like to figure out where it's headed, 
 with the freedom to steer it into opinionated directions, whereas starting a 
 community effort around it (like you suggest) would require a different 
 *kind* of engagement
 
 The sites you mentioned are all fantastic contributions (the way I hope 
 CrossClj will be), but I'm not sure whether they need (or would be better) to 
 be unified. They have, so to speak, different editorial voices, and I think 
 this diversity is a value. For sure, I am favourable to integrate them (where 
 appropriate) by linking their content and using their APIs, and I welcome 
 them if they feel to do the same with CrossClj.
 I think it's the same for all other language communities.
 
 I really value all feedback, but I have my rationales.
 
 I hope I don't sound arrogant: as a contemporary IT practitioner, I'm totally 
 aware that I'm a dwarf standing on the shoulders of open-sourced giants, and 
 that there are a lot of positive network effects; still, I don't feel I have 
 a moral obligation to rush into releasing everything I do. 
 
 thanks for your ideas, and I hope we will do something together in the future.
 
 Francesco
 
 
 
 
 On Thursday, June 12, 2014 3:23:31 AM UTC+2, Devin Walters (devn) wrote:
 Thanks for the reply Francesco. I know you said the code needs clean up and 
 all, but FWIW I haven't seen any project where that wasn't the case. I'd 
 encourage you to put it up on github. I for one would be interested in 
 contributing. I want to merge GetClojure, crossclj, clojuredocs, 
 clojuresphere, Clojars, and Clojure-doc into a one stop shop for all things 
 Clojure. All of the pieces have been worked out separately. With a little 
 bit of collaboration I think those of us interested in these sorts of 
 projects could build something really fantastic for the community.
 
 @Francesco  @All: Drop me a private email if you'd be interested in 
 discussing working on something like this. I'll set up a google hangout and 
 we can get together and talk about it. Think of the songs they'll write 
 about us if we succeed! :)
 
 Cheers,
 '(Devin Walters)
 
 On Jun 11, 2014, at 18:05, Francesco Bellomi francesc...@gmail.com wrote:
 
 Devin,
 
 On Wednesday, June 11, 2014 6:25:13 PM UTC+2, Devin Walters (devn) wrote:
 A few nitpicks:
 
 Thanks for your feedback; I really appreciate any opinion or suggestion, 
 especially related to the UI
  
  
 - I find the usability to be a bit difficult in some places. For instance, 
 search results and specific function pages feel kind of cluttered.
 
 I understand that. I was trying to cram as much info as possible, and I was 
 too lazy to write some basic pagination facility. I think that the problem 
 is especially relevant when you have a lot of results. 
  
 - What does Some other projects... mean? Are they related to the 
 function I'm viewing, or are they just random projects?
 
 Totally random. I was trying to enable/facilitate some serendipitous 
 exploration.
  
 - It's not clear what kind of interaction is being encouraged by adding 
 the Google+ comments box. Maybe a slightly longer up-front explanation 
 about how you envision people using the site would be useful to people 
 trying it out?
 
 I agree with you, comments are not well-integrated and not really usable 
 right now, and it's not clear if (or how) they fit in the current iteration 
 of the project.
 I was inspired by clojuredocs.org commenting system, which I think is 
 really useful, but I don't have a clear answer right now on how it's 
 possible to bootstrap some kind of community activity around CrossClj. 
 Maybe it's a viable and good idea, maybe not.
  
 
 Finally, maybe you already explained this somewhere, so forgive me if I'm 
 adding noise, but are you using tools.analyze, codeq, etc. to do this? If 
 not, I'd be interested in hearing more about how you built it.
 
 It's not much complicated: for each namespace in each project, 
 tools.analyzer.* produces an AST that resolves var occurrences (definitions 
 and applications) in the source code into their fully namespace-qualified 
 vars; pomegranate resolves 

Re: Clojure on iOS devices - Swift as a host?

2014-06-12 Thread Devin Walters
Very helpful info Mike, thank you.

I'll fire up Xcode this weekend, give what you're saying a try, and report back.

Thanks!
'(Devin Walters)

 On Jun 12, 2014, at 8:14, Mike Fikes mikefi...@me.com wrote:
 
 Hi Devin,
 
 A great place to start is 
 http://web.cecs.pdx.edu/~cpinera/javascriptcore-integration-with-clojurescript-in-ios.html
  (some slight modifications are required to get that blog post examples 
 working with the latest, but it's not that hard).
 
 Another great resource is the WWDC 2013 video on JavaScriptCore.
 
 Once you have a sample project up and running, then you are “cooking with 
 fire.” Roughly the workflow involves editing ClojureScript (I use Cursive in 
 IntelliJ, but any IDE would do) where the results of lein cljsbuild auto are 
 being consumed in a “sibling” Xcode workspace. Make a change to 
 ClojureScript, rebuild your Xcode app, observe the change in behavior, repeat.
 
 Debugging is nearly impossible, so I rely heavily on logging, and on 
 producing lots of pure functions that can be independently verified in a 
 REPL. So the first thing you would want to do is set up things do that when 
 you call a logging function in your ClojureScript, it is routed to iOS and 
 logged in the console.
 
 To avoid needing to add lots of new JSExport methods for new functionality, I 
 take the approach of writing some plumbing code that can work with the UI by 
 referencing UIComponents via their “tag” integer, which I manually set in IB 
 and then call a “bind!” function in ClojureScript to set up the needed 
 interactions.
 
 For example, I might have a (def text-field (atom {})) and then in an init 
 method marked ^:export that takes a view argument, I do (bind! text-field 
 view 1), where the literal 1 is the tag for a text field in IB. I've written 
 bind to call into Objective C and register for notifications on that tag, 
 setting things so that, for example, whenever the text changes, it calls back 
 into ClojureScript executing a function that ends up calling (swap! text-view 
 assoc :text updated-text).
 
 You can take a similar approach to have button tap events drop a message into 
 a core.async channel, and associated plumbing to bind a UI button to the 
 channel.
 
 The end result is that you can essentially write what would normally be view 
 controller code in ClojureScript.
 
 A lot of the above (especially the code fragments) are from memory—ask if 
 you'd like more elaboration. But in the end, it's simpler and less elaborate 
 than you might initially think.
 
 - Mike
 
 -- 
 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/d/optout.

-- 
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/d/optout.


Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Divyansh Prakash
I compare Clojure to acid in this 
http://pizzaforthought.blogspot.in/2014/06/clojurelisp-lsdmeditation.html 
rant.

-- 
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/d/optout.


Re: Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Divyansh Prakash
(and rant about other stuff I don't know a whole lot about)

-- 
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/d/optout.


Re: How to unit test (defn-) functions?

2014-06-12 Thread mynomoto
You can use a macro. Look how on 
http://nakkaya.com/2009/11/18/unit-testing-in-clojure/

On Thursday, June 12, 2014 5:44:21 AM UTC-3, Hussein B. wrote:

 Hi,

 I like to use (defn-) when it comes to internal implementation functions. 
 But since they aren't exposed, how to unit test them?

 Of course, I'm using Lein and clojure.test

 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/d/optout.


Re: Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Josh Kamau
I feel USED when you use the mailing list to drive traffic to your blog.


On Thu, Jun 12, 2014 at 4:44 PM, Divyansh Prakash 
divyanshprakas...@gmail.com wrote:

 (and rant about other stuff I don't know a whole lot about)

 --
 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/d/optout.


-- 
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/d/optout.


Re: Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Hussein B.
Thanks. Now, I have a clue how to skip some posts here.

On Thursday, June 12, 2014 3:41:13 PM UTC+2, Divyansh Prakash wrote:

 I compare Clojure to acid in this 
 http://pizzaforthought.blogspot.in/2014/06/clojurelisp-lsdmeditation.html 
 rant.


-- 
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/d/optout.


Re: How to unit test (defn-) functions?

2014-06-12 Thread Timothy Baldridge
I say this too many times on this list, but I'll say it again. The best way
to test defn- functions is to never use defn- in the first place. Instead
move implementation functions into an internal namespace that way they can
be accessed if needed, but are out of the way of the public api. It also
makes it easier for your users to tap into the core of your
library/application if needed. Trust your users to make good decisions,
make everything public, separate via namespaces.

For an example of this see: http://github.com/clojure/core.async

Timothy


On Thu, Jun 12, 2014 at 7:53 AM, mynomoto mynom...@gmail.com wrote:

 You can use a macro. Look how on
 http://nakkaya.com/2009/11/18/unit-testing-in-clojure/


 On Thursday, June 12, 2014 5:44:21 AM UTC-3, Hussein B. wrote:

 Hi,

 I like to use (defn-) when it comes to internal implementation functions.
 But since they aren't exposed, how to unit test them?

 Of course, I'm using Lein and clojure.test

 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/d/optout.




-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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/d/optout.


Re: How to unit test (defn-) functions?

2014-06-12 Thread J Irving
Hey Timothy

So I honestly don't mean to be a smart ass, but there are 6 defn- functions
in clojure.core.async - how do you test those? Or are they just considered
internals to other public functions?

cheers, J


On Thu, Jun 12, 2014 at 10:33 AM, Timothy Baldridge tbaldri...@gmail.com
wrote:

 I say this too many times on this list, but I'll say it again. The best
 way to test defn- functions is to never use defn- in the first place.
 Instead move implementation functions into an internal namespace that way
 they can be accessed if needed, but are out of the way of the public api.
 It also makes it easier for your users to tap into the core of your
 library/application if needed. Trust your users to make good decisions,
 make everything public, separate via namespaces.

 For an example of this see: http://github.com/clojure/core.async

 Timothy


 On Thu, Jun 12, 2014 at 7:53 AM, mynomoto mynom...@gmail.com wrote:

 You can use a macro. Look how on
 http://nakkaya.com/2009/11/18/unit-testing-in-clojure/


 On Thursday, June 12, 2014 5:44:21 AM UTC-3, Hussein B. wrote:

 Hi,

 I like to use (defn-) when it comes to internal implementation
 functions. But since they aren't exposed, how to unit test them?

 Of course, I'm using Lein and clojure.test

 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/d/optout.




 --
 “One of the main causes of the fall of the Roman Empire was that–lacking
 zero–they had no way to indicate successful termination of their C
 programs.”
 (Robert Firth)

 --
 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/d/optout.


-- 
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/d/optout.


Re: Clojure on iOS devices - Swift as a host?

2014-06-12 Thread Gregg Reynolds
On Thu, Jun 12, 2014 at 8:14 AM, Mike Fikes mikefi...@me.com wrote:

 Hi Devin,

 A great place to start is
 http://web.cecs.pdx.edu/~cpinera/javascriptcore-integration-with-clojurescript-in-ios.html
 (some slight modifications are required to get that blog post examples
 working with the latest, but it's not that hard).


Thanks for the great info.

I don't suppose you (or anybody else watching) have taken a crack at using
Cappuccino http://www.cappuccino-project.org/ with Clojurescript?

-Gregg

-- 
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/d/optout.


Re: How to unit test (defn-) functions?

2014-06-12 Thread Timothy Baldridge
There are 6 defn-'s in there? Rich must have wrote that code :-P .

But yes, defn- is mostly used in clojure.core and other such libraries for
functions that are created to simplify other functions. And I would
probably never test those.

Even then I would caution about using defn- too much as some have pointed
out functions like clojure.core/assert-args is kindof handy, but it's
private, so you can't touch it.

Also, core.async tends to take a in the large view of testing. For
example, the guts of the go macro are never tested. Instead the macro is
tested in about 50 different ways. The idea being that if a single one of
those tests fail it's easy to figure out what's wrong based on what passes
and fails.

Timothy


On Thu, Jun 12, 2014 at 8:44 AM, J Irving j...@lollyshouse.ca wrote:

 Hey Timothy

 So I honestly don't mean to be a smart ass, but there are 6 defn-
 functions in clojure.core.async - how do you test those? Or are they just
 considered internals to other public functions?

 cheers, J


 On Thu, Jun 12, 2014 at 10:33 AM, Timothy Baldridge tbaldri...@gmail.com
 wrote:

 I say this too many times on this list, but I'll say it again. The best
 way to test defn- functions is to never use defn- in the first place.
 Instead move implementation functions into an internal namespace that way
 they can be accessed if needed, but are out of the way of the public api.
 It also makes it easier for your users to tap into the core of your
 library/application if needed. Trust your users to make good decisions,
 make everything public, separate via namespaces.

 For an example of this see: http://github.com/clojure/core.async

 Timothy


 On Thu, Jun 12, 2014 at 7:53 AM, mynomoto mynom...@gmail.com wrote:

 You can use a macro. Look how on
 http://nakkaya.com/2009/11/18/unit-testing-in-clojure/


 On Thursday, June 12, 2014 5:44:21 AM UTC-3, Hussein B. wrote:

 Hi,

 I like to use (defn-) when it comes to internal implementation
 functions. But since they aren't exposed, how to unit test them?

 Of course, I'm using Lein and clojure.test

 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/d/optout.




 --
 “One of the main causes of the fall of the Roman Empire was that–lacking
 zero–they had no way to indicate successful termination of their C
 programs.”
 (Robert Firth)

 --
 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/d/optout.


  --
 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/d/optout.




-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

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

Re: Clojure on iOS devices - Swift as a host?

2014-06-12 Thread Mike Fikes
Not me, but if I needed to build a web app, Cappuccino and Om would be on my 
list of things to dig into

-- 
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/d/optout.


if else list of commands

2014-06-12 Thread Glen Rubin
Pretty basic question.  How do I run a couple commands in the else section 
on an if-else function?  Or can I only run one and need to define 
a function that does both commands?
 
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/d/optout.


Re: if else list of commands

2014-06-12 Thread Timothy Baldridge
(if true
  (do (something)
   (something-else))
  (do (something)
   42))


On Thu, Jun 12, 2014 at 9:33 AM, Glen Rubin rubing...@gmail.com wrote:

 Pretty basic question.  How do I run a couple commands in the else section
 on an if-else function?  Or can I only run one and need to define
 a function that does both commands?

 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/d/optout.




-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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/d/optout.


delete-file needs to be vector?

2014-06-12 Thread Glen Rubin
I wrote a fn to delete a couple files:
 
(defn del-temps
  (clojure.java.io/delete-file C:/temp/fs.png true)
  (clojure.java.io/delete-file C:/temp/fs.txt true))
 
 
When I run my program I get the following error: 
 
Exception in thread main java.lang.IllegalArgumentException: Parameter 
declaration clojure.java.io/delete-file should be a vector
 
 
It didn't look like delete-file takes a vector from the documentation?

-- 
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/d/optout.


Re: delete-file needs to be vector?

2014-06-12 Thread Kevin Ilchmann Jørgensen
You seem to be missing the parameter vector

(defn del-temps []  ..)
On Jun 12, 2014 6:14 PM, Glen Rubin rubing...@gmail.com wrote:

 I wrote a fn to delete a couple files:

 (defn del-temps
   (clojure.java.io/delete-file C:/temp/fs.png true)
   (clojure.java.io/delete-file C:/temp/fs.txt true))


 When I run my program I get the following error:

 Exception in thread main java.lang.IllegalArgumentException: Parameter
 declaration clojure.java.io/delete-file should be a vector


 It didn't look like delete-file takes a vector from the documentation?

 --
 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/d/optout.


-- 
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/d/optout.


delete-file needs to be vector?

2014-06-12 Thread Mike Fikes
I had the same happen to me several times and then I got wise to it :)

It is a correct diagnostic, but it would arguably be better if it could somehow 
simply indicate “function definition is missing a parameter declaration.”

-- 
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/d/optout.


if else list of commands

2014-06-12 Thread Mike Fikes
Also, check out when and when-not, which are great for conditionally executing 
some imperative code.

-- 
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/d/optout.


Re: Search seqs in seqs

2014-06-12 Thread Alex Walker
Updated the gist to fix a case '(:a :b) should've returned '((:a :b)) to 
match partition-by.

New: The sub-seq can optionally contain fns, just like partition-by's f 
param.

;; Case: using a seq of fns instead of values
(= (partition-by-seq [odd? odd? even?] [1 2 3 5 6 7 8 9 11 12]) 
   '((1 2) (3 5 6) (7 8) (9 11 12)))
 
;; Case: compare using a mix of fns and values
(= (partition-by-seq [odd? 10] [1 10 2 10 3 10 4 10 5 10 6])
'((1 10) (2 10) (3 10) (4 10) (5 10) (6)))


On Sunday, June 8, 2014 11:27:12 AM UTC-5, Alex Walker wrote:

 https://gist.github.com/alexpw/f20c7b3ac858003e07e2

 This version supports the missing case:

 ;; Case: false match :b, followed by true match :b :c
 (= (partition-by-seq [:b :c] [:a :b :b :c :e :d :a :b :c :d :a :b :c])
'((:a :b) (:b :c) (:e :d :a) (:b :c) (:d :a) (:b :c)))


 On Sunday, June 8, 2014 8:52:09 AM UTC-5, Alex Walker wrote:

 Err, this was bugging me all day when I went afk.  I wrote it too quickly 
 and am missing the case where the sub-seq starts right after seeing the 
 first val, [:b :b :c].

 Will fix it if I have time today, but may need to take a slightly 
 different approach.  Fun problem, btw. :)

 On Saturday, June 7, 2014 2:31:04 PM UTC-5, Alex Walker wrote:

 Here's a solution based on your description that behaves like core 
 partition fns, taking liberty to presume your example should've matched the 
 output below.

 (defn partition-by-seq
   [sub-seq coll]
   (letfn [(step [coll]
 (when-let [coll (seq coll)]
   (let [[run more] (split-with (partial not= (first sub-seq)) 
 coll)
 [possible-match more] (split-at (count sub-seq) more)]
 (if (= possible-match sub-seq)
 (if (seq run)
 (cons run (cons possible-match (lazy-seq (step 
 more
 (cons possible-match   (lazy-seq (step 
 more
 (cons (concat run possible-match)  (lazy-seq (step 
 more)))]
 (or (step coll) (
  
 = (partition-by-seq [:b :c] [])
  
 ()
  
 = (partition-by-seq [:b :c] [:a :d])
  
 ((:a :d))
  
 = (partition-by-seq [:b :c] [:a :b :c :d :a :b :c :d :a :b :c])
  
 ((:a) (:b :c) (:d :a) (:b :c) (:d :a) (:b :c))



 On Tuesday, June 3, 2014 4:05:16 AM UTC-5, Ulrich Küttler wrote:

 Hi,

 what is the preferred way to find sub-seqs in a seq? I am trying to 
 convert

 [:a :b :c :d :a :b :c :d :a :b :c]

 into

 ((:a) (:b :c) (:a :d) (:b :c) (:a))

 using the sub-seq (:b :c) instead of positions.

 partition, partition-by and the like all look at one element at a time. 
 What I need is a search based on seqs. Are there functions that support 
 such a search / split?

 Uli



-- 
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/d/optout.


Given a CSV file, how do I take the values in each row and convert it into a map?

2014-06-12 Thread Shelley Tong
kinda like a key value pair for each row

-- 
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/d/optout.


Re: Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Divyansh Prakash
Sorry if you feel that way. Thought i could share my thoughts and start an 
interesting discussion.
That is what the group is for.
You are obviously free to skip anything that doesn't interest you. That was the 
prime reason for the concise title.
I have no intentions of misleading anyone.

-- 
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/d/optout.


Re: Given a CSV file, how do I take the values in each row and convert it into a map?

2014-06-12 Thread Marc Limotte
See
https://github.com/clojure-cookbook/clojure-cookbook/blob/master/04_local-io/4-20_read-write-csv.asciidoc

Which will give you a seq of the values for each row.  To get Maps, try
this:

(def headers [colA colB ...])
(map (partial zipmap headers) result-of-read-csv)

If your headers are the first line in your CSV, then use (first
result-of-read-csv) to get the headers and (rest ...) for the data.




On Thu, Jun 12, 2014 at 5:17 PM, Shelley Tong shelleytong1...@gmail.com
wrote:

 kinda like a key value pair for each row

 --
 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/d/optout.


-- 
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/d/optout.


Re: Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Gary Trakhman
Twitter's a more organic way to do this.  Your followers can read it,
decide to retweet or not.


On Thu, Jun 12, 2014 at 5:37 PM, Divyansh Prakash 
divyanshprakas...@gmail.com wrote:

 Sorry if you feel that way. Thought i could share my thoughts and start an
 interesting discussion.
 That is what the group is for.
 You are obviously free to skip anything that doesn't interest you. That
 was the prime reason for the concise title.
 I have no intentions of misleading anyone.

 --
 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/d/optout.


-- 
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/d/optout.


Re: Given a CSV file, how do I take the values in each row and convert it into a map?

2014-06-12 Thread Devin Walters
I tend to do this: 

(require '[clojure.data.csv :as csv])
(require '[clojure.java.io :as io])
(require '[clojure.walk :as walk])

(let [[header rows] (- my.csv
io/file
io/reader
csv/read-csv)]
  (map #(- (zipmap header %)
(walk/keywordize-keys))
   rows))


= ({:a foo :b bar} {:a baz :b buzz} ...)

Cheers,
-- 
Devin Walters


On Thursday, June 12, 2014 at 4:38 PM, Marc Limotte wrote:

 See 
 https://github.com/clojure-cookbook/clojure-cookbook/blob/master/04_local-io/4-20_read-write-csv.asciidoc
 
 Which will give you a seq of the values for each row.  To get Maps, try this:
 
 (def headers [colA colB ...])
 (map (partial zipmap headers) result-of-read-csv)
 
 If your headers are the first line in your CSV, then use (first 
 result-of-read-csv) to get the headers and (rest ...) for the data.
 
 
 
 
 On Thu, Jun 12, 2014 at 5:17 PM, Shelley Tong shelleytong1...@gmail.com 
 (mailto:shelleytong1...@gmail.com) wrote:
  kinda like a key value pair for each row 
  
  -- 
  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%2bunsubscr...@googlegroups.com)
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  --- 
  You received this message because you are subscribed to the Google Groups 
  Clojure group.
  To 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/d/optout.
 
 -- 
 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/d/optout.

-- 
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/d/optout.


Re: How to unit test (defn-) functions?

2014-06-12 Thread Sean Corfield
On Thu, Jun 12, 2014 at 7:33 AM, Timothy Baldridge tbaldri...@gmail.com wrote:
 I say this too many times on this list, but I'll say it again. The best way
 to test defn- functions is to never use defn- in the first place. Instead
 move implementation functions into an internal namespace that way they can
 be accessed if needed, but are out of the way of the public api.

Just a note that I got essentially the opposite feedback from
Clojure/core about java.jdbc some time back. It had an implementation
namespace and an API namespace, and when I asked for feedback and what
needed to be addressed before considering a 1.0.0 release (yes, I was
planning well ahead), they said not to have a separate implementation
namespace. So java.jdbc is one namespace, with implementation details
as private functions now.
-- 
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/d/optout.


Re: Instaparse - thank you!

2014-06-12 Thread Daniel Kersten
I started playing with Instaparse recently too and its by far the nicest
parsing library I've used (after having used a few in C++, Java and Python
over the years). It makes parsing a pleasant and fun experience :)

So: Thank You Mark!


On 12 June 2014 03:43, Devin Walters dev...@gmail.com wrote:

 I think it's annularly understood that Mark is the bee's knees. Thanks for
 the fantastic, well-documented instaparse. It's saved me a *lot* of time to
 date, and it taught me a lot about parsers.

 Honorable mention to Sean Corfield for starting this thread and being such
 a model member of the community for what is shaping up to be the better
 part of a decade. Crazy, but true.

 Oh yeah, and all of you reading this. It's extremely exciting (and
 lucrative) to me to see all of my ranty Clojure is the future! bets
 paying off. :) Rhetorical question: How cool is it to be a part of this
 whole Clojure thing?

 Best Regards,
 '(Devin Walters)

 On Jun 11, 2014, at 20:25, Scott Thoman sc...@thoman.org wrote:

 +1 !

 I'm about to use it in a production deployment.  It has been a pleasure to
 use!

 --
 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/d/optout.

  --
 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/d/optout.


-- 
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/d/optout.


[ANN] New templating library - Scijors released

2014-06-12 Thread Marcin Skotniczny


https://camo.githubusercontent.com/e8f9c1a24fc4baa8a514e2f6e0b47744b95fb834/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f342f34332f5a61636b656e7363686572652e6a7067
It's my great pleasure to announce the first public release of my 
templating library:

https://github.com/cosmi/scijors

*Scijors* is a templating tool/library inspired by Clabango and Django 
templates (It's not inspired Selmer, because I started working on it long 
before Selmer was released).


*Main features:*

   - Contains a *real programming language* with fully fledged expressions, 
   looping constructs etc. (thanks to instaparse 
   https://github.com/Engelberg/instaparse). Also can access clojure 
   functions and symbols directly.
   - Based on a the concepts from Django templates like template 
   inheritance, blocks etc.
   - Filters from Django are supported (but most of the time unnecessary, 
   as you can access any code directly), tags are fully extendable (you can 
   inject any grammar you want in fact)
   - Super *fast* (compiled template is virtually as fast as native Clojure 
   code would be)
   - *Reloads on any change* - not only the main template file, but also 
   all included/inherited files

We've been using at Software Mansion for a long time and served probably 
billions of pages, so it is quite battle tested - although I'm publishing 
it publicly for the first time now.

I'm very eager to hear any feedback you can give me on this! 
*Is there any need to have any other templating library anyway? :)*

Thanks,
Marcin Skotniczny
*Software Mansion*


-- 
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/d/optout.


Re: Instaparse - thank you!

2014-06-12 Thread John Wiseman
Yes, instaparse is awesome.  (I use it to parse the grammar definitions of
my own natural language parser, which is a little funny).


On Thu, Jun 12, 2014 at 4:23 PM, Daniel Kersten dkers...@gmail.com wrote:

 I started playing with Instaparse recently too and its by far the nicest
 parsing library I've used (after having used a few in C++, Java and Python
 over the years). It makes parsing a pleasant and fun experience :)

 So: Thank You Mark!


 On 12 June 2014 03:43, Devin Walters dev...@gmail.com wrote:

 I think it's annularly understood that Mark is the bee's knees. Thanks
 for the fantastic, well-documented instaparse. It's saved me a *lot* of
 time to date, and it taught me a lot about parsers.

 Honorable mention to Sean Corfield for starting this thread and being
 such a model member of the community for what is shaping up to be the
 better part of a decade. Crazy, but true.

 Oh yeah, and all of you reading this. It's extremely exciting (and
 lucrative) to me to see all of my ranty Clojure is the future! bets
 paying off. :) Rhetorical question: How cool is it to be a part of this
 whole Clojure thing?

 Best Regards,
 '(Devin Walters)

 On Jun 11, 2014, at 20:25, Scott Thoman sc...@thoman.org wrote:

 +1 !

 I'm about to use it in a production deployment.  It has been a pleasure
 to use!

 --
 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/d/optout.

  --
 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/d/optout.


  --
 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/d/optout.


-- 
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/d/optout.


Functions in data structures?

2014-06-12 Thread Mike Fikes
Is there anything wrong with doing something like this?

(def foo (atom {:fn inc}))
((:fn @foo) 1)
; = 2

This works in Clojure and ClojureScript.

Just wondering if placing functions into immutable data structures could cause 
any grief. 

Or are functions sufficiently “first class” so that this is perfectly fine?

-- 
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/d/optout.


Re: Functions in data structures?

2014-06-12 Thread Jeremy Heiler
On Thu, Jun 12, 2014 at 9:31 PM, Mike Fikes mikefi...@me.com wrote:
 Is there anything wrong with doing something like this?

 (def foo (atom {:fn inc}))
 ((:fn @foo) 1)
 ; = 2

 This works in Clojure and ClojureScript.

 Just wondering if placing functions into immutable data structures could 
 cause any grief.

They could cause a problem if you intend to serialize your data
structures. Otherwise it's perfectly fine.

 Or are functions sufficiently “first class” so that this is perfectly fine?

-- 
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/d/optout.


Re: Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Atamert Ölçgen
There's also Planet Clojure http://clojure.in/.

@Divyansh

Josh, Hussein and Gary are not the only ones who think this sort of traffic
building is uncool. By traffic building I mean; sending a message with a
link that has no valuable information for the group members. They are
probably just nodding their head and thinking that sending another response
is not necessary. At least that's what I did before I saw your response.

90% of the messages in this group doesn't interest me. That's fine.
Valuable information for someone else. But I certainly wouldn't want
everybody to post their blogs here regularly. Because each message is a
tiny little distraction. I'm willing to pay the price because when a really
cool library is announced for example, I get a big reward. Let's keep the
benefit/cost ratio, time-wise  attention-wise, high.




On Thu, Jun 12, 2014 at 10:05 PM, Gary Trakhman gary.trakh...@gmail.com
wrote:

 Twitter's a more organic way to do this.  Your followers can read it,
 decide to retweet or not.


 On Thu, Jun 12, 2014 at 5:37 PM, Divyansh Prakash 
 divyanshprakas...@gmail.com wrote:

 Sorry if you feel that way. Thought i could share my thoughts and start
 an interesting discussion.
 That is what the group is for.
 You are obviously free to skip anything that doesn't interest you. That
 was the prime reason for the concise title.
 I have no intentions of misleading anyone.

 --
 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/d/optout.


  --
 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/d/optout.




-- 
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/d/optout.


Re: [ANN] New templating library - Scijors released

2014-06-12 Thread Atamert Ölçgen
Nice!

Since you use Django template syntax, you should get highlighting free in
some editors.


On Thu, Jun 12, 2014 at 11:31 PM, Marcin Skotniczny cosmi.co...@gmail.com
wrote:


 https://camo.githubusercontent.com/e8f9c1a24fc4baa8a514e2f6e0b47744b95fb834/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f342f34332f5a61636b656e7363686572652e6a7067
 It's my great pleasure to announce the first public release of my
 templating library:

 https://github.com/cosmi/scijors

 *Scijors* is a templating tool/library inspired by Clabango and Django
 templates (It's not inspired Selmer, because I started working on it long
 before Selmer was released).


 *Main features:*

- Contains a *real programming language* with fully fledged
expressions, looping constructs etc. (thanks to instaparse
https://github.com/Engelberg/instaparse). Also can access clojure
functions and symbols directly.
- Based on a the concepts from Django templates like template
inheritance, blocks etc.
- Filters from Django are supported (but most of the time unnecessary,
as you can access any code directly), tags are fully extendable (you can
inject any grammar you want in fact)
- Super *fast* (compiled template is virtually as fast as native
Clojure code would be)
- *Reloads on any change* - not only the main template file, but also
all included/inherited files

 We've been using at Software Mansion for a long time and served probably
 billions of pages, so it is quite battle tested - although I'm publishing
 it publicly for the first time now.

 I'm very eager to hear any feedback you can give me on this!
 *Is there any need to have any other templating library anyway? :)*

 Thanks,
 Marcin Skotniczny
 *Software Mansion*


  --
 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/d/optout.




-- 
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/d/optout.


Re: Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Gary Trakhman
To be fair, I actually read the thing, but I hoped to see more interesting
information on LSD, meditation and Clojure than the headline would suggest
:-).


On Thu, Jun 12, 2014 at 10:01 PM, Atamert Ölçgen mu...@muhuk.com wrote:

 There's also Planet Clojure http://clojure.in/.

 @Divyansh

 Josh, Hussein and Gary are not the only ones who think this sort of
 traffic building is uncool. By traffic building I mean; sending a message
 with a link that has no valuable information for the group members. They
 are probably just nodding their head and thinking that sending another
 response is not necessary. At least that's what I did before I saw your
 response.

 90% of the messages in this group doesn't interest me. That's fine.
 Valuable information for someone else. But I certainly wouldn't want
 everybody to post their blogs here regularly. Because each message is a
 tiny little distraction. I'm willing to pay the price because when a really
 cool library is announced for example, I get a big reward. Let's keep the
 benefit/cost ratio, time-wise  attention-wise, high.




 On Thu, Jun 12, 2014 at 10:05 PM, Gary Trakhman gary.trakh...@gmail.com
 wrote:

 Twitter's a more organic way to do this.  Your followers can read it,
 decide to retweet or not.


 On Thu, Jun 12, 2014 at 5:37 PM, Divyansh Prakash 
 divyanshprakas...@gmail.com wrote:

 Sorry if you feel that way. Thought i could share my thoughts and start
 an interesting discussion.
 That is what the group is for.
 You are obviously free to skip anything that doesn't interest you. That
 was the prime reason for the concise title.
 I have no intentions of misleading anyone.

 --
 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/d/optout.


  --
 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/d/optout.




 --
 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/d/optout.


-- 
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/d/optout.


raspberry pi and clojure

2014-06-12 Thread Andre Perez
Hi everyone, I just started trying to play with a raspberry pi for a 
variety of reasons, and given that java runs on it, I decided to use this 
as an opportunity to learn clojure.  I'm playing with a blinkIo example 
which looks like this: 

public class BlinkGpioExample {


 public static void main(String[] args) throws InterruptedException {


 System.out.println(--Pi4J-- GPIO Blink Example ... started.);


 // create gpio controller

 final GpioController gpio = GpioFactory.getInstance();


 // provision gpio pin #01  #03 as an output pins and blink

 final GpioPinDigitalOutput resevoirPumpLine = gpio

  .provisionDigitalOutputPin(RaspiPin.GPIO_01);

 final GpioPinDigitalOutput troughFillLine = gpio

  .provisionDigitalOutputPin(RaspiPin.GPIO_03);


 // provision gpio pin #02 as an input pin with its internal pull down

 // resistor enabled

 final GpioPinDigitalInput resevoirSwitch = gpio.provisionDigitalInputPin(

  RaspiPin.GPIO_14, Resevoir Switch, PinPullResistance.PULL_DOWN);

 final GpioPinDigitalInput trougSwitch = gpio.provisionDigitalInputPin(

  RaspiPin.GPIO_13, Trough Switch, PinPullResistance.PULL_DOWN);

 resevoirSwitch.setShutdownOptions(true);

 // create and register gpio pin listener

 resevoirSwitch.addListener(new GpioPinListenerDigital() {

 @Override

 public void handleGpioPinDigitalStateChangeEvent(

  GpioPinDigitalStateChangeEvent event) {

  // when button is pressed, speed up the blink rate on LED #2

  if (event.getState().isHigh()) {

  System.out.println(event.getPin().getName() +  do nothing);

  } else {

  resevoirPumpLine.blink(1000);

 }

 }

 });


 trougSwitch.addListener(new GpioPinListenerDigital() {


  @Override

 public void handleGpioPinDigitalStateChangeEvent(

  GpioPinDigitalStateChangeEvent event) {

  if (event.getState().isHigh()) {

  System.out.println(event.getPin().getName() +   do nothing);

  } else {

  //stick value into a flat file or in mem database;

  troughFillLine.blink(1000);

  }


  }

 });


 System.out

  .println( ... the LED will continue blinking until the program is 
terminated.);

 System.out.println( ... PRESS CTRL-C TO STOP THE PROGRAM.);


 // keep program running until user aborts (CTRL-C)

 for (;;) {

 Thread.sleep(500);

 }


 }

}

 

Since I am quite new to clojure, i attempted to do a straight port to 
clojure (as opposed to writing the blinkio in a more functional manner) and 
came up with :

(def factory (GpioFactory/getInstance) )


(def pumpOutput (.provisionDigitalOutputPin factory RaspiPin/GPIO_01))

(def troughOutput (.provisionDigitalOutputPin factory RaspiPin/GPIO_03))



(def pumpInput (.provisionDigitalInputPin factory RaspiPin/GPIO_13 
troughSwitch PinPullResistance/PULL_DOWN))

(def resevoirInput (.provisionDigitalInputPin factory RaspiPin/GPIO_14 
resevoirSwitch PinPullResistance/PULL_DOWN))



(def resevoirListener (reify com.pi4j.io.gpio.event.GpioPinListenerDigital (
handleGpioPinDigitalStateChangeEvent [this event] (printf resevoir here)))
)

(.addListener resevoirInput [^com.pi4j.io.gpio.event.GpioPinListenerDigital 
resevoirListener] )


(def troughListener (reify com.pi4j.io.gpio.event.GpioPinListenerDigital (
handleGpioPinDigitalStateChangeEvent [this event] (printf trough here

(.addListener resevoirInput [^com.pi4j.io.gpio.event.GpioPinListenerDigital 
troughListener] )


(defn infinite[f seconds](future (loop []  (f) (Thread/sleep 
(* seconds 1000))  (recur


(infinite (printf \nlooping) 10)


**

My question:  This compiles, and runs, but doesn't actually do anything 
when I manipulate the PI io.  I am thinking I have to do something 
regarding defining my inputIOs as atoms, but I'm still trying to get my 
head wrapped around that concept. Could someone please point me in the 
right direction to get my (printf trough /resevoir here) messages to 
display?  Mind you that there isn't a problem with any of the wiring on the 
PI, it is verified in the java version of this program.  I am just having 
trouble porting this code.  


Thanks for any help!

Andre

-- 
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/d/optout.


Re: raspberry pi and clojure

2014-06-12 Thread Atamert Ölçgen
Hi Andre,

When I tried to run your code, it didn't compile for me:

user= (defn infinite[f seconds](future (loop []  (f)
(Thread/sleep (* seconds 1000))  (recur
#'user/infinite
user= (infinite (printf \nlooping) 10)

looping
NullPointerException   user/infinite/fn--2267 (NO_SOURCE_FILE:1)
user=


When you call infinite, (printf \nlooping) gets evaluated, produces
expected side-effect, returns nil. This happens before infinite is
executed. Within infinite (f) is effectively (nil).

Also it seems you want to block. But because your loop is wrapped with a
future, it runs in a separate thread. So it doesn't block. After infinite
is called, the program exits. Possibly before (f) is executed.





On Fri, Jun 13, 2014 at 4:33 AM, Andre Perez andreope...@gmail.com wrote:

 Hi everyone, I just started trying to play with a raspberry pi for a
 variety of reasons, and given that java runs on it, I decided to use this
 as an opportunity to learn clojure.  I'm playing with a blinkIo example
 which looks like this:

 public class BlinkGpioExample {


  public static void main(String[] args) throws InterruptedException {


  System.out.println(--Pi4J-- GPIO Blink Example ... started.);


  // create gpio controller

  final GpioController gpio = GpioFactory.getInstance();


  // provision gpio pin #01  #03 as an output pins and blink

  final GpioPinDigitalOutput resevoirPumpLine = gpio

   .provisionDigitalOutputPin(RaspiPin.GPIO_01);

  final GpioPinDigitalOutput troughFillLine = gpio

   .provisionDigitalOutputPin(RaspiPin.GPIO_03);


  // provision gpio pin #02 as an input pin with its internal pull down

  // resistor enabled

  final GpioPinDigitalInput resevoirSwitch = gpio.provisionDigitalInputPin(

   RaspiPin.GPIO_14, Resevoir Switch, PinPullResistance.PULL_DOWN);

  final GpioPinDigitalInput trougSwitch = gpio.provisionDigitalInputPin(

   RaspiPin.GPIO_13, Trough Switch, PinPullResistance.PULL_DOWN);

  resevoirSwitch.setShutdownOptions(true);

  // create and register gpio pin listener

  resevoirSwitch.addListener(new GpioPinListenerDigital() {

  @Override

  public void handleGpioPinDigitalStateChangeEvent(

   GpioPinDigitalStateChangeEvent event) {

   // when button is pressed, speed up the blink rate on LED #2

   if (event.getState().isHigh()) {

   System.out.println(event.getPin().getName() +  do nothing);

   } else {

   resevoirPumpLine.blink(1000);

  }

  }

  });


  trougSwitch.addListener(new GpioPinListenerDigital() {


   @Override

  public void handleGpioPinDigitalStateChangeEvent(

   GpioPinDigitalStateChangeEvent event) {

   if (event.getState().isHigh()) {

   System.out.println(event.getPin().getName() +   do nothing);

   } else {

   //stick value into a flat file or in mem database;

   troughFillLine.blink(1000);

   }


   }

  });


  System.out

   .println( ... the LED will continue blinking until the program is
 terminated.);

  System.out.println( ... PRESS CTRL-C TO STOP THE PROGRAM.);


  // keep program running until user aborts (CTRL-C)

  for (;;) {

  Thread.sleep(500);

  }


  }

 }



 Since I am quite new to clojure, i attempted to do a straight port to
 clojure (as opposed to writing the blinkio in a more functional manner) and
 came up with :

 (def factory (GpioFactory/getInstance) )


 (def pumpOutput (.provisionDigitalOutputPin factory RaspiPin/GPIO_01))

 (def troughOutput (.provisionDigitalOutputPin factory RaspiPin/GPIO_03))



 (def pumpInput (.provisionDigitalInputPin factory RaspiPin/GPIO_13
 troughSwitch PinPullResistance/PULL_DOWN))

 (def resevoirInput (.provisionDigitalInputPin factory RaspiPin/GPIO_14
 resevoirSwitch PinPullResistance/PULL_DOWN))



 (def resevoirListener (reify
 com.pi4j.io.gpio.event.GpioPinListenerDigital (
 handleGpioPinDigitalStateChangeEvent [this event] (printf resevoir here)
 )))

 (.addListener resevoirInput [
 ^com.pi4j.io.gpio.event.GpioPinListenerDigital resevoirListener] )


 (def troughListener (reify com.pi4j.io.gpio.event.GpioPinListenerDigital (
 handleGpioPinDigitalStateChangeEvent [this event] (printf trough here)))
 )

 (.addListener resevoirInput [
 ^com.pi4j.io.gpio.event.GpioPinListenerDigital troughListener] )


 (defn infinite[f seconds](future (loop []  (f) (
 Thread/sleep (* seconds 1000))  (recur


 (infinite (printf \nlooping) 10)


 **

 My question:  This compiles, and runs, but doesn't actually do anything
 when I manipulate the PI io.  I am thinking I have to do something
 regarding defining my inputIOs as atoms, but I'm still trying to get my
 head wrapped around that concept. Could someone please point me in the
 right direction to get my (printf trough /resevoir here) messages to
 display?  Mind you that there isn't a problem with any of the wiring on the
 PI, it is verified in the java version of this program.  I am just having
 trouble porting this code.


 Thanks for any help!

 Andre

 --
 You received this message because you are