Skip to content

Instantly share code, notes, and snippets.

View sniperliu's full-sized avatar

Liu Hao sniperliu

View GitHub Profile
;; 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
{-# 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__
@sniperliu
sniperliu / spec_parsing.clj
Created December 12, 2016 09:39 — forked from thegeez/spec_parsing.clj
Parsing with clojure.spec for the Advent of Code challenge
(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