Tag Archives: Clojure

N-Queens

The N-Queens puzzle is a classic computer science problem. In fact, it’s much older than discipline of computer science. It is usually used as a problem to introduce students to backtracking algorithms in computer science. I was first introduced to the problem in Niklaus Wirth’s Algorithms + Data Structures = Programs back in the ’70s.

I thought it might be interesting to write an updated version in my continuing effort to become proficient in Clojure.  My intent was to write a simple working version, then use the concurrency features of the language to write a parallel version and see what kind of performance gain was possible.

Continue reading

Java-Clojure Interop: An Update

My most popular answer on Stack Overflow has to do with Clojure-Java interop. Since that answer was written, some of the tools used in the answer, specifically enclojure, have been deprecated. Because many of the follow-up questions related to how to build a working version of the answer, I thought it might be a good idea to update the post with modern tools.

Keyboard Shortcuts for JavaFX Buttons

Most programs written for graphical user interfaces still provide a way to operate with the keyboard, requiring minimal mouse usage. The thought is that expert users will want to speed through their work keeping their fingers on the keyboard rather than devote an entire hands worth of fingers to controlling the mouse. I’ve been learning JavaFX, the eventual replacement for the Swing UI framework on Java, and wanted to explore how shortcut functionality had changed. There were a few tutorials on keyboard shortcuts for menu-driven programs, but nothing I could find on their use with button-based interfaces. That’s what I cover here.

Continue reading

JavaFX KeyCodeCombinations in Clojure

I’ve been experimenting with adding keyboard accelerators to some of the Clojure programs I’ve written with JavaFX-based user interfaces. As part of that investigation, I tried to translate the Java program here to Clojure. The program just puts up a window with a menu bar containing only a “File” menu which itself contains one item, “Exit“. Most programs provide a keyboard shortcut or accelerator to close the program with a Ctrl-X (on Windows). Figuring out how to add that functionality was a bit of an issue for me.

Continue reading

The Clojure Development Toolchain

One of the things about Clojure that is difficult for beginners is the process of creating and running programs. I would argue that it is more difficult than learning the language itself. There is no “one-button” provisioning system that would set up some sort of canonical development environment. This long post will talk about setting up Leiningen and Emacs to make a comfortable environment for developing in Clojure.

Continue reading

Clojure, JavaFX and Tic-Tac-Toe

Recently, I have been experimenting with JavaFX in Clojure. Initially, in one of my experiments, I wanted to learn how to re-size a game-board interface as it’s containing window was re-sized. In the past I’ve had medical device interfaces that draw a representation of a physical device and these drawings must re-size as their window is re-sized. The initial experiment was with a simple interface for Tic-Tac-Toe. Since I had such a nice interface, I thought, why not program the complete game.

Continue reading

Re-sizing an Interface in JavaFX and Clojure

Since JavaFX is the future of the user interface for Java, I’ve started trying to learn it. Since I’m also learning Clojure, I’m doing the work in that language.

One of the things I’ve been looking into is how the interface responds to resizing. If you have all of your controls in a nice layout, that is usually taken care of for you. But how do you handle things if the interface is not made up of standard components, something like a graphical game interface for example?

Continue reading