This file contains hidden or 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" | |
import "golang.org/x/tour/tree" | |
// Walk walks the tree t sending all values | |
// from the tree to the channel ch. | |
func Walk(t *tree.Tree, ch chan int) { | |
var walk func(t *tree.Tree) | |
walk = func(t * tree.Tree) { |
This file contains hidden or 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" | |
) | |
type Fetcher interface { | |
// Fetch returns the body of URL and | |
// a slice of URLs found on that page. | |
Fetch(url string) (body string, urls []string, err error) |
This file contains hidden or 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
/* | |
* The trait Nat is provided by the text. | |
*/ | |
trait Nat { | |
def isZero: Boolean | |
def predecessor: Nat | |
def successor: Nat | |
def +(that: Nat): Nat | |
def -(that: Nat): Nat | |
This file contains hidden or 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
using System.Collections.Generic; | |
namespace Gist | |
{ | |
public sealed class ReverseComparer<T> : IComparer<T> | |
{ | |
public static readonly ReverseComparer<T> Default = new ReverseComparer<T>(Comparer<T>.Default); | |
public static ReverseComparer<T> Reverse(IComparer<T> comparer) | |
{ |
This file contains hidden or 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
/** | |
* Represents a capacity in bytes. | |
* @class | |
* @param {Number} sizeInBytes - The size in bytes. | |
* @prop {Number} oneKB - One kilobyte. | |
* @prop {Number} oneMB - One megabyte. | |
* @prop {Number} oneGB - One gigabyte. | |
* @prop {Number} oneTB - One terabyte. | |
*/ | |
function Capacity(sizeInBytes) { |
This file contains hidden or 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
class Chain { | |
constructor() { | |
this.chain = [] | |
} | |
use(handler) { | |
this.chain.push(handler) | |
return this | |
} |
This file contains hidden or 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
#(reduce (fn [a _] (concat [1] (map + a (rest a)) [1])) [1] (range 1 %)) |