Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
template <typename T>
struct ShowType
{
static constexpr const char * type = "value";
};
template <typename T>
struct ShowType<T&>
#include <vector>
#include <list>
#include <iostream>
#include <cassert>
using namespace std;
//both foo() and bar() try to do the same thing:
//print the first elemnt in c and append it to c.
#include <map>
#include <vector>
#include <string>
#include <memory>
#include <iostream>
using namespace std;
template <typename T>
//There are 3 files: seq.h seq.cc main.cc
//Compile with: g++ -std=c++11 main.cc seq.cc
//-------- seq.h ------------
#include <stdlib.h>
#include <string.h>
#include <limits>
#include <cassert>
#include <initializer_list>
#include <iostream>
#include <string>
using namespace std;
class Base
{
public:
Base(const string &firstname, const string &lastname)
: firstname_(firstname)
#include <string>
#include <iostream>
#include <type_traits>
using namespace std;
class Person
{
public:
Person(const std::string &name, int age)
// Compile: g++ -std=c++11 -Wall replace_var.cc -o replace_var
// Tested with g++-4.7.2
#include <string>
#include <map>
#include <cctype>
#include <iostream>
typedef std::map<std::string, std::string> TVarMap;
#pragma once
#include <boost/optional.hpp>
/**
* Wraps any value with a context of Left for the Either class.
*
* By convention, Left represents some sort of less-desired condition.
*/
I like LYAH as a reference and cheat-sheet but I found it a little slow for learning Haskell.
Here's my recommended order for just learning Haskell:
http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-Way/ 80% completion here is fine if you feel your attention waning, the next thing will address hammering in things like functors and monads via typeclasses.
https://github.com/NICTA/course/ this will hammer in the lessons in a very direct form by forcing you to confront the challenges and lessons learned by the creators and community of Haskell itself. Doing the exercises here is critical for being fluent.
Real World Haskell is available online. I recommend it as a reference only.
@beyondwdq
beyondwdq / build.sh
Last active December 21, 2020 21:58
std::unordered_map with custom key type
g++ -std=c++11 custom_hash.cc -o custom_hash