theme | class | ||
---|---|---|---|
gaia |
|
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
module Lib where | |
data Wrapped a = | |
Exists a | DoesNotExist | |
data RecordUpdate = | |
RecordUpdate | |
{ rua :: Wrapped Int | |
, rub :: Wrapped Int | |
, ruc :: Wrapped Int |
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
{ stdenv, pkgs, patchelf, libX11, alsaLib, SDL }: | |
stdenv.mkDerivation rec { | |
name = "sunvox-${version}"; | |
version = "1.9.1"; | |
src = ./sunvox-1.9.1.zip; | |
buildInputs = [ pkgs.unzip patchelf]; | |
libPath = stdenv.lib.makeLibraryPath [ |
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
(defn iform | |
"Derive the infinity series interval of a particular index in the seq" | |
[n] | |
(let [bin (map #(js/parseInt %) (.split (.toString n 2) #""))] | |
(reduce #(if (zero? %2) (unchecked-negate-int %1) (inc %1)) 0 bin))) | |
(def iseries | |
"Generate the infinity series lazily - 0, 1, -1, 2, 1, 0, -2, 3..." | |
(map #(iform %) (iterate inc 0))) |
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 sumofprimes) | |
(def primes "Infinite, lazy sequence of prime numbers." | |
((fn step [m n] | |
(or | |
(some-> (get m n) (-> (->> (reduce #(update %1 (+ %2 n) conj %2) (dissoc m n))) (step (inc n)))) | |
(-> (assoc m (* n n) (list n)) (step (inc n)) (->> (cons n) (lazy-seq))) | |
)) {} 2)) | |
; without threading |
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 primepalindromes) | |
(defn reverse-number [number reversed] | |
(if (= number 0) | |
reversed | |
(reverse-number (quot number 10) | |
(+ (rem number 10) (* reversed 10))))) | |
(defn prime? [n] | |
(.isProbablePrime (BigInteger/valueOf n) 5)) | |
(println (dec (last (take-while #(not (and (prime? %) (= (reverse-number % 0) %))) (iterate dec 1000))))) |
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 fizzbuzz) | |
(use 'clojure.string) | |
(defn fizzbuzz [line] | |
(let [[x y n] (map #(Integer. %) (split line #"\s+"))] | |
(join " " (map | |
#(cond | |
(and (zero? (mod % x)) (zero? (mod % y))) "FB" | |
(zero? (mod % x)) "F" | |
(zero? (mod % y)) "B" | |
:else %) |
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 longestlines) | |
(use 'clojure.string) | |
(let [files (map #(trim %) (split (slurp (first *command-line-args*)) #"\n"))] | |
(println (join "\n" (take (Integer. (first files)) (sort-by count > files))))) |