First three hours of Clojure.
Small (~3 people) group, Java experience, some Javascript and other dynamic language experience - no prior Clojure knowledge is assumed.
; A little function that adds its two parameters together | |
(defn addit [x y] (+ x y)) | |
; This adds the value supplied in the second parameter to the atom in the first parameter, then returns the atom | |
(defn atom-adder [x y] (swap! x (partial addit y)) x) | |
(def value-atom (atom 1)) | |
; Create an agent with a reference to the atom | |
(def counter-agent (agent value-atom)) |
(def sieve (atom [])) | |
(def siever (agent sieve)) | |
(send-off siever | |
(fn [x test-set] | |
(doall | |
(map (fn [n] | |
(if (not (some | |
#(zero? (mod n %)) |
import java.io.IOException; | |
import java.nio.file.FileVisitResult; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.nio.file.SimpleFileVisitor; | |
import java.nio.file.attribute.BasicFileAttributes; | |
import org.apache.commons.lang3.StringUtils; |
(ns tron.bots | |
(:require [tron.core :as tron])) | |
(defn empty-look | |
"A mock look function which just checks for the arena | |
boundaries." | |
[pos] | |
(when-not (tron/valid-pos? pos) :wall)) | |
(defn mock-look |
try { | |
var RIGHTCURLYBRACE="}",LEFTCURLYBRACE="{"; | |
// bookmarklet to kick things off | |
//javascript:function%20runCode(e)%20%7Be.preventDefault();eval(document.getElementById(%22codearea%22).value);return%20false;%7D;(function()%7Ba=document.createElement(%22div%22);b=document.body.appendChild(a);b.style.background=%22%23eeeeee%22;b.style.width=%22100%25%22;b.style.height=%22100px%22;b.innerHTML='%3Ctextarea%20id=%22codearea%22%3E%3C/textarea%3E%3Cbutton%20id=%22runcodebutton%22%3ERun%3C/button%3E';document.getElementById('runcodebutton').addEventListener(%22click%22,runCode);a.style.position=%22absolute%22;a.style.top=%220px%22;document.getElementById(%22codearea%22).value=window.localStorage.getItem(%22codeMSG%22);a.style.zIndex=%221000%22%7D)(); | |
function bootstrap() { | |
// get ourself |
function addUploadControl() { | |
if(document.getElementById("imageUpload")===null) { | |
var fileInputContainer=document.createElement("div"); | |
var fileInput=document.createElement("input"); | |
fileInputContainer.style.backgroundColor="white"; | |
fileInputContainer.style.padding="10px"; | |
fileInputContainer.style.borderColor="black"; | |
fileInputContainer.style.borderRadius="10px"; |
Hello World |
try { | |
var RIGHTCURLYBRACE = "}", LEFTCURLYBRACE = "{"; | |
// bookmarklet to kick things off | |
//javascript:function%20runCode(e)%20%7Be.preventDefault();eval(document.getElementById(%22codearea%22).value);return%20false;%7D;(function()%7Ba=document.createElement(%22div%22);b=document.body.appendChild(a);b.style.background=%22%23eeeeee%22;b.style.width=%22100%25%22;b.style.height=%22100px%22;b.innerHTML='%3Ctextarea%20id=%22codearea%22%3E%3C/textarea%3E%3Cbutton%20id=%22runcodebutton%22%3ERun%3C/button%3E';document.getElementById('runcodebutton').addEventListener(%22click%22,runCode);a.style.position=%22absolute%22;a.style.top=%220px%22;document.getElementById(%22codearea%22).value=window.localStorage.getItem(%22codeMSG%22);a.style.zIndex=%221000%22%7D)(); | |
function bootstrap() { | |
var startTheDance = 5000; |
(defun maximize-laptop () | |
"Resize to fill my laptop display, and hide menu bar" | |
(interactive) | |
(setq ns-auto-hide-menu-bar t) | |
(set-frame-position nil 0 -22) | |
(set-frame-size nil 1660 1046 'pixelwise)) |