Skip to content

Instantly share code, notes, and snippets.

@Midoliy
Midoliy / Main.fsx
Last active March 6, 2024 09:09
代替データストリームのサンプル
#load "NativeMethod.fsx"
open System
open System.IO
open System.Text
open NativeMethod
let nullptr = IntPtr.Zero
let write (str:string) handle =
@Midoliy
Midoliy / ProjectEuler.fs
Last active July 10, 2019 21:57
Project Euler by F#
// ----------------------------------------------------------------------------------------------------------
// Problem 1 「3と5の倍数」
// -------------------------------
//
// 10未満の自然数のうち, 3 もしくは 5 の倍数になっているものは 3, 5, 6, 9 の4つがあり, これらの合計は 23 になる.
// 同じようにして, 1000 未満の 3 か 5 の倍数になっている数字の合計を求めよ.
//
// ----------------------------------------------------------------------------------------------------------
// 通常の解答 / O(N)
@Midoliy
Midoliy / Curry.cs
Last active June 9, 2019 22:07
C#で関数型プログラミング
using System;
namespace Functional
{
public static class Curry
{
public static Action curry(Action act) => act;
public static Action<T> curry<T>(Action<T> act) => act;
public static Func<T1, Action<T2>> curry<T1, T2>(Action<T1, T2> act) => t1 => t2 => act(t1, t2);
public static Func<T1, Func<T2, Action<T3>>> curry<T1, T2, T3>(Action<T1, T2, T3> act) => t1 => t2 => t3 => act(t1, t2, t3);