This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns maze.core | |
(:use maze.tiles) | |
(:require [clojure.data.json :as json])) | |
(defn empty-maze [xsize ysize] | |
(let [row (into [] (take ysize (repeat 0)))] | |
(into [] (take xsize (repeat row))))) | |
(defn all-coords [maze] | |
(let [xsize (count maze) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns maze.tiles) | |
;;(print "\u2588 \u2588") | |
(def tiles1 | |
{0 ["***" | |
"*!*" | |
"***"] | |
1 ["* *" | |
"* *" | |
"***"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn can-sum-to-zero | |
([nums] | |
(can-zero nums #{})) | |
([nums can-sum-to] | |
(when (seq nums) | |
(let [num (first nums)] | |
(if (can-sum-to (- num)) | |
true | |
(let [can-also-sum-to (map #(+ num %) can-sum-to)] | |
(recur (rest nums) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: if-let in this context, compiling:(NO_SOURCE_PATH:1:1) | |
at clojure.lang.Compiler.analyze (Compiler.java:6380) | |
clojure.lang.Compiler.analyze (Compiler.java:6322) | |
clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3573) | |
clojure.lang.Compiler.analyzeSeq (Compiler.java:6562) | |
clojure.lang.Compiler.analyze (Compiler.java:6361) | |
clojure.lang.Compiler.analyze (Compiler.java:6322) | |
clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5708) | |
clojure.lang.Compiler$FnMethod.parse (Compiler.java:5139) | |
clojure.lang.Compiler$FnExpr.parse (Compiler.java:3751) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject demo "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.5.1"]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns logic.sudoku | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic]) | |
(:require [clojure.core.logic.fd :as fd])) | |
(defn init-board [vars puzzle] | |
(matche [vars puzzle] | |
([[] []] | |
succeed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns logic.once | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic]) | |
(:require [clojure.core.logic.fd :as fd])) | |
(defne occurs-noneo [x xs] | |
([x []]) | |
([x [y . ys]] | |
(!= y x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Infortunately I am unable at accept this pull request because it fails one of my unit tests. | |
test.job> (fact "job is in the correct city" | |
(let [job {:company "Amazon" :location :seattle}] | |
(:location job) => :austin)) | |
FAIL "job is in the correct city" at (form-init8310622436901647370.clj:3) | |
Expected: :austin | |
Actual: :seattle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def matches | |
{:a {:a "foo" :b "bar"} | |
:b {:a "blue" :b {:a "fred" :b "bob"}}}) | |
(defn winner [node] | |
(if (map? node) | |
(:winner node) | |
node)) | |
(defn select-winner [node aorb] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn find-timer [timer-name] | |
(timers/timer ["APPNAME" "timer" (name timer-name)])) | |
(defmacro with-timer [timer-name & body] | |
`(let [timer# (find-timer ~timer-name)] | |
(timers/time! timer# | |
(do ~@body)))) |