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
struct Point { | |
x: float, | |
y: float, | |
} | |
enum Shape { | |
Circle(Point, float), | |
Rectangle(Point, Point), | |
} |
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 my-quil-app.core | |
(:require [quil.core :as q]) | |
(:gen-class)) | |
;; `setup` is called once when we start up. | |
(defn setup [] | |
(q/smooth) ;; Turn on anti-aliasing. | |
(q/frame-rate 1) ;; Set framerate to 1 FPS. | |
(q/background 200)) ;; Set the background colour to | |
;; a nice shade of grey. |
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 text-example.core | |
(require [quil.core :as q]) | |
(:gen-class)) | |
(def screen-width 640) | |
(def screen-height 480) | |
(def blue [53 108 237]) | |
(def yellow [235 229 20]) |
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
;; try1.clj | |
(require '[clojure.string :as str]) | |
(defn count-palindromes | |
[max] | |
(let [n (atom 0)] | |
(doseq [i (range 10 max)] | |
(let [i-str (str i) | |
i-rstr (str/reverse i-str)] |
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/java -jar /home/john/opt/clojure-1.5.1/clojure-1.5.1.jar | |
(println "hi") |
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 'leiningen.exec) | |
(leiningen.exec/deps '[[org.clojure/math.combinatorics "0.0.4"]]) | |
(require '[clojure.math.combinatorics :as combo]) | |
(println | |
(combo/combinations [1 2 3] 2)) |
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
#!/bin/bash | |
lein run -m clojure.main/main -i "$@" |
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 items ["florian" "fluid" "flack" "flask" "flan"]) | |
;; Find the item that begins with "flu". | |
(println (first (filter (fn [s] | |
(re-find #"^flu" s)) | |
items))) |
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 lein-run | |
(require '[cemerick.pomegranate :as pome]) | |
(pome/add-dependencies | |
:coordinates '[[org.clojure/math.combinatorics "0.0.4"]] | |
:repositories (merge cemerick.pomegranate.aether/maven-central | |
{"clojars" "http://clojars.org/repo"})) | |
(require '[clojure.math.combinatorics :as combo]) |
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.data.codec.base64 :as base64]) | |
;;--------------------------------------------------- | |
;; From <http://en.wikipedia.org/wiki/Base64> | |
(def input "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz | |
IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg | |
dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu | |
dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo | |
ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=") |