Re: Roman Numerals

2009-03-05 Thread David Sletten
On Mar 4, 2009, at 8:29 PM, Tom Faulhaber wrote: BTW, cl-format (my Common Lisp format function for Clojure), supports the ~...@r directive for converting Arabic to Roman (but nothing to go the other way around. I didn't spend too much time thinking about stylistic issues when I wrote it,

Re: Roman Numerals

2009-03-04 Thread David Sletten
On Mar 3, 2009, at 4:53 AM, Chouser wrote: (defn roman? [roman-string] (and (not (empty? roman-string)) (re-matches #(?:M{0,3})(?:D?C{0,3}|C[DM])(?:L?X{0,3}|X[LC])(?:V?I{0,3}|I [VX])$ roman-string))) The normal idiom in Clojure is (seq x) instead of (not (empty?

Re: Roman Numerals

2009-03-04 Thread Chouser
On Wed, Mar 4, 2009 at 4:43 AM, David Sletten da...@bosatsu.net wrote: Conversely, when says side effect. This is clear for 2 reasons. First, there is no else clause, so when doesn't really work as an expression. Furthermore, the forms in the when body are evaluated in an implicit do. Since

Re: Roman Numerals

2009-03-04 Thread Tom Faulhaber
representing invalid Roman numerals such as IVI, IXV, etc...   For this purpose the function roman? uses a regular expression I   cribbed from Perl's CPAN module Roman.pm (http://search.cpan.org/ ~chorny/Roman-1.23/lib/Roman.pm). arabic-to-roman performs the obvious conversion in the other

Roman Numerals

2009-03-03 Thread David Sletten
Here's a little toy to practice my basic Clojure skills. I didn't see any similar topic in the archives, so here we go... This code performs conversions between Roman and Arabic numerals. Roman numerals are represented as strings and Arabic numerals are just integers. Arabic numerals

Re: Roman Numerals

2009-03-03 Thread Chouser
On Tue, Mar 3, 2009 at 6:40 AM, David Sletten da...@bosatsu.net wrote: I'd appreciate any feedback regarding my Clojure style. Any more natural ways to do things? Looks good, thanks for sharing. (defn roman? [roman-string]   (and (not (empty? roman-string))        (re-matches        

Re: Roman Numerals

2009-03-03 Thread Michel S.
Hello, Chouser has commented extensively, so I'll just put in my two cents. On Mar 3, 6:40 am, David Sletten da...@bosatsu.net wrote: Incidentally, the cond form in roman-to-arabic-aux seems to me   harder to read in Clojure than it would be in CL with its additional   set of grouping