Skip to content

Instantly share code, notes, and snippets.

@matarillo
matarillo / Program.cs
Created February 13, 2014 09:01
王女様のジェムストリング問題 ref: http://qiita.com/matarillo/items/c95f2a33bd0723a25875
using System;
using System.Diagnostics;
using System.Linq;
class Program
{
static void Main(string[] args)
{
var gems = new[] { 1, 4, 1, 4, 2, 1, 3 };
var pattern = "eagcdfbe".Select(x => x - 'a').ToArray();
@matarillo
matarillo / TupleComparer.cs
Created February 18, 2014 12:43
複数キーのルックアップテーブル ref: http://qiita.com/matarillo/items/5441acf8cf686371bee1
class TupleComparer<T1, T2, T3, T4> : EqualityComparer<Tuple<T1, T2, T3, T4>>
{
private static readonly IEqualityComparer<T1> comparer1
= EqualityComparer<T1>.Default;
private static readonly IEqualityComparer<T2> comparer2
= EqualityComparer<T2>.Default;
private static readonly IEqualityComparer<T3> comparer3
= EqualityComparer<T3>.Default;
private static readonly IEqualityComparer<T4> comparer4
= EqualityComparer<T4>.Default;
Imports System.Collections.ObjectModel
Module Module1
Sub Main()
Dim c As New Collection(Of Integer) From {1}
Foo(Of Integer)(c)
End Sub
Sub Foo(Of T)(ByVal o As Object)
Option Strict Off
Imports System.Text
Module Module1
Sub Main()
Dim table As New Dictionary(Of String, Object)()
table("test") = New List(Of Integer) From {1, 2, 3}
Console.WriteLine(DictionaryToString(table))
If TypeOf .Value Is List(Of Integer) Then
sb.Append(CType(.Value, List(Of Integer)))
ElseIf TypeOf .Value Is List(Of String) Then
sb.Append(CType(.Value, List(Of String)))
ElseIf TypeOf .Value Is List(Of Object) Then
sb.Append(CType(.Value, List(Of Object)))
End If
Option Strict On
Imports System.Text
Imports System.Reflection
Module Module1
Sub Main()
Dim table As New Dictionary(Of String, Object)()
table("test") = New List(Of Integer) From {1, 2, 3}
Option Strict On
Imports System.Text
Module Module1
Sub Main()
Dim table As New Dictionary(Of String, Object)()
table("test") = New List(Of Integer) From {1, 2, 3}
Console.WriteLine(DictionaryToString(table))
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
[TestClass]
public class GrepUtilTest
{
@matarillo
matarillo / Program.java
Created April 22, 2014 08:33
Yコンビネータでラムダ式が再帰関数に変わるからフィボナッチ数も計算できる、Java8版 ref: http://qiita.com/matarillo/items/9e1a058d186104a1f964
package example;
import java.util.function.*;
public class Program {
public static void main(String[] args) {
Function<Integer, Integer> fib
= Y(f -> n -> n > 1 ? f.apply(n - 1) + f.apply(n - 2) : n);
using System;
using System.Collections.Generic;
internal class Program
{
private static void Main(string[] args)
{
Value<Maybe, int> m1 = Maybe.Instance.Unit(12);
Value<Maybe, int> m2 = Maybe.Instance.Unit(34);
Value<Maybe, int> m3 =