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
value(1, 1). | |
value(2, 5). | |
value(3, 10). | |
value(4, 25). | |
value(5, 50). | |
count_coins(Amount, Ways) :- cc(Amount, Ways, 5). | |
cc(X, 0, _) :- X < 0. | |
cc(_, 0, 0). |
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
To try and encourage more sales of the 5 different Harry | |
Potter books they sell, a bookshop has decided to offer | |
discounts of multiple-book purchases. | |
One copy of any of the five books costs 8 EUR. | |
If, however, you buy two different books, you get a 5% | |
discount on those two books. | |
If you buy 3 different books, you get a 10% discount. |
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
public class CustomMatchers { | |
public static Matcher<View> withBackground(final int resourceId) { | |
return new TypeSafeMatcher<View>() { | |
@Override | |
public boolean matchesSafely(View view) { | |
return sameBitmap(view.getContext(), view.getBackground(), resourceId); | |
} | |
@Override |
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 percolation.core | |
"Currently working for non-recursive, fully specified (no [:*]), attributes only (no limit, defaults etc.) pull api queries." | |
(:require [datomic.api :as d])) | |
(def schema | |
"Percolation specific schema" | |
[{:db/id #db/id[:db.part/db] | |
:db/ident :percolator/name | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/one |
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
(require '[clojure.java.shell :as shell] | |
'[clojure.string :as str]) | |
(defn- current-tag [] | |
(let [{:keys [exit out]} (shell/sh "git" "describe" "--tags")] | |
(when (zero? exit) | |
(str/trim out)))) | |
(def version | |
(if-let [tag (current-tag)] |
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
#!/usr/bin/env boot | |
(set-env! | |
:dependencies '[[com.datomic/datomic-pro "0.9.5302"] | |
[com.datomic/datomic-transactor-pro "0.9.5302"]] | |
:repositories {"my.datomic.com" | |
{:url "https://my.datomic.com/repo" | |
:username "..." | |
:password "..."}}) |
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-in [m ks] | |
(loop [path [] | |
ks (seq ks) | |
m m] | |
(if ks | |
(when-let [[k m] (find m (first ks))] | |
(recur (conj path k) (next ks) m)) | |
[path m]))) |
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 example.log) | |
(defprotocol Logger | |
(log [this msg])) | |
(defn map* [f logger] | |
(reify Logger | |
(log [this msg] (log logger (f msg))))) | |
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 tinylog.core | |
(:require [clj-http.client :as http] | |
[cheshire.core :as json] | |
[clojure.core.async :as async])) | |
(defprotocol Logger | |
(log [this msg])) | |
(defn map* [f logger] | |
(reify Logger |
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
{:paths ["/"] | |
:deps {}} |