Skip to content

Instantly share code, notes, and snippets.

@yuchiki
yuchiki / async_test.cs
Last active May 25, 2018 08:03
sample for understanding the behavior of 'await' in C#. inspired by Jake Archibald's interesting quiz: https://twitter.com/jaffathecake/status/999269332889763840
using System;
using System.Threading.Tasks;
class Program {
const bool UseCompletedTask = true; // You can change this.
//If you use the completed task, "2 3" must be printed, because the program is run synchronously.
//If you use the incompleted task, "1 2", "2 1", "2 3", ... may be printed, because the program is run asynchronously.
static void Main() {
var x = 0;
@yuchiki
yuchiki / result.txt
Created July 30, 2018 11:07
comparison between value and reference in csharp
Java
------------
Java
------------
Perl
------------
Perl
Ruby
------------
Perl
using System;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Test {
public static void Main() {
var foo = new Foo("最初のテキスト"); // 値型の値
var bar = new Bar("最初のテキスト"); // 参照型の値
using System;
static class Program {
static void Main() {
Zero().Succ().Succ().Pred().Succ().Pred().Succ().Succ().Show();
var three = Zero().Succ().Succ().Succ();
var four = Zero().Succ().Succ().Succ().Succ();
@yuchiki
yuchiki / tail_recursion.cs
Created August 2, 2018 06:42
see whether the tail recursion gets optimized or not.
using System;
using static System.Console;
using System.Diagnostics;
using System.Linq;
class A {
static void Main() => WriteLine($"Sum:{Sum(10)}");
static int Sum(int n) => _sum(0, n);
@yuchiki
yuchiki / Enumarate.cs
Last active October 19, 2018 07:05
[C#] Enumerate IEnumerable with integer indexes
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Program {
static void Main() {
var PIString = Math.PI.ToString();
foreach (var (c, i) in PIString.Enumerate())
WriteLine($"{i + 1, 2}th letter: {c}");

Alphabet

Letter Latin Italian German Spanish French ɛnglish
A a a a
B beː bi beː be̞ be biː
C keː tʃi tseː θe̞ se siː
D deː di deː de̞ de diː
ɛ e ə
F ɛf ɛffe ɛf e̞fe̞ ef ɛf

イタリック祖語

動詞

「語根-時制-ə-人称(-受動)」の形をとる. ただし二人称複数受動のみ人称と態が融合した専用形 menai を用いる.

時制接辞

時制
@yuchiki
yuchiki / tree.cs
Last active December 12, 2018 04:29
if C# 8.0 released
using System;
namespace tree {
static class Program {
static void Main() =>
Console.WriteLine(MyTree.Sum());
static int Sum(this Tree<int> t) =>
t switch {
@yuchiki
yuchiki / Main.cs
Created December 14, 2018 07:15
Maybe monad in C#
using System;
using static Monad.Maybe;
using static System.Console;
namespace Monad {
class Program {
static void Main() {
var N = Nothing<int>();
WriteLine(f(1, 2, 3));