Skip to content

Instantly share code, notes, and snippets.

κeen KeenS

Block or report user

Report or block KeenS

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
View cps
[| x |] = λk.k x ・・・val
[| λx.t |] = λk.k (λx.[|t|]) ・・・lam
[| π t |] = λk.[|t|] (λa.k (π a)) ・・・app1
[| t1 t2 |] = λk.[|t1|] (λf.[|t2|] (λa.f a k)) ・・・app2
[| Sx.t |] = λk.[x↦λa.λk'.k' (k a)]([|t|] (λv.v))・・・shift
[| <t> |] = λk.k ([|t|] (λv.v)) ・・・reset
変換対象: <add10 (Sx.x (x 100))>
View tayupinco.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View rust_by_example.rb
# coding: utf-8
var = [
{ "id": "hello", "title": "Hello World", "children": [
{ "id": "comment", "title": "コメント", "children": nil },
{ "id": "print", "title": "フォーマットしてプリント", "children": [
{ "id": "print_debug", "title": "デバッグ", "children": nil },
{ "id": "print_display", "title": "ディスプレイ", "children": [
{ "id": "testcase_list", "title": "テストケース: リスト", "children": nil }
] },
{ "id": "fmt", "title": "フォーマット", "children": nil }
View console.log
running 3 tests
test bench::benth_fib_memo1 ... bench: 5,237 ns/iter (+/- 411)
test bench::benth_fib_memo1_2 ... bench: 2 ns/iter (+/- 0)
test bench::benth_fib_memo2 ... bench: 2 ns/iter (+/- 0)
test result: ok. 0 passed; 0 failed; 0 ignored; 3 measured; 0 filtered out
View sytax.rs
//! parent level doc comments
mod path {
/*! parent level doc comment2 */
pub mod name {
pub type Type = String;
pub const CONSTANT: &'static str = "const";
}
}
View embedded_dsl.rs
struct DbConn;
#[derive(Clone, Copy)]
struct User;
#[derive(Clone, Copy)]
struct Device;
enum Error {
ReadPrivilege,
WritePrivilege,
@KeenS
KeenS / overload.hs
Created Jun 3, 2018
GHCで {リスト,スカラ} x {リスト,スカラ}演算のオーバーロード
View overload.hs
{-#LANGUAGE TypeFamilies, MultiParamTypeClasses, FlexibleInstances #-}
class Overload a b where
type Out a b :: *
(+):: a -> b -> Out a b
instance Overload Int Int where
type Out Int Int = Int
(+) = (Prelude.+)
View cli
$ smlsharp -v
SML# 3.4.0 (2017-08-31 19:31:44 JST) for x86_64-pc-linux-gnu with LLVM 3.7.1
$ smlsharp -O3 inner_prod.sml -o inner_prod_smlsharp
$ ./inner_prod_smlsharp
compose
Time:
[Total] 9101 ms/10calls
[Average] 910.1 ms/call
loop
Time:
View mini_vm.rs
type Ip = usize;
type Var = usize;
#[derive(Debug)]
enum Instr {
Const(i32),
Add,
Sub,
Get(Var),
Set(Var),
View ck_macro.rs
#![recursion_limit = "256"]
// スタックは以下のような形。
// [(マクロ名, (まだ評価していない引数...), (評価が終わった引数...)), ...]
//
// ck(スタック, 式)という形で評価していく。なんとなく継続を起動してるイメージ
// 評価が終わったら`q!(値)`という形で目印を付ける
//
// ただしここで受け取るマクロは全てスタックを第一引数に取るものとする。CPSでいう継続にあたる。
macro_rules! ck {
You can’t perform that action at this time.