I am building a simple swing GUI in Clojure. I am trying to apply a single function to multiple GUI components by using map in the context of a let:
(map #(f % component4) [component1 component2 component3])
Where the components are all defined in the let.
Problematically, map is lazy, and the action is not applied to the components, however, I can force it by wrapping the above in a ‘take’.
Is there a non lazy alternative to map? Or should I be going about this differently?
EDIT:
Using counterclockwise in eclipse. I had different results using (use ‘Lib :reload) from the REPL and using CTRL+Enter from the editor. Reloading would launch the GUI, but the problem described above would occur. The problem did not occur when using CTRL+Enter from the editor, therefore I think my description of the problem may be inaccurate. Regardless, doseq seems to be a better alternative to map in this scenario.
I challenge your assertion that getting
takeinvolved makes any difference at all. If you wrapped it indoallordorunit would do what you want, but you should consider usingdoseqinstead ofmapfor this sort of side-effect-only action.Note
Originally posted as comment on question; copied to answer by popular demand.