Avoiding repetition while still using 'recur'

2016-06-26 Thread Botond Balázs
Hi, Here is my solution to 4clojure problem #177: Write a function that takes in a string and returns truthy if all square [ > ] round ( ) and curly { } brackets are properly paired and legally nested, > or returns falsey otherwise. > (defn valid-parens? [s] (loop [[ch & chs] s stack []]

Re: Clojure for the Brave and True - infix notation exercise

2016-06-26 Thread Botond Balázs
Thanks miner! On Friday, June 24, 2016 at 10:20:54 PM UTC+2, miner wrote: > > Not exactly the same problem, but you might like to see an infix > implementation from “The Joy of Clojure” by Fogus and Chouser. > > http://fogus.me/fun/unfix/infix-src.html > > The “Joy” code makes intermediate

Re: Clojure for the Brave and True - infix notation exercise

2016-06-26 Thread Botond Balázs
Thank you Jason, this is indeed a much nicer solution. On Friday, June 24, 2016 at 8:51:26 PM UTC+2, Jason Felice wrote: > > Recursive descent parsers are much smaller for simple cases. Basically, > you write one function per level of precedence, and each tries, greedily, > to consume as much

Re: Avoiding repetition while still using 'recur'

2016-06-26 Thread Colin Yates
Skimming through but that `case` resolves to either false or a recur so sure you can move that case to an helper fn which returns true or false. If false then `return` else `recur`? On 26 June 2016 at 13:43, Botond Balázs wrote: > Hi, > > Here is my solution to 4clojure

Re: Avoiding repetition while still using 'recur'

2016-06-26 Thread James Reeves
The easiest way would be to factor out the bracket matching code, since that's the only thing that changes between your different case statements. For instance: (defn valid-parens? [s] (let [opening-brackets {\( \), \[ \], \{ \}} closing-brackets (clojure.set/map-invert

Re: Avoiding repetition while still using 'recur'

2016-06-26 Thread Botond Balázs
Thanks guys. Very nice and simple solution, James. On Sunday, June 26, 2016 at 3:21:56 PM UTC+2, James Reeves wrote: > > The easiest way would be to factor out the bracket matching code, since > that's the only thing that changes between your different case statements. > For instance: > >

Re: is there a way to use drip to speed up the running of unit tests?

2016-06-26 Thread Alan Thompson
I also highly recommend test-refersh! Alan On Sat, Jun 25, 2016 at 8:47 AM, Jake McCrary wrote: > Hi Fenton, > > In my experience the way to get faster feedback from your tests is to have > them run in a way that doesn’t require stopping and starting a process. > This can

Workshop report: Generative design systems with Clojure

2016-06-26 Thread Karsten Schmidt
Hi everyone, last week I've been teaching a 2-day workshop about building generative design systems with Clojure and have just published a report incl. various outputs & code samples produced: https://medium.com/@thi.ng/workshop-report-generative-design-with-clojure-7d6d8ea9a6e8#.mai46g3no

Re: Avoiding repetition while still using 'recur'

2016-06-26 Thread Andy-
To add a little variant of James Reeve's code: You can avoid the loop/recur by using reduce: (defn valid-parens? [s] (let [opening-brackets {\( \), \[ \], \{ \}} closing-brackets (clojure.set/map-invert opening-brackets)] (empty? (reduce (fn [stack c] (if

Re: is there a way to use drip to speed up the running of unit tests?

2016-06-26 Thread Daniel Compton
I would recommend looking at bolth . It’s an extremely fast test runner, has nice stacktraces, diffs, e.t.c. On Mon, Jun 27, 2016 at 6:28 AM Alan Thompson wrote: > I also highly recommend test-refersh! > Alan > > On Sat, Jun 25, 2016 at 8:47

Re: Avoiding repetition while still using 'recur'

2016-06-26 Thread Botond Balázs
I didn't know that reduction can be stopped with reduced. Thanks Andy! On Sunday, June 26, 2016 at 10:08:47 PM UTC+2, Andy- wrote: > > To add a little variant of James Reeve's code: You can avoid the > loop/recur by using reduce: > > > (defn valid-parens? [s] > (let [opening-brackets {\( \),