This file contains hidden or 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 hex-rgb.core | |
(:require [clojure.test :refer [deftest is testing]])) | |
;;;; Turn css hex colors into a Red Green Blue (RGB) sequence | |
;;;; Some simple functions. | |
(defn hex->num | |
"Turn a string in hex format into a decimal number" | |
[^String s] | |
(Integer/parseInt s 16)) |
This file contains hidden or 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
;; See http://www.4clojure.com/problem/104 | |
;; My original boring implimentation: | |
(fn roman [i] | |
(loop [roman "" i i] | |
(cond | |
(> i 999) (recur (str roman "M") (- i 1000)) | |
(> i 899) (recur (str roman "CM") (- i 900)) | |
(> i 499) (recur (str roman "D") (- i 500)) | |
(> i 99) (recur (str roman "C") (- i 100)) |
This file contains hidden or 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 bowling.core | |
"Bowling Kala - based on http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata | |
Note: This version is stateless as the whole games score is calculated. | |
http://www.bowlinggenius.com/ used to check edge cases" | |
(:require [clojure.test :refer [deftest is testing]])) | |
(defn spare? [[i j]] (= 10 (+ i j))) | |
(defn strike? [[i _]] (= 10 i)) | |
(defn strike-bonus |
This file contains hidden or 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 fizzbuzz.core | |
(:require [clojure.test :refer [deftest is testing]])) | |
(def fizzbuzz? #(= 0 (mod % 15))) | |
(def buzz? #(= 0 (mod % 5))) | |
(def fizz? #(= 0 (mod % 3))) | |
(defn fizzbuzz | |
[n] | |
(cond |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | |
<meta content="utf-8" http-equiv="encoding"> | |
</head> | |
<body style="background-color: #000;"> | |
<script> | |
/* Forked from SymfonyLive London 2015 - Seb Lee-Delisle - Getting artistic with code | |
* https://www.youtube.com/watch?v=DEpqJr73VMU |
This file contains hidden or 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
;; Add two vectors | |
(defn add-vec-simple [[x1 y1] [x2 y2]] | |
[(+ x1 x2) (+ y1 y2)]) | |
;; Add two or more vectors together (First attempt.) | |
(defn add-vec-better [[x1 y1] & args] | |
(loop [x x1 y y1 more args] | |
(if (empty? more) | |
[x y] | |
(recur (+ x (first (first more))) |