Well, that's my most rubbish UI ever, but at least it gave me a chance to learn a few things. Starting from the example, I made a few very simple changes and ended up with the rubbish one above....
I'm still not fulling groking exactly how "real" applications are designed in a functional programming language. For example, in this daft app what should the separation of concerns be? Does MVC have a functional counterpart?
Next on this list is changing the code
(prn alg)to actually render what's going on with quicksort and bubble sort.
(import '(javax.swing JFrame JLabel JTextField JButton JComboBox JPanel Timer)
(defn draw-sort [canvas alg]
(defn sortapp 
(let [frame (JFrame. "Sort Visualizer")
canvas (JPanel. true)
run-button (JButton. "Run Algorithm")]
(proxy [ActionListener] 
(draw-sort canvas (.toString (.getSelectedItem algorithm-chooser))))))
(.addItem "Quick sort")
(.addItem "Bubble sort"))
(.setLayout (GridLayout. 2 2 3 3))
(.setSize 300 300)
Things I have learnt:
dotosyntax saves lots of repetition!
proxyis used to generate implementations of interfaces dynamically
Things I need to find out:
- What's the idiomatic way of drawing something on the screen? Do I need to be using timers? Probably!