Skip to content

Instantly share code, notes, and snippets.

Standard ML で簡易タイマを書いてみた

概要

time(1) コマンドや、Common Lisp の time 関数 のような、 処理全体にどのくらい時間がかかっているのか教えてくれる関数が Standard ML の標準ライブラリになさそうだった。なので自分でいい加減なものを書いてみた。

幸い、実行時間を測るタイマ自体は標準ライブラリが提供してくれていた。

Standard ML のコードをリアルタイムにチェックする (Emacs + Flycheck + MLton)

必要なもの

  1. Emacs
  2. Flycheck
  3. MLton

手順

@hebiyan
hebiyan / flycheck-mlton.el
Last active February 6, 2020 16:58
Elisp code that enables syntax and type checking of Standard ML code using MLton through Flycheck.
(flycheck-define-checker mlton
"Standard ML type and syntax checking with mlton compiler.
See URL 'http://mlton.org"
:command ("mlton" "-stop" "tc" source)
:error-patterns
((error line-start "Error: " (file-name) blank line ?\. column ?\. "\n"
(message (1+ line-start (1+ blank) (+ nonl) "\n"))))
:mode (sml-mode))
@hebiyan
hebiyan / 14-125431.md
Last active June 5, 2022 11:29
Rust での読み込み処理を短く書きたい

動機

オンラインジャッジなどの問題では、「n 個の数字を読み込む」コードをしょっちゅう書く。Rust でこれを扱うとき、大体こんなかんじではないか。
(読み込む個数 n は問題で指定されているとする)

/* 標準入力を開いて */
let mut scan = std::io::stdin();

let mut line = String::new();
@hebiyan
hebiyan / 08-143152.md
Last active September 9, 2015 01:45
Gist で ブログを書く環境を整える

動機

  • Markdown で記事を書きたい
  • でも良い Web サービスがなさげ
  • GitHub Pages はめんどくさそう
  • GitHub Gist でも Markdown は書ける
  • これでいいんじゃね

参考

@hebiyan
hebiyan / gist:26c52dca99390aff6bcc
Last active September 8, 2015 04:51
Gist で Markdown を試してみる

head

日本語の見出しは使えないのか?

  • test
  • test2
  • test3
(format t "hello world")
(defun tarai (x y z)
(declare (optimize (speed 3) (safety 0)))
(if (<= x y)
y
(tarai (tarai (1- x) y z)
(tarai (1- y) z x)
(tarai (1- z) x y))))
(compile 'tarai)
(print (tarai 12 6 0))