Skip to content

Instantly share code, notes, and snippets.

View Manu343726's full-sized avatar

Manu Sánchez Manu343726

View GitHub Profile
@Manu343726
Manu343726 / main.cpp
Created November 21, 2014 14:48
tuple monad (with maybe for filtering)
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <experimental/optional>
#include <utility>
auto naked_tuple = [](auto... xs)
{
return [=](auto f)
@Manu343726
Manu343726 / cowbasic_string.hpp
Last active November 15, 2023 17:44
(conceptual) COW string implementation
/*
* A simple Copy On Write (COW) string implementation.
*
* Copyright © 2014 Manu Sanchez. @Manu343726 on GitHub, Stack Overflow, etc.
*
* manu343726.github.io
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
@Manu343726
Manu343726 / cpp14monad.cpp
Last active January 23, 2024 11:41
C++14 tuple continuation monad
//Author: Manu Sánchez (Manu343726). Aug 2014
//Everything started from this: http://stackoverflow.com/questions/25338795/is-there-a-name-for-this-tuple-creation-idiom
//Now, play with C++14!
#include <utility>
#include <iostream>
#include <exception>
template<typename... Ls>
@Manu343726
Manu343726 / haskell_function.cpp
Created May 3, 2014 16:00
Haskell-like partial function calls for C++11
/****************************************************************************
* Haskell-like automatic partial functions *
* *
* Copyright © 2014 Manuel Sánchez Pérez *
* *
* This program is free software. It comes without any warranty, to *
* the extent permitted by applicable law. You can redistribute it *
* and/or modify it under the terms of the Do What The Fuck You Want *
* To Public License, Version 2, as published by Sam Hocevar. See *
* http://www.wtfpl.net/ for more details. *