You can pass your functions around directly; you don't need to wrap them in #(). That will get rid of most of the rest of the duplication you've got.
(def search-fields [ ["Search Quotes (Case Independent)" show-search-quotes] ["Search Quotes Not (Case Independent)" show-search-quotes-not] ["Search Quotes Word Bounderies" show-search-quotes-word-boundary] ["Search Quotes Begin (Case Independent)" show-search-quotes-begin] ["Search Quotes End (Case Independent)" show-search-quotes-end] ["Search Quotes Java Regular Expression" show-search-quotes-java-regex] ["Search Quotes Java Regular Expression Not" show-search-quotes-java-regex] ]) Also, please consider doseq instead of dotimes. (doseq [[description function] search-fields] (grid-bag-layout search-panel :fill GridBagConstraints/HORIZONTAL :ipadx 8 ...)) You could extract the doseq into a var-args function, then call it with the items like so: (def-grids ["Search Quotes (Case Independent)" show-search-quotes] ["Search Quotes Not (Case Independent)" show-search-quotes-not] ["Search Quotes Word Bounderies" show-search-quotes-word-boundary] ["Search Quotes Begin (Case Independent)" show-search-quotes-begin] ["Search Quotes End (Case Independent)" show-search-quotes-end] ["Search Quotes Java Regular Expression" show-search-quotes-java-regex] ["Search Quotes Java Regular Expression Not" show-search-quotes-java-regex]) Chris On Feb 28, 2015 4:50 AM, "Cecil Westerhof" <cldwester...@gmail.com> wrote: > I need some things that are almost the same. I solved that in this way: > (def search-fields > [ > ["Search Quotes (Case Independent)" #(show-search-quotes > %)] > ["Search Quotes Not (Case Independent)" > #(show-search-quotes-not %)] > ["Search Quotes Word Bounderies" > #(show-search-quotes-word-boundary %)] > ["Search Quotes Begin (Case Independent)" > #(show-search-quotes-begin %)] > ["Search Quotes End (Case Independent)" > #(show-search-quotes-end %)] > ["Search Quotes Java Regular Expression" > #(show-search-quotes-java-regex %)] > ["Search Quotes Java Regular Expression Not" > #(show-search-quotes-java-regex %)] > ]) > > (dotimes > [i (count search-fields)] > (let [ > description (nth (nth search-fields i) 0) > function (nth (nth search-fields i) 1) > ] > (grid-bag-layout > search-panel > :fill GridBagConstraints/HORIZONTAL > :ipadx 8 > :ipady 4 > :gridy i > :gridx 0 ^JLabel (label description) > :gridx 1 ^JTextField > (text :columns 40 > :listen > [:action (fn [e] > (let [ > search-str (text e) > ] > (when (not (empty? search-str)) > (function search-str)))) > ])))) > > Is that the correct way, or can it be done better? > > -- > Cecil Westerhof > > -- > 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 - please be patient with > your first post. > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 - please be patient with your first post. 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.