Skip to content

Instantly share code, notes, and snippets.

@yonta
yonta / LICENSE
Last active September 14, 2023 09:37
Chintai
MIT License
Copyright (c) 2023 SAITOU Keita
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@yonta
yonta / LoopCell.sml
Created August 2, 2023 20:51
Loop Cell
datatype 'a cell = CELL of 'a * 'a cell option ref
val cell = CELL (1, ref NONE)
(* val cell = CELL (1, ref NONE) : int cell *)
val cellRef = ref (SOME cell)
(* val cellRef = ref (SOME (CELL (1, ref NONE))) : int cell option ref *)
cellRef := SOME (CELL (1, cellRef))
(* val it = () : unit *)
cellRef
(*
val it =
@yonta
yonta / base_price.gp
Last active May 23, 2023 07:56
電気・ガス代の比較
chubudenki_base_price = 1144
chubudenki1(x) = (x < 0) ? NaN : ((x <= 120) ? 21.4 * x + chubudenki_base_price : NaN)
chubudenki2(x) = (x <= 120) ? chubudenki1(x) : ((x <= 300) ? 25.51 * (x - 120) + chubudenki1(120) : NaN)
chubudenki3(x) = (x <= 300) ? chubudenki2(x) : 28.46 * (x - 300) + chubudenki2(300)
tohodenki_base_price = 936
tohodenki1(x) = (x < 0) ? NaN : ((x <= 120) ? 21.02 * x + tohodenki_base_price : NaN)
tohodenki2(x) = (x <= 120) ? tohodenki1(x) : ((x <= 200) ? 25.46 * (x - 120) + tohodenki1(120) : NaN)
tohodenki3(x) = (x <= 200) ? tohodenki2(x) : ((x <= 250) ? 25.48 * (x - 200) + tohodenki2(200) : NaN)
tohodenki4(x) = (x <= 250) ? tohodenki3(x) : ((x <= 300) ? 25.50 * (x - 250) + tohodenki3(250) : NaN)
@yonta
yonta / MutableDeque.sml
Last active June 17, 2020 13:31
破壊的デック
structure MutableDeque :
sig
type 'elem t
val empty : unit -> 'elem t
val cons : 'elem -> 'elem t -> 'elem t
val head : 'elem t -> 'elem
val tail : 'elem t -> 'elem t
val snoc : 'elem -> 'elem t -> 'elem t
val last : 'elem t -> 'elem
val init : 'elem t -> 'elem t
signature SHOW =
sig
type t
val show : t -> string
end
structure ShowInt : SHOW where type t = int =
struct
type t = int
val show = Int.toString
@yonta
yonta / flycheck-mlton.el
Last active December 4, 2020 08:06 — forked from hebiyan/flycheck-mlton.el
Elisp code that enables syntax and type checking of Standard ML code using MLton through Flycheck.
;;; flycheck-mlton.el --- Flycheck: MLton support -*- lexical-binding: t; -*-
;; This code is modified by SAITOU Keita <keita44.f4@gmail.com>.
;;
;; Original source is available here,
;; URL: http://hebiyan.hatenablog.com/entry/20160316/1458125059
;; Package-Requires: ((emacs "24.1") (flycheck "0.22") (sml-mode "0.4"))
;;; Commentary:
@yonta
yonta / recipe.md
Last active August 30, 2023 15:37
芋煮会の準備手順

山形芋煮

材料の下ごしらえ

  1. ネギとごぼうを切って、それぞれ別袋にいれておく

会場

  1. 鍋の外側に液体洗剤を塗る(同時に火をつけ始める)
  2. 鍋に水を1/2~2/3にいれて火にかける
;;; 結局採用したやつ
(defun call-with-region-or-line (func-symbol)
"Call FUNC-SYMBOL with marked region or current line.
If the region is active, beggining and end of region is used for the function
arguments, othewise current line is used."
(if (region-active-p)
(funcall func-symbol (region-beginning) (region-end))
(let* ((begin (line-beginning-position))
(end (1+ (line-end-position))))
;; (setq lexical-binding nil)
;;; 任意のregionを使う関数を、選択regionがないときは現在行を与えるようにする
(defun call-with-region-or-line (func)
""
(lambda () (interactive)
(if (region-active-p) (call-interactively func)
(let ((begin (line-beginning-position))
(end (1+ (line-end-position))))
(funcall func begin end)))))
@yonta
yonta / StalinSort.sml
Last active July 30, 2019 16:11
粛清だ
fun stalinSort nil = nil
| stalinSort (h::t) =
let
fun sort _ nil = nil
| sort x (h::t) =
if x < h then h :: sort h t
else sort x t
in
h :: sort h t
end