I hereby claim:
- I am robot-dreams on github.
- I am eyj (https://keybase.io/eyj) on keybase.
- I have a public key whose fingerprint is 3D1B 8DAF EC71 A8F6 797A 8206 8C7C 79E9 7D30 1AF0
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import Html exposing (Html, program, text) | |
main = program | |
{ init = init | |
, update = update | |
, subscriptions = subscriptions | |
, view = view | |
} |
func nextPermutation(a []int) { | |
// Find the greatest index i such that a[i] < a[i + 1] | |
i := len(a) - 2 | |
for i >= 0 && a[i] >= a[i+1] { | |
i-- | |
} | |
if i >= 0 { | |
// Find the greatest index j > i such that a[i] < a[j]; such an index | |
// exists because a[i] < a[i + 1] | |
j := len(a) - 1 |
hamming :: [Integer] | |
hamming = | |
1 : merge3 | |
(map (*2) hamming) | |
(map (*3) hamming) | |
(map (*5) hamming) | |
where | |
merge (x:xs) (y:ys) = | |
case compare x y of | |
LT -> x : merge xs (y:ys) |
import Control.Monad (foldM) | |
-- All safe placements of n queens, on a board with n rows and n columns; a | |
-- placement is safe if no two queens are attacking each other | |
queens :: Int -> [[(Int, Int)]] | |
queens n = | |
foldM (extend n) [] [1..n] | |
-- All possible ways to extend, on a board with n rows, an existing safe | |
-- placement of queens by adding an additional queen in column j |
fib :: Int -> Integer | |
fib n = | |
let fibTriplet k | |
| k <= 0 = (0, 0, 1) | |
| k == 1 = (0, 1, 1) | |
| even k = let (a, b, c) = fibTriplet (k `div` 2) | |
in (a^2 + b^2, b * (a + c), b^2 + c^2) | |
| odd k = let (a, b, c) = fibTriplet (k - 1) | |
in (b, c, b + c) | |
snd3 (_, y, _) = y |
functor WBLHeap(Element : ORDERED) : HEAP = | |
struct | |
structure Elem = Element | |
datatype Heap = E | |
| T of int * Elem.T * Heap * Heap | |
val empty = E | |
fun isEmpty E = true |
unstressed syllables -> dot (short) | |
stressed syllables -> dash (long) | |
a-BOUT .- | |
BOIS-ter-ous-ly -... | |
CARE-less CHIL-dren -.-. | |
DAN-ger-ous -.. | |
eh? . | |
fe-ne-STRA-tion ..-. | |
GOOD GRA-vy --. |
// Returns a channel that will be closed whenever ANY of the input channels are | |
// closed (or written to). | |
func or(channels ...<-chan struct{}) <-chan struct{} { | |
switch len(channels) { | |
case 0: | |
return nil | |
case 1: | |
return channels[0] | |
} | |
orDone := make(chan struct{}) |
package main | |
import ( | |
"math" | |
) | |
// We represent a region of space, containing some number of particles, as an | |
// OctTree. Leaves of the tree contain at most 1 particle (but are also allowed | |
// to represent empty regions). | |
// |