Thanks Michael 2009/2/17 Michael Wood <esiot...@gmail.com>
> > On Tue, Feb 17, 2009 at 11:05 AM, Laurent PETIT <laurent.pe...@gmail.com> > wrote: > > Hello, > > > > I wanted to try it too, so I grabbed Timothy's version, and did some > > improvements (I hope they are, feedback welcome ! :-) over it. > > > > Something I corrected is the removal of null or blank items, as in the > first > > python version. > > I also got rid of the assoc by using update-in. > > And I felt that there was too much use of apply, but this may be > subjective. > > > > Question: In order to use update-in (or assoc in the previous version), > one > > has to transform the seqs returned by partition into a vector of vectors, > > thus the use of 'into. > > It still seems a little bit ugly to me. Is there a more concise (if not > > idiomatic) way to do that ? > > > > Here is the new version: > > > > (ns html.table) > > > > (defn make-table [column-count selected-row selected-column words] > > (let [remove-blank (partial remove #(or (nil? %) (-> % .trim > .isEmpty))) > > I got an exception here: > java.lang.IllegalArgumentException: No matching field found: isEmpty > for class java.lang.String (NO_SOURCE_FILE:0) > > I assume you're using Java 1.6? > > Changing it to the following fixes it for me: > [...] > (let [remove-blank (partial remove #(or (nil? %) (empty? (.trim %)))) > [...] > > > table (into [] (map (partial into []) (partition column-count > > (remove-blank words)))) > > table-with-selected (update-in table [selected-row > selected-column] > > (partial list :bold))] > > (cons :table > > (map (fn [r] (cons :tr (map (fn [i] (list :item i)) r))) > > table-with-selected)))) > > > > (defn test-mt [] > > (make-table 3 1 0 ["cat" "dog" "rabbit" "cat" "dog" "rabbit" "frog" > > "elephant" "gorilla"])) > > -- > Michael Wood <esiot...@gmail.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 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 -~----------~----~----~----~------~----~------~--~---