Skip to content

Instantly share code, notes, and snippets.

View alanjohnjames's full-sized avatar

Alan James alanjohnjames

  • London
  • 22:30 (UTC -12:00)
View GitHub Profile
//
// http://stackoverflow.com/questions/2502354/what-is-pattern-matching-in-functional-languages
//
// Instead of writing
double f(int x, int y) {
if (y == 0) {
if (x == 0)
return NaN;
@alanjohnjames
alanjohnjames / count_all.cpp
Created November 5, 2015 12:43
Count all elements of a std::vector that are NaN or Inf
// Example program
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <algorithm>
template <typename BinaryFunctionT /*= std::less<double>*/ >
int count_all(const std::vector<double>& vec, double value, BinaryFunctionT func )