Clojure Regex

Note: If you’re new to regex, check out my Clojure regex introduction.

Clojure programming supports regular expressions, often just called regex. Underneath Clojure’s hood, Clojure is using Java’s java.util.regex package, so it isn’t surprising to see Clojure’s regular expressions (regex) has similarities to Java’s regular expressions.

Now of course, you could write regular expression code directly using Java from Clojure with Java-Interop. For example,

(def some-quote 
  (str "It was the best of times. "
  "It was the worst of times. It was Friday "
  "night and it was late."))

(def day-pattern "\\w*day")

(defn java-interop-regex
  "just doing Clojure regex with Java APIs"
  (let [pat (java.util.regex.Pattern/compile day-pattern) 
        mat (.matcher pat some-quote)
        day-found (.find mat)]
    (println "Is there a day? ... " day-found)))


would print out, Continue reading “Clojure Regex”

ClojureScript Game Engine Development with Construct 2

Clojure game programming benefits most from use of a game engine. While game engines are not specifically written for Clojure, Clojure is written to run on many VMs, and can take advantage of many game engines.

Construct 2 happens to be a great game engine for use with Clojure in the form of ClojureScript. ClojureScript integrates very nicely with Construct 2’s plugins and behaviors. Construct 2 allows for Clojure games (in the form of ClojureScript) to reach practically every platform out there for 2D game publishing.

Construct 2 / ClojureScript games can reach any platform HTML 5 games can reach, including:

  • All modern web browsers
  • Behave like native PC, Mac, and Linux apps using the Node-Webkit wrapper
  • Be published by Chrome Web Store, Facebook, Kongregate, NewGrounds, Firefox Marketplace, iOS and Android app stores, the Windows 8 Store, and Amazon
  • And can easily integrate advertising into games published to your own web site

Continue reading “ClojureScript Game Engine Development with Construct 2”

Calling ClojureScript from JavaScript

Integrating JavaScript and ClojureScript into a single web page is easy, with the right start. JavaScript is the language of the web, for now anyway. However sometimes, you want a more modern, powerful language. Perhaps a language that combines modern functional paradigms with the old school power of Lisp. ClojureScript fits your needs.

ClojureScript is a modern functional Lisp that happens to compile down to optimized JavaScript. The base language is called Clojure. Clojure targets the JVM, .NET, and JavaScript VMs. ClojureScript is the JavaScript variety of Clojure.

Continue reading “Calling ClojureScript from JavaScript”