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 ticzip.core | |
(:require [clojure.zip :as z])) | |
(def game {:board (vec (repeat 9 nil)) | |
:player :x}) | |
(def next-player {:x :o, :o :x}) | |
(defn- free-tiles [{:keys [board]}] | |
(->> board |
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 ttt-gametree.core) | |
(def win-patterns [[0 1 2] ; 1st row | |
[3 4 5] ; 2nd row | |
[6 7 8] ; 3rd row | |
[0 4 8] ; diagonal | |
[2 4 6] ; diagonal | |
[0 3 6] ; 1st col | |
[1 4 7] ; 2nd col | |
[2 5 8]]) ; 3rd col |
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 variants-playground.core | |
(:require [clojure.core.typed :as t :refer [cf defalias ann U Value Str HVec HMap]] | |
[clojure.core.match :refer [match]])) | |
(defmacro Variant [& lst] | |
`(U ~@(for [[tag & items] lst] | |
`(HVec [(Value ~tag) | |
(HMap :mandatory ~@items)])))) | |
(println (macroexpand '(Variant [:foo {:bar 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
(require hy.contrib.loop) | |
(import [random [shuffle]]) | |
(def ranks (+ (range 2 11) [:a :k :q :j])) | |
(def suits [:h :c :d :s]) | |
;; OH MY IMPERATIVE GAAWD! | |
(def deck []) | |
(for [rank ranks | |
suit suits] |
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 | |
sed -i "s/http:\/\/.*ubuntu.com\/ubuntu/http:\/\/old-releases.ubuntu.com\/ubuntu/g" /etc/apt/sources.list |
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
;;; Concurrent prime sieve using core.async in clojure | |
(ns primesieve.core | |
(:require [clojure.core.async :as async :refer [go-loop chan >! <! <!! close! filter< to-chan]])) | |
(def bufsize 512) | |
(defn gen [upper-limit] | |
"Returns channel, puts numbers from 2 to upper-limit into channel" | |
(to-chan (range 2 upper-limit))) |
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
(fact (let [c (chan) | |
_ (>!! c :hallo)] | |
(deref (future (<!! c)) 200 :timeout) => :hallo)) |
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
;;; Kompiler og kjoer med: | |
;;; nasm -f elf64 -F stabs kake.asm && gcc -o kake kake.o && ./kake | |
global main | |
extern printf | |
segment .data | |
formatert db 'Svaret er: %u!', 0Ah, 0h | |
segment .text |
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 yathzee.core | |
(:require [clojure.set :refer :all])) | |
(defn- sum [list] | |
(reduce + list)) | |
(defn score-singles [num roll] | |
(sum (filter #(= num %) roll))) | |
(def score-1s (partial score-singles 1)) |
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
;; Anything you type in here will be executed | |
;; immediately with the results shown on the | |
;; right. | |
(import [com.pi4j.wiringpi Spi]) | |
(def reg {:no-op (byte 0x0) | |
:row-1 (byte 0x1) | |
:row-2 (byte 0x2) | |
:row-3 (byte 0x3) |