I hereby claim:
- I am engelberg on github.
- I am markengelberg (https://keybase.io/markengelberg) on keybase.
- I have a public key whose fingerprint is C3F3 DE10 2B2E DEDA 4613 AC36 530A 864D 3A1B A35E
To claim this, I am signing this object:
;; gorilla-repl.fileformat = 1 | |
;; @@ | |
(ns count-combinations) | |
;; @@ | |
;; => | |
;;; {"type":"html","content":"<span class='clj-nil'>nil</span>","value":"nil"} | |
;; <= | |
;; ** |
(ns compojure-example.handler | |
(:require [compojure.core :refer :all] | |
[compojure.route :as route] | |
[ring.middleware.defaults :refer [wrap-defaults site-defaults api-defaults]] | |
[ring.util.anti-forgery :refer [anti-forgery-field]] | |
[ring.util.response :as response] ; for response/redirect, etc. | |
[hiccup.core :refer [html h]] | |
[hiccup.form :as form] | |
[hiccup.element :refer [image link-to]] | |
[hiccup.page :refer [html5]])) |
(ns mark.teamsplit | |
(:require [loco.core :as l] | |
[loco.constraints :refer :all])) | |
; Although this problem was stated in terms of a group of players | |
; with multiple attributes, we can just represent each player by | |
; a single number, so this function just takes the list of numbers. | |
(defn find-teams | |
"Players is a list of player strengths, timeout is in milliseconds" |
(defn- sum [s] (reduce + s)) | |
(defn score | |
([gs] (let [s (clojure.string/replace gs #"\d/" #(str (nth % 0) (char (- 106 (int (nth % 0)))))), | |
g (map #(case % \X 10 \- 0 (- (int %) 48)) s)] | |
(score g 1))) | |
([game frame] | |
(cond | |
(= frame 10) (sum game) | |
(= (first game) 10) (+ (sum (take 3 game)) (score (drop 1 game) (inc frame))), | |
(= (sum (take 2 game)) 10) (+ (sum (take 3 game)) (score (drop 2 game) (inc frame))), |
(ns utils.cond | |
"A collection of variations on Clojure's core macros. Let's see which features | |
end up being useful." | |
{:author "Christophe Grand"} | |
(:refer-clojure :exclude [cond when-let if-let])) | |
(defmacro if-let | |
"A variation on if-let where all the exprs in the bindings vector must be true. | |
Also supports :let." | |
([bindings then] |
I hereby claim:
To claim this, I am signing this object:
(ns twentyfour.core | |
(:use clojure.math.combinatorics)) | |
(def ops ['+ '- '* '/]) | |
(def commutative #{'+ '*}) | |
;; We can generate all the possible expressions efficiently with combinatorics' partitions | |
;; partitions automatically handles duplicates for us, which keeps the process efficient | |
(defn expressions [nums] |
abelo | |
abio | |
abomeno | |
abrikoto | |
absoluta | |
abunda | |
acida | |
adapti | |
adicii | |
adjektivo |
; The sample to refactor | |
(if-let [x (foo)] | |
(if-let [y (bar x)] | |
(if-let [z (goo x y)] | |
(do | |
(qux x y z) | |
(log "it worked") | |
true) | |
(do | |
(log "goo failed") |
public class CoreSubsetObjective implements Objective<SubsetSolution, CoreSubsetData>{ | |
/** | |
* Evaluates the given subset solution using the underlying data, by computing the average | |
* distance between all pairs of selected items. If less than two items are selected, | |
* the evaluation is defined to have a value of 0.0. | |
* | |
* @param solution subset solution | |
* @param data core subset data | |
* @return evaluation with a value set to the average distance between all pairs of selected items; |