Here's an example of trying to use "map" to bring the two tables
together together in the same scope.  I'm doing this because the nth
element in one sequence correlates to its nth counterpart in the
second sequence.  mainTables is a sequence of JTables and fixedTables
is an equally sized sequence of JTables.  For some reason though it
appears that setupTable is never being called.  Why is that?  Is there
a better way to do this?

            (defn setupTable [main fixed]
              (println "Setting up table")
              (doto fixed
                    (.setAutoCreateColumnsFromModel false)
                    (.setModel (.getModel main))
                    (.setSelectionModel (.getSelectionModel main))
                    (.setFocusable false))

              ; remove the first column from the main table and add it to the
fixed table
              (let [column (.getColumn (.getColumnModel main) 0)]
                   (println column)
                   (.removeColumn (.getColumnModel main) column)
                   (.addColumn (.getColumnModel fixed) column)
                   )
              )

            (map (fn [main fixed] (setupTable main fixed)) mainTables 
fixedTables)
            (println mainTables)
            (println fixedTables)

On Thu, Apr 8, 2010 at 4:30 PM, Josh Stratton <strattonbra...@gmail.com> wrote:
>> It sounds like the doseq is the macro you're looking for, e.g.
>> (doseq [c my-components]
>>   (.setVisible c true))
>
> That works once I've done the initial mapping and I want to set
> values, but what if I still want the two components--the old and new
> one--in the same scope at the same time?
>
> In python, one might do something like this:
>
> for i,component in oldComponents:
>     newComponents[i].setValue(oldComponents[i])
>     if (oldComponents[i].getAttribute() > 5):
>          newComponents[i].setAttribute(0)
>     else:
>          newComponents[i].setAttribute(1)
>
> I guess I was just trying to avoid using index notation.  Would zip be
> the appropriate solution here, where I can set the two lists together
> in tuples of old and new?
>

-- 
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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to