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
#include <stdbool.h> | |
#include <stddef.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <errno.h> | |
#define return_null_if_null(p) \ | |
do { \ |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
) | |
// Partition is an equivalence relation over disjoint sets. | |
type Partition interface { |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from __future__ import division | |
def term(i): | |
# n = 4.0/(2*i + 1) | |
# return -n if i & 1 else n | |
return (-1)**i * 4.0/(2*i + 1) |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"math/big" | |
) | |
// readInt reads an integer from standard input. | |
func readInt() (int, error) { |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"math" | |
"math/big" | |
) | |
// readInt reads an integer from standard input. |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"math/big" | |
) | |
// readInt reads an integer from standard input. | |
func readInt() (int, error) { |
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
// Package semaphore contains implementations of counting semaphores using both | |
// buffered channels and condition variables. | |
package semaphore | |
import "errors" | |
// Semaphore defines the protocol for any counting semaphore. | |
type Semaphore interface { | |
// Acquire blocks until a slot can be acquired in the counting semaphore. | |
Acquire() |
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
FOo |
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
type errWriter struct { | |
w io.Writer | |
err error | |
} | |
func (e *errWriter) Write(p []byte) { | |
if e.err != nil { | |
return | |
} | |
_, e.err = e.w.Write(p) |
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
/** | |
* Fisher-Yates in-place shuffle. | |
* | |
* @see: http://bost.ocks.org/mike/algorithms/#shuffling | |
* @param {!Array} array An array of items. | |
*/ | |
var fisherYatesShuffle = function(array) { | |
var n = array.length | |
var t; | |
var i; |