Skip to content

Instantly share code, notes, and snippets.

View nkoneko's full-sized avatar

Nekomura, Koneko nkoneko

  • Tokyo
View GitHub Profile
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <iostream>
#include <string>
#include <numeric>
namespace client
{
#include <iostream>
template <int N>
struct Integer
{
int& ref()
{
return x_;
}
Integer& add(int const x)
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <memory>
#include <boost/filesystem.hpp>
#include <pstream.h>
namespace toy
#!/bin/bash
usage() {
1>&2 cat <<EOS
Usage: ${0} --work-dir SVN_WORK_DIR --repo SVN_REPOS_URL --user SVN_USER:SVN_PASSWORD
EOS
}
log() {
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
unsigned short calc(unsigned short u)
{
return u ^ (u >> 1);
}
void print_bits(unsigned short u, unsigned short v)
-module(concurrent1).
-export([pong/0, ping/1, start/1]).
pong() ->
receive
{From, Msg} ->
io:format("Pong received ~w~n", [Msg]),
From ! {self(), Msg},
pong();
term ->
namespace Monad
{
interface IEither<out E, V> {}
public class Either<E, V> : IEither<E, V>
{
public readonly E Error;
public V Value { get; private set; }
public bool HasError { get; private set; }
public Either(E error)
{
namespace Example
module Main = begin
open Monad.Maybe;
let maybeString (s:string) =
if s = null || s.Length = 0 then Nothing
else Just s;
let a2A (s:string) =
namespace System.Monad
{
public class Error
{
private Error() { }
public sealed class ErrorM<A> : Error, IMonad<A, Error>
{
public IMonad<B, Error> Return<B>(B val)
{
return new ErrorM<B> { Value = val, Exc = default(Exception), HasError = false };
namespace System.Monad
{
// Monad m => m A
// e.g. Maybe Int when m = Maybe and A = Int
public interface IMonad<A, M>
{
// Monad m => b -> m b
IMonad<B, M> Return<B>(B val);
// Monad m => m a -> (a -> m b) -> m b
IMonad<B, M> Bind<B>(Func<A, IMonad<B, M>> f);