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
#[derive(Debug, PartialEq)] | |
struct BinaryTree<T> { | |
root: Option<Box<Node<T>>>, | |
} | |
#[derive(Debug, PartialEq)] | |
struct Node<T> { | |
value: T, | |
left: Option<Box<Node<T>>>, | |
right: Option<Box<Node<T>>>, |
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
license: mit |
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
license: mit |
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 net.thegeez.advent.spec-parsing | |
(:require [clojure.string :as str] | |
[clojure.spec :as s] | |
[clojure.spec.gen :as gen] | |
[clojure.test.check.generators :as tgen])) | |
;; Dependencies: | |
;; [org.clojure/clojure "1.9.0-alpha14"] | |
;; [org.clojure/test.check "0.9.0"] | |
;; Advent of Code is a series of code challenges in the form of an advent |
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
{-# LANGUAGE BangPatterns #-} | |
module SimpleExampleMvar where | |
import Control.Concurrent | |
import Control.Monad | |
import System.Environment(getArgs) | |
import Data.Int | |
import Text.Printf | |
import Control.Exception | |
import System.CPUTime | |
-- modified version of @__josejuan__ |
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
;; warm up: balancing | |
=> (s/def ::balanced | |
(s/* (s/cat :open #{'<} :children ::balanced :close #{'>}))) | |
:user/balanced | |
=> (s/conform ::balanced '[< < > < > > < >]) | |
[{:open <, :children [{:open <, :close >} {:open <, :close >}], :close >} {:open <, :close >}] | |
=> (s/conform ::balanced '[< < > < < > > > < >]) | |
[{:open <, :children [{:open <, :close >} {:open <, :children [{:open <, :close >}], :close >}], :close >} {:open <, :close >}] | |
;; infix to prefix |
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 clj-spec.fish | |
(:require [schema.core :as schema] | |
[clojure.spec :as spec] | |
[clojure.spec :as s])) | |
;; just beginning | |
;; Schema does this | |
(def Data | |
"A schema for a nested data type" |
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 clj-bt.bencoding | |
(:require [clojure.string :as s] | |
[the.parsatron :as p :refer [defparser let->> >>]])) | |
;; decoding | |
(defparser zero [] (>> (p/char \0) (p/always 0))) | |
(defparser non-zero [] (p/token #{\1 \2 \3 \4 \5 \6 \7 \8 \9})) | |
(defparser positive [] | |
(let->> [fst (non-zero) |