Right now you have a complicated function that takes no inputs and
always produces the same string. It seems somewhat nonsensical.
Surely you want this function to take some inputs, and produce
different strings depending on the input.
Check out htdp.org as a resource for learning more about functional
programming and good program design principles.
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 <esio...@gmail.com>
>Haha, I was afraid someone would say this.I won't say that, you ported Python to Clojure while maintaining Python spirit. That's great!
>Here is my embarrassingly bad (but working) version:
Emeka
I won't say that, you ported Python to Clojure while maintaining Python spirit. That's great!
Are you serious, or is this a joke somewhat bashing the python language ?
On Tue, Feb 17, 2009 at 4:03 PM, Jesse Aldridge <JesseA...@gmail.com> wrote:
>
>> Jesse,
>> Could I see your own version.
>
> Haha, I was afraid someone would say this.
> Here is my embarrassingly bad (but working) version:
>
> (defn build-table []
> (def num-cols 3)
> (def selected-row 0)
> (def selected-col 0)
> (def all-strings ["apple" "cat" "dog" "" "frog" "elephant"
> "gorilla"])
let would be better than def here. def creates basically a global
variable (although I'm sure someone will complain about me calling
them that :)
> (defn new_cell [string row col]
> (defn bg-color []
There's no point using nested defns, since defn is defined in terms of
def. i.e. these are also global.
--
Michael Wood <esio...@gmail.com>