Skip to content

Instantly share code, notes, and snippets.

View dazfuller's full-sized avatar
🤌
reality.foldLeft

Darren Fuller dazfuller

🤌
reality.foldLeft
View GitHub Profile
@dazfuller
dazfuller / permutation.go
Created February 16, 2010 20:14
Permutation algorithm implemented in GO
package permutation
import "sort"
func compare(a, b []int) int {
for i := 0; i < len(a) && i < len(b); i++ {
switch {
case a[i] > b[i]:
return 1
case a[i] < b[i]:
@dazfuller
dazfuller / Program.cs
Created September 23, 2011 10:00
Some examples using Parallelism in .NET 4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
namespace PLinqDemo
{
class Demo
@dazfuller
dazfuller / example.cpp
Created October 31, 2011 16:46
Example use of Lambda expressions and for ranges with C++11
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void FindValue(vector<string>& values, std::function<bool (const string&)> f)
{
auto i = find_if(values.begin(), values.end(), f);
@dazfuller
dazfuller / using_auto.cpp
Created November 6, 2011 20:51
Ignoring the Voices: C++11 Example - Using auto
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void cpp_old()
{
std::vector<std::string> my_collection;
my_collection.push_back("Hello");
@dazfuller
dazfuller / auto_return.cpp
Created November 6, 2011 21:06
Ignoring the Voices: C++11 Example - Using auto as a Return Type
#include <iostream>
#include "auto_return.h"
void Test::SetField(TestEnum t)
{
_field = t;
}
auto Test::GetField() -> TestEnum
@dazfuller
dazfuller / decltype_useful.cpp
Created November 6, 2011 21:31
Ignoring the Voices: C++11 Example - decltype
#include <iostream>
#include <map>
#include <string>
#include <vector>
std::map<int, std::vector<std::string>> MyFunction()
{
std::vector<std::string> v1;
v1.push_back("Hello");
v1.push_back("World");
@dazfuller
dazfuller / initializer_lists.cpp
Created November 10, 2011 01:25
Ignoring the Voices: C++11 Example - Initialization Lists
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
// Our method which takes an initialization list parameter
template<class T> void MyFunction(initializer_list<T> values)
{
@dazfuller
dazfuller / range_for_loop.cpp
Created November 10, 2011 02:29
Ignoring the Voices: C++11 Example - Range-For Statement
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<string> a = { "Ignoring", "The", "Voices" };
for (const auto s : a)
@dazfuller
dazfuller / basic_sort.cpp
Created December 16, 2011 13:52
Ignoring the Voices: C++11 Example - Basic Sorting
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void PrintList(const vector<int>& list)
{
for (auto i : list)
{
@dazfuller
dazfuller / lambda_sort.cpp
Created December 16, 2011 14:13
Ignoring the Voices: C++11 Example - Lambda Sorting
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void PrintList(const vector<int>& list)
{
for (auto i : list)
{