Group words by their first letter and sum their frequencies

2013-07-11 Thread James Trunk
Hi everyone, I'm new to Clojure and trying to learn my way around the 
language.

I've written a function that sums the frequencies of words starting with 
the same letter, however I'm not fully satisfied with the result. I'm 
striving for readability and idomaticity, but I fear that my rather limited 
grasp of Clojure's core functions and lack of experience with functional 
programming are letting me down on both counts.

(def text (slurp "http://www.ccel.org/ccel/bible/kjv.txt";))

(defn sum-last-elements [coll]
  (reduce + (map last coll)))

(defn group-first-elements [coll]
  (map first coll))

(->> text
 (re-seq 
#"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))")
 frequencies
 (group-by ffirst)
 vals
 (#(zipmap (map group-first-elements %) (map sum-last-elements %

Which on that file gives the result:

{("woman" "women") 663, ("children" "child") 2274, ("men" "man") 5314}

My questions:

   1. Is there a way to avoid using ?: everywhere in the regex?
   2. (group-by ffirst) vals - is there a more 
   readable/declarative/idiomatic way to group by first letter?
   3. Is there a trick to avoid the ugly looking anonymous function (which 
   I'm only using to reorder the thread-last argument)?
   4. Is it idiomatic to extract small functions to give them names (with 
   an eye to aiding readability) or would most Clojure programmers prefer 
   these to be anonymous and in-line?
   5. Is thread-last the right approach when dealing with nested 
   data-structures or is list comprehension, or some other approach preferred?

Thanks in advance for any help.

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




Re: Group words by their first letter and sum their frequencies

2013-07-11 Thread James Trunk
Hello Laurent,

Thank you so much for your detailed and helpful reply.

> You could use the new as-> macro in clojure 1.5 
Is it possible to get as-> to work with thread-last?

> depends :-) since your 2 fns are helper fns rather than 
> generically-reusable fns, I would make them private to enforce that : 
> (defn- ...)
Good point, and I'll definitely try to remember that in the future.

> May I suggest alternative implementations ?
> 
I really like both of your alternative solutions, and have learned several 
new ideas from them. Thank you.

By the way, I'm using the Clojure Cheat Sheet 
(http://clojure.org/cheatsheet) as my guide to the core functions, but it 
doesn't seem to be up-to-date with all these fancy 1.5 functions that 
you're using. Is there a new website that has superseded CCS? Do you know 
why CCS isn't kept up-to-date?

Regards,
James

On Thursday, July 11, 2013 2:29:38 PM UTC+2, Laurent PETIT wrote:
>
> Hello James, 
>
> 2013/7/11 James Trunk >: 
> > Hi everyone, I'm new to Clojure and trying to learn my way around the 
> > language. 
> > 
> > I've written a function that sums the frequencies of words starting with 
> the 
> > same letter, however I'm not fully satisfied with the result. I'm 
> striving 
> > for readability and idomaticity, but I fear that my rather limited grasp 
> of 
> > Clojure's core functions and lack of experience with functional 
> programming 
> > are letting me down on both counts. 
> > 
> > (def text (slurp "http://www.ccel.org/ccel/bible/kjv.txt";)) 
> > 
> > (defn sum-last-elements [coll] 
> >   (reduce + (map last coll))) 
> > 
> > (defn group-first-elements [coll] 
> >   (map first coll)) 
> > 
> > (->> text 
> >  (re-seq 
> > #"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))") 
> >  frequencies 
> >  (group-by ffirst) 
> >  vals 
> >  (#(zipmap (map group-first-elements %) (map sum-last-elements % 
> > 
> > Which on that file gives the result: 
> > 
> > {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 5314} 
> > 
> > My questions: 
> > 
> > Is there a way to avoid using ?: everywhere in the regex? 
> > (group-by ffirst) vals - is there a more readable/declarative/idiomatic 
> way 
> > to group by first letter? 
>
> you could first (group-by first), then create the final map by calling 
> (distinct) and count 
>
> > Is there a trick to avoid the ugly looking anonymous function (which I'm 
> > only using to reorder the thread-last argument)? 
>
> You could use the new as-> macro in clojure 1.5 
>
> > Is it idiomatic to extract small functions to give them names (with an 
> eye 
> > to aiding readability) or would most Clojure programmers prefer these to 
> be 
> > anonymous and in-line? 
>
> depends :-) since your 2 fns are helper fns rather than 
> generically-reusable fns, I would make them private to enforce that : 
> (defn- ...) 
>
> > Is thread-last the right approach when dealing with nested 
> data-structures 
> > or is list comprehension, or some other approach preferred? 
>
> The thread-last as you employed it is fine by me. 
>
> May I suggest alternative implementations ? 
>
> (def text (slurp "http://www.ccel.org/ccel/bible/kjv.txt";)) 
> (let [words (re-seq 
> #"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))" 
> text) 
>words-per-initial (vals (group-by first words))] 
>   (zipmap 
> (map distinct words-per-initial) 
> (map count words-per-initial))) 
>
> ;; => {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 
> 5314} 
>
>
>
> or to avoid the intermediary creation of seqs of distincts and seqs of 
> counts: 
>
> (defn- reduce-initial [m initial initial-words] 
>   (assoc m (distinct initial-words) (count initial-words))) 
>
> (let [words (re-seq 
> #"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))" 
> text) 
>words-per-initial (group-by first words)] 
>   (reduce-kv reduce-initial {} words-per-initial)) 
>
> ;; => {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 
> 5314} 
>
>
> HTH, 
>
> -- 
> Laurent 
>

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




Re: Group words by their first letter and sum their frequencies

2013-07-11 Thread James Trunk
Hi Andy,

I'd missed the more recent versions with tool-tips, thank you for pointing 
me to them.

Regards,
James

On Thursday, July 11, 2013 5:11:21 PM UTC+2, Andy Fingerhut wrote:
>
> There is a link "Download other versions with tooltips" near the top of 
> the Clojure Cheat Sheet page (http://clojure.org/cheatsheet) that links 
> to versions that are a bit more recent, and they include tooltips of the 
> doc strings when you hover your cursor over the symbol.
>
> The version at clojure.org/cheatsheet gets updated less frequently, 
> simply because I have to ask someone else to do it who has the necessary 
> permissions.  I'll ask again now.
>
> Andy
>
>
> On Thu, Jul 11, 2013 at 6:50 AM, James Trunk 
> > wrote:
>
>> Hello Laurent,
>>
>> Thank you so much for your detailed and helpful reply.
>>
>> > You could use the new as-> macro in clojure 1.5 
>> Is it possible to get as-> to work with thread-last?
>>
>> > depends :-) since your 2 fns are helper fns rather than 
>> > generically-reusable fns, I would make them private to enforce that : 
>> > (defn- ...)
>> Good point, and I'll definitely try to remember that in the future.
>>
>> > May I suggest alternative implementations ?
>> > 
>> I really like both of your alternative solutions, and have learned 
>> several new ideas from them. Thank you.
>>
>> By the way, I'm using the Clojure Cheat Sheet (
>> http://clojure.org/cheatsheet) as my guide to the core functions, but it 
>> doesn't seem to be up-to-date with all these fancy 1.5 functions that 
>> you're using. Is there a new website that has superseded CCS? Do you know 
>> why CCS isn't kept up-to-date?
>>
>> Regards,
>> James
>>
>> On Thursday, July 11, 2013 2:29:38 PM UTC+2, Laurent PETIT wrote:
>>
>>> Hello James, 
>>>
>>> 2013/7/11 James Trunk : 
>>> > Hi everyone, I'm new to Clojure and trying to learn my way around the 
>>> > language. 
>>> > 
>>> > I've written a function that sums the frequencies of words starting 
>>> with the 
>>> > same letter, however I'm not fully satisfied with the result. I'm 
>>> striving 
>>> > for readability and idomaticity, but I fear that my rather limited 
>>> grasp of 
>>> > Clojure's core functions and lack of experience with functional 
>>> programming 
>>> > are letting me down on both counts. 
>>> > 
>>> > (def text (slurp 
>>> > "http://www.ccel.org/ccel/**bible/kjv.txt<http://www.ccel.org/ccel/bible/kjv.txt>"))
>>> >  
>>>
>>> > 
>>> > (defn sum-last-elements [coll] 
>>> >   (reduce + (map last coll))) 
>>> > 
>>> > (defn group-first-elements [coll] 
>>> >   (map first coll)) 
>>> > 
>>> > (->> text 
>>> >  (re-seq 
>>> > #"(?:(?:\bm[a|e]n\b)|(?:\bwom[**a|e]n\b)|(?:\bchild\b)|(?:\**bchildren\b))")
>>> >  
>>>
>>> >  frequencies 
>>> >  (group-by ffirst) 
>>> >  vals 
>>> >  (#(zipmap (map group-first-elements %) (map sum-last-elements 
>>> % 
>>> > 
>>> > Which on that file gives the result: 
>>> > 
>>> > {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 5314} 
>>> > 
>>> > My questions: 
>>> > 
>>> > Is there a way to avoid using ?: everywhere in the regex? 
>>> > (group-by ffirst) vals - is there a more 
>>> readable/declarative/idiomatic way 
>>> > to group by first letter? 
>>>
>>> you could first (group-by first), then create the final map by calling 
>>> (distinct) and count 
>>>
>>> > Is there a trick to avoid the ugly looking anonymous function (which 
>>> I'm 
>>> > only using to reorder the thread-last argument)? 
>>>
>>> You could use the new as-> macro in clojure 1.5 
>>>
>>> > Is it idiomatic to extract small functions to give them names (with an 
>>> eye 
>>> > to aiding readability) or would most Clojure programmers prefer these 
>>> to be 
>>> > anonymous and in-line? 
>>>
>>> depends :-) since your 2 fns are helper fns rather than 
>>> generically-reusable fns, I would make them priva

Re: [ANN] Dunaj project, an alternative core API for Clojure

2015-03-20 Thread James Trunk
Congratulations on the release!

Thank you for putting yourself and your ideas out there in this way, and 
for reminding us not to settle for what we have now, but to continually 
push towards ever greater heights.

Best,
James

On Friday, March 20, 2015 at 6:35:37 AM UTC+1, Jozef Wagner wrote:
>
> Dunaj, an alternative core API for Clojure, has been released! 
> Try it yourself and check out its extensive documentation at 
> http://www.dunaj.org/
>
> Last Dunaj experiment aims to improve API's primary documentation.
>
> Official documentation is available at project's homepage at
> http://www.dunaj.org. API and SPI documentation is
> automatically generated from Dunaj sources. Other parts of
> the documentation are written in AsciiDoc format and are available in
> project's repository alongside other sources.
> Everything is released under the same license as Clojure.
>
> Library used for the actual documentation generation can be used
> to generate documentation for any Clojure project, and will be
> released soon.
>
> API documentation is presented in a clear and user friendly way.
> Vars in a given namespace are grouped by their purpose into
> several categories. In addition to Var's docstring, type signatures,
> examples and see also references are provided.
>
> Moreover, Dunaj defines new metadata keys for vars that provide
> additional information to IDEs. With these metadata, editors can
> offer improved and more precise highlighting and indentation.
>
> You can read about this and previous experiments at the documentation
> section of Dunaj at http://www.dunaj.org/doc.html 
>
> Best,
> Jozef Wagner
>
> On Thursday, March 5, 2015 at 10:33:53 PM UTC+1, Jozef Wagner wrote:
>>
>> I'm happy to announce a project called Dunaj [1], which provides an 
>> alternative core API for Clojure. Its main aim is to experimentally test 
>> major additions to the language. 
>>
>> Dunaj /ˈdunaɪ/ is a set of core language experiments aimed to improve 
>> Clojure language and its core API. It deals with language features that 
>> require changes across different parts of Clojure and which cannot be 
>> evaluated in isolation. Dunaj aims to bring Clojure even more towards 
>> simplicity, consistency and performance. 
>> It is intended to be used by regular Clojure developers, either for 
>> application or library development.
>>
>> Dunaj was created to test 10 experiments that bring significant changes 
>> to the Clojure language. As there is a substantial number of additions and 
>> changes, I want to try a bit unconventional approach here. Before I'll 
>> release the actual library, I will introduce Dunaj's experiments in a 
>> series of individual posts. Every part states the motivation behind the 
>> experiment, introduces changes and additions to the language and 
>> demonstrates its intended use. If you do not want to miss any of this, you 
>> may want to register for a mailing list at [1] or follow @dunajproject at 
>> Twitter.
>>
>> -- Jozef Wagner
>>
>> [1] http://www.dunaj.org/ 
>>
>>

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

2014-02-05 Thread James Trunk
As a TDD practitioner and 
Expectationsuser, I've been 
following this thread with great interest! 

@Jay: Will your change in thinking have any impact on Expectations?

My experience with TDD in Clojure has been an overwhelmingly positive one, 
and it seems like this thread might be a good place to discuss the subject 
with others.

RDD is an invaluable tool for evolving the shape of your functions, and 
it's a killer feature for REPL-based languages like Clojure. However, I 
mainly use RDD in the refactoring stage of TDD, and I still choose the 
overhead of writing tests before coding my solutions. Why do I do that? 
Well, I experience a number of benefits from TDD:

   - A very clear separation of thinking between requirements and solution
   - A constant focus on delivering the Minimum Viable Product
   - Documentation, in English, of the expected behaviour of a function
   - Documentation, in code, of example inputs and expected outputs of a 
   function (especially useful in a dynamic language like Clojure)
   - A continual reminder (and perfect opportunity) to refactor
   - A refactoring confidence boost (i.e. if all my tests are still green, 
   then I can be pretty confident in that refactor)
   - The little bit of serotonin released in your brain when you make the 
   next test turn green :-)
   - Finishing a session with a red test gives you a great starting point 
   for your next session and often helps you to get straight back into "the 
   zone"
   - A clear handover point if you're pair-programming

It's clear that developers who don't use TDD can (and do) develop extremely 
high quality solutions. However, for me personally, the list of benefits 
from doing TDD outweigh the cost of writing and maintaining the tests. I am 
a better programmer when I use TDD. I prefer jumping into other people's 
codebases when they have used TDD. I find it easier to get back into one of 
my own old projects when I've used TDD.

I also understand that most other programmers don't agree with me on this, 
which might mean that I'm wrong. :-)

Cheers,
James

On Tuesday, February 4, 2014 1:06:06 PM UTC+1, Jay Fields wrote:
>
> tl; dr: I'm presenting "Lessons Learned from Adopting Clojure" in 
> Chicago on Feb 11th: 
>
> http://www.eventbrite.com/e/goto-night-with-jay-fields-tickets-10366768283?aff=eorgf
>  
>
> Five years ago DRW Trading was primarily a Java shop, and I was 
> primarily developing in Ruby. Needless to say, it wasn't a match made 
> in heaven. Fast forward five years, Clojure is the second most used 
> language in the firm, and the primary language for several teams 
> (including mine). Clojure wasn't the first language that I've 
> introduced to an organization; however, it's unquestionably the most 
> successful adoption I've ever been a part of. The use of Clojure has 
> had many impacts on the firm: culturally, politically, and 
> technically. My talk will discuss general ideas around language 
> selection and maintenance trade-offs, and specific examples of what 
> aspects of Clojure made it the correct choice for us. 
>
> A few highlights 
>
> - Where to first introduce a new language and your role as the 
> language care-taker. 
> - REPL driven development, putting TDD's 'rapid feedback' to shame. 
> - Operations impact of adding a language - i.e. get ready for some DevOps. 
> - Functional programming, the Lisp Advantage, and their impact on 
> maintainability. 
>
> Of course, no good experience report is all roses. The adoption has 
> seen several hurdles along the way, and I'll happily to describe those 
> as well. 
>

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


[Video] The case for Clojure

2014-03-01 Thread James Trunk
Hi everyone,

I made a new video about Clojure that I wanted to share with you all. It's 
a sales pitch for choosing Clojure as the language for your next project:

The case for Clojure 

I realise that if you're reading this discussion group there's a good 
chance that you've already made that choice, and don't need me to convince 
you. You guys aren't actually the target audience for the video, but, if 
you have the time, I'd love it if you'd watch it anyway. Then, if you think 
it's good enough, you can pass it on to any friends or colleagues who 
you're trying to convince to take a look at Clojure.

Cheers,
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/groups/opt_out.


Re: ANN simple-time

2014-03-20 Thread James Trunk
Hi Matt,

Thanks for your work on this library, it looks truly excellent.

The next time I need to deal with dates or times I'll be reaching straight 
for simple-time.

Cheers, 
James

On Thursday, March 20, 2014 7:15:55 PM UTC+1, Matt Bossenbroek wrote:
>
> It is my pleasure to announce simple-time to the world: 
> https://github.com/mbossenbroek/simple-time
>
> simple-time is a dead simple datetime & timespan library for Clojure. It's 
> an opinionated alternative for clj-time that takes a more functional twist 
> on the object-heavy Joda time library.
>
> Full API is here: 
> http://mbossenbroek.github.io/simple-time/simple-time.core.html
>
> Read more about the motivation for simple-time here: 
> https://github.com/mbossenbroek/simple-time#motivations
>
> Enjoy!
>
> -Matt
>
>

-- 
You 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: local mutable state

2014-03-20 Thread James Trunk
Hi Andy,

I think Mr. Reeves gave you some excellent reasons to avoid using local 
mutable state, especially when trying to learn functional programming. If 
you're interested in seeing a spoiler for 114 you can look at one approach 
below (if you don't want a spoiler, then close this tab post-haste! ;-)

(fn my-take-while [n pred coll]
  (lazy-seq
(let [first-element (first coll)
  n (if (pred first-element) (dec n) n)]
  (when (> n 0)
(cons first-element (my-take-while n pred (rest coll)))

Cheers, 
James

On Thursday, March 20, 2014 8:34:20 PM UTC+1, Andy Smith wrote:
>
>
> Is is very bad form to use local mutable state to solve problems like :
>
> https://www.4clojure.com/problem/114
>
> i.e. 
>
> (fn [n f xs] (let [c (atom 0)] (take-while #(if (f %) (> n (swap! c inc)) 
> true) xs)))
>
> If so, what is the strongest reason to reject this kind of code? Since its 
> a local atom it ought to be thread-safe right?
>
> Thanks
>
> Andy
>

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


[Video] Game development in Clojure (with play-clj)

2014-03-27 Thread James Trunk
Hi everyone,

I thought some of you might be interested to watch my screencast about game 
development in Clojure with 
play-clj
.

Cheers,
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: [Video] Game development in Clojure (with play-clj)

2014-04-13 Thread James Trunk
Hi Kris,

Thanks for your comment, and I'm very glad that you found the video helpful.

I started doing screencasts because I realised that I learn a new concept 
fastest by watching someone else doing/explaining it - and I figured I 
might not be the only one. Saying that, I know screencasts aren't for 
everyone, and they have a few drawbacks compared to text (harder to search, 
skim, or repeat sections). So positive comment like yours remind me that 
I'm not the only auditory/visual learner around here, and inspire me to 
keep going. Thanks!

James

On Saturday, April 12, 2014 11:28:29 PM UTC+2, Kris Calabio wrote:
>
> Great video! I've looked through Zach's examples, and even started coding 
> a game myself. But your screencast helped me have a better understanding of 
> some of the concepts and code that I was having trouble understanding just 
> by looking at the example games. Thanks!
> -Kris
>
> On Thursday, March 27, 2014 10:07:21 AM UTC-7, James Trunk wrote:
>>
>> Hi everyone,
>>
>> I thought some of you might be interested to watch my screencast about game 
>> development in Clojure with 
>> play-clj<https://www.youtube.com/watch?v=9ilUe7Re-RA>
>> .
>>
>> Cheers,
>> 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: [Video] Game development in Clojure (with play-clj)

2014-04-13 Thread James Trunk
There's a link to a gist of 
core.clj<https://gist.github.com/Misophistful/9892203>in the video's 
description.

Cheers, 
James

On Monday, April 14, 2014 12:08:16 AM UTC+2, Kris Calabio wrote:
>
> Actually, I thought it would be even more helpful if you had the source 
> code available (for searching/skimming). Is that somewhere online?
> -Kris
>
>
> On Sun, Apr 13, 2014 at 2:47 PM, James Trunk 
> > wrote:
>
>> Hi Kris,
>>
>> Thanks for your comment, and I'm very glad that you found the video 
>> helpful.
>>
>> I started doing screencasts because I realised that I learn a new concept 
>> fastest by watching someone else doing/explaining it - and I figured I 
>> might not be the only one. Saying that, I know screencasts aren't for 
>> everyone, and they have a few drawbacks compared to text (harder to search, 
>> skim, or repeat sections). So positive comment like yours remind me that 
>> I'm not the only auditory/visual learner around here, and inspire me to 
>> keep going. Thanks!
>>
>> James
>>
>>
>> On Saturday, April 12, 2014 11:28:29 PM UTC+2, Kris Calabio wrote:
>>>
>>> Great video! I've looked through Zach's examples, and even started 
>>> coding a game myself. But your screencast helped me have a better 
>>> understanding of some of the concepts and code that I was having trouble 
>>> understanding just by looking at the example games. Thanks!
>>> -Kris
>>>
>>> On Thursday, March 27, 2014 10:07:21 AM UTC-7, James Trunk wrote:
>>>>
>>>> Hi everyone,
>>>>
>>>> I thought some of you might be interested to watch my screencast about 
>>>> game 
>>>> development in Clojure with 
>>>> play-clj<https://www.youtube.com/watch?v=9ilUe7Re-RA>
>>>> .
>>>>
>>>> Cheers,
>>>> James
>>>>
>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Clojure" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/clojure/mR1IBJ_OomY/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> clojure+u...@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: [Video] Game development in Clojure (with play-clj)

2014-04-16 Thread James Trunk
> you can omit comma ',' in maps {:key value :another value}
In the interest of readability, I usually add commas when I have multiple 
key-value pairs on the same row.

> can omit contains? in filter:
Cool - thanks for the tip!

Also, thanks to everyone else for your comments. :-)

Cheers, 
James

On Wednesday, April 16, 2014 6:07:06 PM UTC+2, edbond wrote:
>
> Nice video, very cool.
>
> Some notes:
> - you can omit comma ',' in maps {:key value :another value}
> - can omit contains? in filter:
> user=> (filter :apple? [{:apple? true :x 6} {:apple? true :x 4} {:player? 
> true :x 550}])
> ({:apple? true, :x 6} {:apple? true, :x 4})
>
>
> Thanks again,
> Eduard
>
>
> On Thursday, March 27, 2014 7:07:21 PM UTC+2, James Trunk wrote:
>>
>> Hi everyone,
>>
>> I thought some of you might be interested to watch my screencast about game 
>> development in Clojure with 
>> play-clj<https://www.youtube.com/watch?v=9ilUe7Re-RA>
>> .
>>
>> Cheers,
>> 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: boolean problem

2014-04-17 Thread James Trunk
Hi Roelof,

I'd recommend using an editor that supports rainbow brackets so you can 
easily see when your parens are matched.

Also, when you get your parens matched you'll find another error in your 
code, check out the docs for if 
to figure that one out.

Cheers, 
James

On Thursday, April 17, 2014 9:11:13 AM UTC+2, Roelof Wobben wrote:
>
> Hello, 
>
> IM working at the Iloveponies github tutorial and Im stuck here,
>
> I have to check if x is a nil or false and then the output must be false,\
> Otherwise I have to be true.
>
> So I tried this :
>
> (defn boolean [x]
>   (if (and (nil? x) (false? x))
>   )
>
> But then I see a very long error message: 
>
> xception in thread "main" java.lang.RuntimeException: EOF while reading, 
> starting at line 4, 
> compiling:(i_am_a_horse_in_the_land_of_booleans.clj:30:1)
> at clojure.lang.Compiler.load(Compiler.java:7071)
> at clojure.lang.RT.loadResourceScript(RT.java:370)
> at clojure.lang.RT.loadResourceScript(RT.java:361)
> at clojure.lang.RT.load(RT.java:440)
> at clojure.lang.RT.load(RT.java:411)
> at clojure.core$load$fn__5018.invoke(core.clj:5530)
> at clojure.core$load.doInvoke(core.clj:5529)
> at clojure.lang.RestFn.invoke(RestFn.java:408)
> at clojure.core$load_one.invoke(core.clj:5336)
> at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
> at clojure.core$load_lib.doInvoke(core.clj:5374)
> at clojure.lang.RestFn.applyTo(RestFn.java:142)
> at clojure.core$apply.invoke(core.clj:619)
> at clojure.core$load_libs.doInvoke(core.clj:5413)
> at clojure.lang.RestFn.applyTo(RestFn.java:137)
> at clojure.core$apply.invoke(core.clj:621)
> at clojure.core$use.doInvoke(core.clj:5507)
> at clojure.lang.RestFn.invoke(RestFn.java:421)
> at 
> iloveponies.tests.i_am_a_horse_in_the_land_of_booleans$eval6263$loading__4910__auto6264.invoke(i_am_a_horse_in_the_land_of_booleans.clj:1)
> at 
> iloveponies.tests.i_am_a_horse_in_the_land_of_booleans$eval6263.invoke(i_am_a_horse_in_the_land_of_booleans.clj:1)
> at clojure.lang.Compiler.eval(Compiler.java:6619)
> at clojure.lang.Compiler.eval(Compiler.java:6608)
> at clojure.lang.Compiler.load(Compiler.java:7064)
> at clojure.lang.RT.loadResourceScript(RT.java:370)
> at clojure.lang.RT.loadResourceScript(RT.java:361)
> at clojure.lang.RT.load(RT.java:440)
> at clojure.lang.RT.load(RT.java:411)
> at clojure.core$load$fn__5018.invoke(core.clj:5530)
> at clojure.core$load.doInvoke(core.clj:5529)
> at clojure.lang.RestFn.invoke(RestFn.java:408)
> at clojure.core$load_one.invoke(core.clj:5336)
> at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
> at clojure.core$load_lib.doInvoke(core.clj:5374)
> at clojure.lang.RestFn.applyTo(RestFn.java:142)
> at clojure.core$apply.invoke(core.clj:619)
> at clojure.core$load_libs.doInvoke(core.clj:5413)
> at clojure.lang.RestFn.applyTo(RestFn.java:137)
> at clojure.core$apply.invoke(core.clj:621)
> at clojure.core$use.doInvoke(core.clj:5507)
> at clojure.lang.RestFn.invoke(RestFn.java:408)
> at 
> i_am_a_horse_in_the_land_of_booleans_test$eval6257$loading__4910__auto6258.invoke(i_am_a_horse_in_the_land_of_booleans_test.clj:1)
> at 
> i_am_a_horse_in_the_land_of_booleans_test$eval6257.invoke(i_am_a_horse_in_the_land_of_booleans_test.clj:1)
> at clojure.lang.Compiler.eval(Compiler.java:6619)
> at clojure.lang.Compiler.eval(Compiler.java:6608)
> at clojure.lang.Compiler.load(Compiler.java:7064)
> at clojure.lang.RT.loadResourceScript(RT.java:370)
> at clojure.lang.RT.loadResourceScript(RT.java:361)
> at clojure.lang.RT.load(RT.java:440)
> at clojure.lang.RT.load(RT.java:411)
> at clojure.core$load$fn__5018.invoke(core.clj:5530)
> at clojure.core$load.doInvoke(core.clj:5529)
> at clojure.lang.RestFn.invoke(RestFn.java:408)
> at clojure.core$load_one.invoke(core.clj:5336)
> at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
> at clojure.core$load_lib.doInvoke(core.clj:5374)
> at clojure.lang.RestFn.applyTo(RestFn.java:142)
> at clojure.core$apply.invoke(core.clj:619)
> at clojure.core$load_libs.doInvoke(core.clj:5413)
> at clojure.lang.RestFn.applyTo(RestFn.java:137)
> at clojure.core$apply.invoke(core.clj:619)
> at clojure.core$require.doInvoke(core.clj:5496)
> at clojure.lang.RestFn.invoke(RestFn.java:421)
> at midje.repl$load_facts$fn__6191.invoke(repl.clj:206)
> at midje.repl$load_facts.doInvoke(repl.clj:192)
> at clojure.lang.RestFn.invoke(RestFn.java:397)
> at user$eval6253.invoke(form-init263954278555209

Re: why is this failing on a list

2014-05-04 Thread James Trunk
Also, don't forget that vectors are zero indexed, so (- (count v) 1) will 
give you the last element, not the second last.

Cheers,
James

On Sunday, May 4, 2014 4:49:45 PM UTC+2, Lee wrote:
>
>
>
> On May 4, 2014, at 10:42 AM, Roelof Wobben > 
> wrote: 
>
> > For 4clojure I have to find the second to last item. 
> > 
> > So I did this: 
> > 
> > (fn secondlast [v] 
> >   (get v (-(count v)1))) 
> > 
> > Now it's only failing at this test :  (= (__ (list 1 2 3 4 5)) 4) 
> > 
> > Can anyone tell me where I did take the wrong way. 
>
>
> The "get" function with integer keys works for vectors but not for lists: 
>
> => (get [7 8 9] 1) 
> 8 
> => (get '(7 8 9) 1) 
> nil 
>
> So one option would be to call "vec" on the list before calling get: 
>
> => (get (vec '(7 8 9)) 1) 
> 8 
>
> Another option would be to use "nth" instead of "get". 
>
>  -Lee 
>
>

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


Re: [ANN] Nightmod, a tool for making live-moddable games

2014-05-31 Thread James Trunk
I've played around a little with Nightmod, and I really like what I've 
seen. It's an excellent introduction to games programming; allowing people 
to experiment their way to understanding by seeing their tweaks/additions 
reflected immediately in the running game.

I'm going to be recommending Nightmod to some kids I know who are just 
getting into programming.

Thanks for your work on this Zach.

Cheers,
James

On Friday, May 30, 2014 3:10:27 PM UTC+2, Zach Oakes wrote:
>
> Nightmod is a new tool I'm working on that allows you to create games 
> while they run. It is a combination of my previous projects, Nightcode and 
> play-clj, into a single tool. Please read the website for more info, and if 
> you try it out, I would love to hear feedback.
>
> Website:
> https://nightmod.net/
>
> Github:
> https://github.com/oakes/Nightmod
>
> HN:
> https://news.ycombinator.com/item?id=7821516
>

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


[Video] Generative testing in Clojure

2014-01-01 Thread James Trunk
Hi everyone,

Here is an introduction to generative testing in 
Clojure using 
simple-check.

I hope newcomers to the technique/library find it useful!

Cheers, 
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/groups/opt_out.


Re: [Video] Generative testing in Clojure

2014-01-02 Thread James Trunk
Thanks for the comment, and I'm very glad you found it useful.

Cheers, 
James

On Wednesday, January 1, 2014 7:30:15 PM UTC+1, Mark N. wrote:
>
> Nicely done, I've been looking for a good intro to generative testing. The 
> real-world example at the end nicely illustrates the value of the 
> "shrinking" part of the algorithm. Thanks for publishing this.
>
>
> On Wed, Jan 1, 2014 at 10:58 AM, James Trunk 
> > wrote:
>
>> Hi everyone,
>>
>> Here is an introduction to generative testing in 
>> Clojure<http://www.youtube.com/watch?v=u0TkAw8QqrQ> using 
>> simple-check.
>>
>> I hope newcomers to the technique/library find it useful!
>>
>> Cheers, 
>> James
>>
>> -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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


How to handle configuration in Clojure?

2014-01-13 Thread James Trunk
I've been investigating how to handle configuration in a Clojure 
application/library, and have discovered two main candidates: dynamics vars 
and argument passing.

The downsides to dynamic vars seem to be: hiddenness, thread safety, and 
more complex tests (binding before each test).

The downside to argument passing is noise in the code (especially when 
you're just passing the config through). Longer and more descriptive names 
for the config (i.e. not "ctx" or "cfg") make this noise even more painful.

Are there any alternatives that I've missed? What is the current best 
practice for handling configuration?

Cheers,
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/groups/opt_out.


Re: How to handle configuration in Clojure?

2014-01-14 Thread James Trunk
Thanks for all the great links and ideas you have all posted, now I have 
plenty of reading and thinking to do!

> I am curious about what you mean by 'thread safety'.
Perhaps "thread safety" is the wrong term, but what I meant was the 
limitations dynamic binding introduces around thread dispatching, which 
Stuart Sierra explains in this blog 
post<http://stuartsierra.com/2013/03/29/perils-of-dynamic-scope>
.

Cheers,
James

On Monday, January 13, 2014 7:10:38 PM UTC+1, Stefan Kanev wrote:
>
> On 13/01/14, James Trunk wrote: 
> > The downsides to dynamic vars seem to be: hiddenness, thread safety, and 
> > more complex tests (binding before each test). 
>
> I am curious about what you mean by 'thread safety'.  As far as I know, 
> dynamic variables are thread-local, which means that they are 
> thread-safe, at least to some extend.  I assume you mean something 
> specific? 
>
> -- 
> Stefan Kanev  ¦  @skanev  ¦  http://skanev.com/ 
> If a program manipulates a large amount of data, it does so in a small 
> number 
> of ways. 
>

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


Re: [ANN] play-clj, a game library

2014-01-21 Thread James Trunk
Thanks for all your hard work on this - it looks awesome, and I can't wait 
to play around with it!

I like the conciseness of the project name, but I worry that it doesn't 
roll off the tongue all that well. I guess that *jure* library names 
are considered passé by most, but in this case I actually thought that the 
name *playure* seemed like a nice fit. Imagine getting to a 1.0 release and 
being able to call it *playure one*! Just a thought. :-)

Cheers, 
James

On Monday, January 20, 2014 4:31:50 PM UTC+1, Zach Oakes wrote:
>
> Today I'm releasing play-clj , a 
> Clojure wrapper for LibGDX that allows you to write games for desktop OSes, 
> Android, and iOS from the same Clojure codebase. The template automatically 
> creates Leiningen projects for all three platforms:
>
> lein new play-clj hello-world
>
> I am also releasing Nightcode  0.2.6, which 
> includes the play-clj template built-in. I've fixed a lot of bugs since 
> releasing 0.2.0 last month, including finally fixing the REPL input problem.
>
> If you'd like to help me continue working on stuff like play-clj and 
> Nightcode, I am on Gittip  now.
>
> I would also love help optimizing performance, which is pretty bad on 
> mobile OSes at the moment. Try out my example 
> games, 
> including an in-progress clone of Notch's Ludum Dare entry, Minicraft.
>

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


Re: [ANN] play-clj, a game library

2014-01-21 Thread James Trunk
> Do you mean *playjure*?
No, I did mean *playure* (pronounced player), though after re-reading my 
post I understand the confusion.

And considering that the current *play-clj* name isn't at all confusing, 
it's probably a good reason to stick with it! :-)

Cheers,
James

On Tuesday, January 21, 2014 12:41:56 PM UTC+1, fmj...@gmail.com wrote:
>
>  On 21/01/14 09:50, James Trunk wrote:
>  
> I like the conciseness of the project name, but I worry that it doesn't 
> roll off the tongue all that well. I guess that *jure* library 
> names are considered passé by most, but in this case I actually thought 
> that the name *playure* seemed like a nice fit. Imagine getting to a 1.0 
> release and being able to call it *playure one*! Just a thought. :-)
>  
> Do you mean *playjure*?
>  

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