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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace ListReverse | |
{ | |
/// <summary> | |
/// Demonstrate two methods which reverse the elements in a list. | |
/// </summary> | |
class Program |
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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <string> | |
// Reverse the elements in a vector. | |
template <typename T> | |
std::vector<T> Reverse(std::vector<T> input) | |
{ | |
std::vector<T> output; |
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
// #FixMyCode | |
// This code attempts to find a given string within another string, matching the given string exactly. | |
// Can you make it more correct, more elegant, faster, or just plain better? If so, please do! | |
// Fork this Gist and tweet me the result @joshuampeterson. | |
#include <string> | |
#include <iostream> | |
bool IsWordDelimiter(char character) | |
{ | |
return character == ' ' || character == '.' || character == ',' || |
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
// #FixMyCode | |
// This code queues some work for a background thread, then waits for that work to complete. | |
// Can you make it more correct, more elegant, faster, or just plain better? If so, please do! | |
// Fork this Gist and tweet me the result @joshuampeterson. | |
using System; | |
using System.Collections.Generic; | |
using System.Threading; | |
namespace WaitForBackgroundThread | |
{ |
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
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
namespace StatisticsMethods | |
{ | |
interface StatisticsMethod | |
{ | |
void Accumulate(double value); | |
void PostProcess(); |
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 <cstdlib> | |
#include <ctime> | |
#include <iostream> | |
// From http://stackoverflow.com/questions/2704521/generate-random-double-numbers-in-c | |
double fRand(double fMin, double fMax) | |
{ | |
double f = (double)rand() / RAND_MAX; | |
return fMin + f * (fMax - fMin); | |
} |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using ClaySharp; | |
namespace ConsoleApplication2 | |
{ | |
class Program | |
{ |
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
using NUnit.Framework; | |
namespace TennisScoringKata | |
{ | |
[TestFixture] | |
public class DefineTennisGame | |
{ | |
private TennisGame game; | |
[SetUp] |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace UnexpectedLoop | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
OlderNewer