Re: loop/recur with multiple branches

2013-12-11 Thread Vincent Chen
On Tue, Dec 10, 2013 at 11:46 PM, Cedric Greevey wrote: > On Tue, Dec 10, 2013 at 6:29 PM, Vincent Chen wrote: >> >> Try this (not tested, might be missing parens and whatnot): >> >> (defn slice [x s n] >> (loop [[h & tail] x, s s, n n, acc []

Re: loop/recur with multiple branches

2013-12-10 Thread Vincent Chen
accumulator. The accumulator carries the eventual result, which is returned at the base case. - Since we're destructuring into head and tail, I used vectors. conj will push to the end of the vector. - In Clojure, vectors tend to be more natural than lists. Accumulating into lists usually requires a

Re: Typedef-like functionality for Clojure records?

2013-09-27 Thread Vincent Chen
On Thu, Sep 26, 2013 at 1:49 AM, Marshall Bockrath-Vandegrift wrote: > Vincent Chen writes: > >> - Use something else than records to model structs (suggestions welcome)? > > Maps. > > Records have concrete Java types, which allows them to implement > interfaces a

Re: Typedef-like functionality for Clojure records?

2013-09-27 Thread Vincent Chen
tion and validation you could consider prismatic/schema [1] as a > translation target, and just represent your data with maps. > > [1] https://github.com/Prismatic/schema > > > On Wednesday, September 25, 2013 10:47:35 PM UTC-7, Vincent Chen wrote: >> >> Hi, >> &

Typedef-like functionality for Clojure records?

2013-09-25 Thread Vincent Chen
Hi, I have in my hands an XML description of data structures that I want to mechanically translate into Clojure. There are and elements, with being similar to structs in C (list of fields) and being similar to typedef in C (defining new name for already defined s). I model s using Clojure rec

Re: [ANN] XCLJB v0.1.0: X protocol Clojure-language Binding

2013-09-25 Thread Vincent Chen
onvince me otherwise. Thanks, Vincent On Wed, Sep 25, 2013 at 1:50 AM, Adam Clements wrote: > Have you looked at core.async for shuttling asynchronous events back and > forth. This sounds to me like the sort of thing it was designed for > > On 10 Sep 2013 06:30, "Vince

[ANN] XCLJB v0.1.0: X protocol Clojure-language Binding

2013-09-09 Thread Vincent Chen
tching? Is there a better way of implementing events? Regards, Vincent Chen -- -- 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 -