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> | |
template <typename T> | |
struct ShowType | |
{ | |
static constexpr const char * type = "value"; | |
}; | |
template <typename T> | |
struct ShowType<T&> |
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 <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. |
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 <map> | |
#include <vector> | |
#include <string> | |
#include <memory> | |
#include <iostream> | |
using namespace std; | |
template <typename T> |
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
//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> |
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 <string> | |
using namespace std; | |
class Base | |
{ | |
public: | |
Base(const string &firstname, const string &lastname) | |
: firstname_(firstname) |
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 <string> | |
#include <iostream> | |
#include <type_traits> | |
using namespace std; | |
class Person | |
{ | |
public: | |
Person(const std::string &name, int age) |
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
// 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; |
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
#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. | |
*/ |
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
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. |
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
g++ -std=c++11 custom_hash.cc -o custom_hash |
NewerOlder