Skip to content

Instantly share code, notes, and snippets.

Harrison Brown hrb90

Block or report user

Report or block hrb90

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
hrb90 / arc_segment_intersection.js
Last active Jan 6, 2018
arc/segment intersection in javascript
View arc_segment_intersection.js
// returns an array of real solutions to the quadratic ax^2 + bx + c = 0
const quadratic = (a, b, c) => {
if (a === 0) return [ -c/b ];
const discriminant = b*b - 4*a*c;
if (discriminant < 0) {
return [];
} else {
const y = - b / (2 * a);
const x = Math.sqrt(discriminant) / (2 * a);
return [y + x, y - x];
hrb90 / banach-tarski.purs
Last active Jan 3, 2018
What's an anagram of Banach-Tarski? Banach-Tarski Banach-Tarski.
View banach-tarski.purs
module BanachTarski where
import Prelude
import Data.Foldable (and, foldr)
import Data.Group.Free (FreeGroup(..), Signed(..), free)
import Data.List ((:))
import Data.Tuple (Tuple, snd)
import Math (Radians, acos, cos, sin)
View hutton.purs
module Main where
import Prelude hiding (between)
import Control.Monad.Eff (Eff)
import Data.Array (foldr, many, reverse, some, uncons)
import Data.Bifunctor (lmap)
import Data.Either (Either)
import Data.Functor (voidRight)
import Data.Maybe (Maybe(..))
hrb90 / ProfunctorLens.js
Last active Nov 15, 2017 — forked from tel/ProfunctorLens.js
Pure Profunctor Lenses in ES6
View ProfunctorLens.js
* Lens types.
* ===========
* a * b = {fst: a, snd: b}
* a + b = {index: Boolean, value: a | b}
* Iso s t a b = forall (~>) . Profunctor (~>) => (a ~> b) -> (s ~> t)
* Lens s t a b = forall (~>) . Strong (~>) => (a ~> b) -> (s ~> t)
* Prism s t a b = forall (~>) . Choice (~>) => (a ~> b) -> (s ~> t)
hrb90 / purescript-confusion.purs
Last active Nov 7, 2017
purescript-by-example chapter 9 lsystem problem 1
View purescript-confusion.purs
module Example.LSystem where
import Prelude
import Control.Monad.Eff (Eff)
import Data.Array (foldM)
import Data.Maybe (Maybe(..))
import Graphics.Canvas (CANVAS, closePath, fillPath, getCanvasElementById, getContext2D, lineTo, moveTo, setFillStyle, setStrokeStyle, strokePath)
import Math as Math
import Partial.Unsafe (unsafePartial)
hrb90 / binary_tree_invert.hs
Last active Sep 1, 2017
i is a haskell programmer
View binary_tree_invert.hs
{-# LANGUAGE DeriveFunctor #-}
data MaybePair a = Pair (Maybe a) (Maybe a)
deriving (Eq, Show, Functor)
data BinaryTree a =
Node a (MaybePair (BinaryTree a))
deriving (Eq, Show)
invert :: BinaryTree a -> BinaryTree a
hrb90 / monadic-fizzbuzz.js
Last active Nov 28, 2017
FizzBuzz with monads!
View monadic-fizzbuzz.js
You've probably seen FizzBuzz before. If you need a reminder, the problem is
this: Print out a list of numbers from 1 to 100, except that if a number's
divisible by 3, replace it with "Fizz", and if it's divisible by 5, replace it
with "Buzz". If it's divisible by 3 and 5, replace it with "FizzBuzz".
This is pretty straightforward to do in JavaScript with a for loop and some
if-then blocks, but it quickly gets more complicated. What if we want to add
"Quux" at the end of every number divisible by 7? And also add "Prime" at the
hrb90 /
Created Jul 26, 2017
Python implementation of algorithm for correlated equilibria described in Hart and Mas-Colell (2000)
# Written by Daniel Filan (2017) based on the algorithm described in Hart and Mas-Colell (2000)
# This code is in the public domain.
# This script implements the Hart-Mas-Colell algorithm for finding correlated
# equilibria in many-player many-action games via the players following a simple
# adaptive procedure.
import numpy as np
import random
You can’t perform that action at this time.