Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Welch michaelgwelch

View GitHub Profile
@michaelgwelch
michaelgwelch / combinations.swift
Last active Aug 29, 2015
Producing Combinations in Swift based on Eric Lippert's post
View combinations.swift
// Producing combinations
// Porting Eric Lippert's code to Swift
// http://ericlippert.com/2014/10/13/producing-combinations-part-one/
import Cocoa
public class ImmutableStack<T> {
public func push(t:T) -> ImmutableStack<T> {
return NonEmptyStack(top: t, tail: self)
@michaelgwelch
michaelgwelch / Predicate.swift
Created Jun 5, 2014
Swift Programming Language (Apple) Predicate<T>
View Predicate.swift
class Predicate<T> {
let pred:(T) -> Bool
init(pred:(T) -> Bool) {
self.pred = pred
}
subscript(input:T) -> Bool {
get {
return pred(input)
}
}
@michaelgwelch
michaelgwelch / link_story2.user.js
Created Mar 24, 2012
A greasemonkey script that creates a link from commit to story on pivotal tracker
View link_story2.user.js
@michaelgwelch
michaelgwelch / main.hs
Created Mar 10, 2012
Easy way to generate a random number in ghci
View main.hs
let rand = randomRIO (0,100);
-- or just type "randomRIO (lo, hi)"
View EnumerableExtensions.cs
using System.Collections.Generic;
namespace CollectionsExtensions
{
public static class EnumerableExtensions
{
/// <summary>
/// Provides an extension method that gets an iterator for
/// IEnumerables. This makes it as easy to get an iterator as it
/// is to get an enumerator.
You can’t perform that action at this time.