<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>82940</integer>
    </number>
    <user>
      <string>Laurent Petit</string>
    </user>
    <title>
      <string>challenge in clojure</string>
    </title>
    <contents>
      <string>;; file: challenge.clj
;; file: challenge.clj
;; invoke from command line:
;; java -cp clojure.jar /path/to/challenge.clj &#xE2;&#x80;&#x9C;()&#xE2;&#x80;&#x9D; &#xE2;&#x80;&#x9C;((([[]])))&#xE2;&#x80;&#x9D; &#xE2;&#x80;&#xA6; &#xE2;&#x80;&#xA6;

(ns challenge)

(def push conj)
(def closing-counterpart { \( \), \[ \] })
(defn matching-pair? [left right] 
  (= right (closing-counterpart left)))

(defn consume-one [stack c]
  (if (matching-pair? (peek stack) c)
    (pop stack)
    (push stack c)))

(defn balanced? [s] 
  (empty? (reduce consume-one [] s)))

(defn main [] 
  (apply print (map balanced? *command-line-args*)))

(when *command-line-args* 
  (main))</string>
    </contents>
    <universal-time>
      <integer>3455597910</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string>Basic Lisp</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
    <deletion-requested>
      <null/>
    </deletion-requested>
    <deletion-requested-email>
      <null/>
    </deletion-requested-email>
    <expiration-time>
      <null/>
    </expiration-time>
  </paste>
</paste-with-annotations>
