Skip to content

Instantly share code, notes, and snippets.

View yvt's full-sized avatar
⚠️
I'm sorry, but I cannot fulfill this request as it goes against OpenAI use po...

yvt yvt

⚠️
I'm sorry, but I cannot fulfill this request as it goes against OpenAI use po...
View GitHub Profile
@yvt
yvt / ArrayList.qn
Created October 28, 2013 13:33
Queen HTML ハイライター
{
ArrayList.qn
tcpp が 2013年10月28日 に作成.
}
interface IFormatter`T
func Format(v:T): string
end interface
class ArrayList`T
@yvt
yvt / Curry.qn
Created October 29, 2013 05:09
Queen カリー化
func AddTwo(a: int): func<(int): int>
class C
var a: int
func Eval(b: int): int
return a + b
end func
end class
var c:: #C
c.a :: a
return c.Eval
@yvt
yvt / CurryAnon.qn
Last active December 27, 2015 01:19
Queen カリー化 with 無名関数
func Times(n: int, f: func<(int)>)
for i(1, n)
f(i)
end for
end func
func Sum(f: func<(int):int>, n: int): int
var v:: 0
Times(n, func(i: int)
@yvt
yvt / QueenFPC.qn
Last active December 27, 2015 01:29
Q Language 不動点コンビネータ
{ }
{ 不動点コンビネータだよ〜 }
{ https://ja.wikipedia.org/wiki/不動点コンビネータ }
{ }
func Times(n: int, f: func<(int)>)
for i(1, n)
f(i)
end for
end func
@yvt
yvt / gist:8420170
Created January 14, 2014 15:32
4n桁の2進数を逆順にして16進数にするCプログラム
#include <stdio.h>
#define DIGIT(a) ((a)=='1'?1:0)
void rec(){
int c = getchar();
int c2 = getchar(), c3 = getchar(), c4 = getchar();
if(c < 0) return;
rec();
putchar("0123456789abcdef"[((DIGIT(c4)*2+DIGIT(c3))*2+DIGIT(c2))*2+DIGIT(c)]);
}
void main(){
@yvt
yvt / asm-red-black-tree.s
Created February 5, 2014 15:25
x86_64 System V呼び出し規約 AT/T記法のアセンブラで赤黒木 (削除は実装していない, 処理速度やコードサイズは未考慮)
#
# x86_64 赤黒木 (System V 呼び出し規約)
# (C) 2013 @YVT, all rights reserved.
#
.global _RedBlack_AllocNode
# .global _RedBlack_FreeNode
# struct TreeDescriptor {
@yvt
yvt / ping-teat.sh
Created February 7, 2014 10:04
Pingのパケット損失率をパケットサイズごとの表にしてCSV出力するスクリプト (要root)
#!/bin/sh
# 出力ファイル
OUT=/tmp/ping-test-out.csv
# ホスト名 (適宜変えてね)
HOST=www.google.com
echo "ping-test to ${HOST}" > "$OUT"
#include <stdio.h>
//http://stackoverflow.com/questions/281725/template-specialization-based-on-inherit-class
template<typename D, typename B>
class IsDerivedFrom
{
class No { };
class Yes { No no[3]; };
static Yes Test( B* ); // not defined
@yvt
yvt / hilbert.cpp
Created May 31, 2014 13:22
3Dヒルベルト曲線をVoxlap KV6形式で出力するツール
#include <cstdio>
#include <vector>
#include <iostream>
#include <array>
#include <cstdlib>
#include <cstdint>
#include <memory>
#include <valarray>
#include <cassert>