Skip to content

Instantly share code, notes, and snippets.

View Nymphium's full-sized avatar
⚜️
百合

Satoru Kawahara Nymphium

⚜️
百合
View GitHub Profile
\documentclass[landscape,a4paper]{article}
\usepackage{luacode}
\usepackage{pdfpages}
\begin{document}
\begin{luacode*}
local options = [==[
pages= -,
nup = 2x2,
width = 0.49\paperwidth,
function() return error() endlocal socket = require('socket')
local gettime = socket.gettime
local TIMES = 1000000
local t1 = gettime()
for _ = 1, TIMES do
pcall(error)
end
local t2 = gettime()
let run_continuer : type a. ((unit -> (unit -> a)) -> a) -> a =
fun f ->
let module M = struct
effect Save : unit -> (unit -> a);;
let save () = perform @@ Save ()
end
in
let open M in
match f save with
| effect (Save ()) k ->
awful.key({ modkey }, 't', function()
local w = {}
for _, c in ipairs(filter_ddt(get_tag_clients())) do
local str = ('/tmp/%s.png'):format(tostring{}:match('0x([0-f]+)'))
gears.surface(c.content):write_to_png(str)
local font_orig = beautiful.font:match('^(.*) %d+$')
local font_size = 14
local font = ('%s %d'):format(font_orig, font_size)
#lang racket
(require racket/control)
(struct spwn (val p) #:prefab #:extra-name Spwn)
(define (fcontrol-at p v)
(fcontrol (spwn v p)))
(define (%-at p th handler)
(require control/racket)
; (% (+ (fcontrol 3) (fcontrol 4)) (λ (x k) (k (* x x))))
; ~> ((λ (x k) (k (* x x))) 3 (λ (y) (+ y (fcontrol 4))))
; ~> ((λ (y) (+ y (fcontrol 4))) 9)
; ~> (+ 9 (fcontrol 4))
; ~> %の外側に出ちゃたあ(正しい)
(let [(p (make-continuation-prompt-tag))]
(% (+ (fcontrol 3 #:tag p) (fcontrol 4 #:tag p)) (λ (x k) (k (* x x))) #:tag p))
命令列Cと状態{m, h, w, d, p}の遷移から成るPainter Programmingの小ステップ意味論を考える。
要素が{0, 1}から成るHxW行列が得られる。
`M`atrix, `H`eight, `W`idth, `D`irection[←↓↑→], `P`rogram stack
init = { m = H x Wの000...0, h = 1, w = 1, d = →, P = []}
## 補助関数
edge_HW → H _ = true
edge_HW ← 1 _ = true
@Nymphium
Nymphium / yh.tex
Last active December 30, 2019 19:45
% lualatex main.tex
% convert -density 2000 -strip main.pdf out.png
\documentclass[tikz]{standalone}
\usepackage{graphicx}
\usepackage{pagecolor,xcolor}
\usepackage{newtxmath}
% \usepackage{pagecolor}
% \definecolor{greenback}{HTML}{00ff00}
% \pagecolor{greenback}
(*
ref: Efficient Compilation of algebraic effects and handlers
*)
type (_, _) operation = ..
type 'a computation =
| Return : 'a -> 'a computation
| Call : ('arg, 'res) operation * 'arg * ('res -> 'a computation) -> 'a computation
@Nymphium
Nymphium / embedding_with_free.lua
Created October 8, 2019 06:43
embedding algebraic effects with free (but untyped)
-- allocate variable for back patching
local bind
-- type computation
local computation = function(t)
return function(a)
return setmetatable(a, { __index = t, __shr = bind })
end
end