Skip to content

Instantly share code, notes, and snippets.

Avatar

Yuya Kono takoeight0821

View GitHub Profile
@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 / 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
@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 / Demo.v
Created Jan 6, 2018
ひろしま学生IT勉強会で発表した資料です
View Demo.v
Theorem p : forall (A : Type)
(b : bool)
(x : A),
(if b then x else x) = x.
Proof.
intros A b x.
destruct b.
- reflexivity.
- reflexivity.
Qed.
@takoeight0821
takoeight0821 / bf.rs
Created Dec 13, 2017
RustでBFインタプリタ(なんもわからん)
View bf.rs
use std::io::{self, Read, stdin};
use std::collections::HashMap;
#[derive(Debug)]
struct BFM {
program: String,
tape: Vec<i32>,
ip: usize,
dp: usize,
braces: HashMap<usize, usize>,
View hard.c
#include <stdio.h>
int main(void) {
char flag[12];
flag[0] = 'F';
flag[1] = 'L';
flag[2] = 'A';
flag[3] = 'G';
flag[4] = '{';
flag[5] = 'h';
View easy.c
#include <stdio.h>
int main(void) {
char* flag = "FLAG{hello_world}";
puts("hello");
return 0;
}
@takoeight0821
takoeight0821 / othello.c
Last active May 22, 2018
『実用Common Lisp』に出てくるオセロをCに移植(単純なCPU対戦まで)
View othello.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#define EMPTY 0
#define BLACK 1
#define WHITE 2
#define OUTER 3
@takoeight0821
takoeight0821 / oxgame.lisp
Created Jul 5, 2017
マルバツゲーム
View oxgame.lisp
(defparameter *board*
(list #\_ #\_ #\_
#\_ #\_ #\_
#\_ #\_ #\_))
(defun show-board (board)
(format t " 012~%")
(format t "0 ~{~a~}~%" (subseq board 0 3))
(format t "1 ~{~a~}~%" (subseq board 3 6))
(format t "2 ~{~a~}~%" (subseq board 6 9)))
You can’t perform that action at this time.