Hi,
On Sun, Sep 13, 2009 at 1:23 AM, Terrance Davis wrote:
>
> I translate this into Clojure as something like ...
>
> (def final-foo
> (. Double parseDouble
>(. javax.swing.JOptionPane showInputDialog "What is your foobar?")))
>
>
While not directly related: try to not use the . (dot) oper
I like to use the comp operator to handle these situations
((comp
#(Double/parseDouble %)
#(javax.swing.JOptionPane/showInputDialog "What is your foobar")))
This is called "point free" style, the name comes from topology.
I find it easy to add/remove/reorder operations in this manner.
I
Terrance, you could do something like this (loose on the syntax):
(def final-foo
(let [tmpString (. javax.swing.JOptionPane showInputDialog "What is your
foobar?")]
(. Double parseDouble tmpString)))
Look at this comment for one example of a function written both ways:
http://lojic.com/blog
For instance, in Java ...
tmpString = JOptionPane.showInputDialog("What is your foobar?");
finalFoo = Double.parseDouble(tmpString);
instead of ...
finalFoo = Double.parseDouble(JOptionPane.showInputDialog("What is
your foobar?"));
I translate this into Clojure as something like ...
(def fin
Could you post an example? It'd be easier to comment on it.
On Sep 12, 6:32 pm, Terrance Davis wrote:
> Commonly, I break down complex lines of code into several easy to
> follow simple lines of code. This results in many temp variables that
> are not intended to be used anywhere else in the co
Commonly, I break down complex lines of code into several easy to
follow simple lines of code. This results in many temp variables that
are not intended to be used anywhere else in the code. Sometimes I see
a method reusing common primitives and objects (like ints and
Strings), so to prevent verbo