Skip to content

Instantly share code, notes, and snippets.

Yuya Kono takoeight0821

Block or report user

Report or block takoeight0821

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@takoeight0821
takoeight0821 / Main.hs
Last active Nov 3, 2019
エキゾチックなNumインスタンス
View Main.hs
module Main where
newtype IODouble = IODouble { runIODouble :: IO Double }
instance Num IODouble where
fromInteger x = IODouble $ do
print x
pure $ fromInteger x
(IODouble x) + (IODouble y) = IODouble $ do
x' <- x
@takoeight0821
takoeight0821 / foo.s
Created Aug 31, 2019
Arch Linuxでclang -c foo.sでこれコンパイルするとclangがセグフォする
View foo.s
.intel_syntax noprefix
.text
not:
ret
f:
call not
ret
# 以下ログ
# Stack dump:
@takoeight0821
takoeight0821 / main.c
Last active Apr 16, 2019
zamの実装っぽい何か
View main.c
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <gc.h>
#include <stdint.h>
struct value;
struct env
{
@takoeight0821
takoeight0821 / main.c
Last active Apr 13, 2019
スタックマシンっぽい何か
View main.c
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <gc.h>
union value;
struct env;
struct closure;
union value;
@takoeight0821
takoeight0821 / main.js
Last active Feb 5, 2019
ダブルクロス対応のダイスbot
View main.js
const Discord = require('discord.js');
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
}
function diceRoll(count, roll) {
let dices = [];
@takoeight0821
takoeight0821 / main.cc
Last active Dec 11, 2018
競プロの簡単な問題を解いたときの副産物
View main.cc
#include <iostream>
#include <tuple>
#include <algorithm>
#include <vector>
using namespace std;
template <typename T>
unsigned int digit_sum(T x, unsigned int base) {
auto result = 0;
@takoeight0821
takoeight0821 / main.c
Created Dec 7, 2018
逆ポーランド記法電卓っぽい何か
View main.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LEN 256
typedef struct stack {
int *stack;
int len;
} Stack;
@takoeight0821
takoeight0821 / AstDsl.hs
Created Nov 28, 2018
ASTを構築する言語内DSLについて色々考えたメモ
View AstDsl.hs
module AstDsl where
import Control.Monad.State
import Control.Monad.Identity
import Data.Monoid
import Control.Monad.Writer
-- こんな普通のAST定義があるとする
data Expr = Let String Expr Expr
| Var String
@takoeight0821
takoeight0821 / Fib.v
Last active Jun 13, 2018
ひろしま学生IT勉強会で発表した資料です
View Fib.v
(* 普通の再帰で書いたfibと、末尾再帰のfibが等しいことをCoqで証明
http://www.madsbuch.com/blog/100-days-of-fibonacci-day-7-coq/
を参考にした。
*)
From mathcomp Require Import ssreflect.all_ssreflect.
Fixpoint fib1 (n : nat) : nat :=
match n with
| 0 => 0
| 1 => 1
@takoeight0821
takoeight0821 / polyrec.hs
Created May 31, 2018
これは多相再帰型が一般には推論できないみたいな話なのか
View polyrec.hs
data T = A | B | C T
deriving (Show, Eq)
class HasT a where
t :: a -> T
instance HasT T where
t = id
instance HasT a => HasT (Maybe a) where
You can’t perform that action at this time.