Skip to content

Instantly share code, notes, and snippets.

View KeenS's full-sized avatar

κeen KeenS

View GitHub Profile
use std::io::{self, Write};
fn main() {
let n = 600000;
let out = io::stdout();
let mut out = out.lock();
for i in 1..n {
let mut str = "".to_owned();
if i % 3 == 0 {
str.push_str("Fizz");
$ rustup run nightly rustc -Copt-level=3 --test sort.rs
$ ./sort --bench
running 6 tests
test bench_insert_sort ... bench: 571 ns/iter (+/- 22)
test bench_insert_sort_asserted ... bench: 547 ns/iter (+/- 47)
test bench_insert_sort_clone ... bench: 440 ns/iter (+/- 28)
test bench_insert_sort_clone_asserted ... bench: 428 ns/iter (+/- 16)
test bench_insert_sort_unsafe ... bench: 239 ns/iter (+/- 15)
test bench_insert_sort_unsafe_improved ... bench: 255 ns/iter (+/- 23)

Keybase proof

I hereby claim:

To claim this, I am signing this object:

; https://twitter.com/kazuho/status/858425590738599936
(defun mickeyconv (n)
(format nil "~:D" n))
(mickeyconv 1234567890) ;=> "1,234,567,890"
; ネタです
@KeenS
KeenS / cmd.txt
Last active December 31, 2016 11:33
$ rustup run nightly rustc -O --test suffix_array.rs
$ ./suffix_array.rs --bench
running 8 tests
test tests::test_make_suffix_array_gfx ... ignored
test tests::test_make_suffix_array_keen ... ignored
test tests::test_make_suffix_array_keen2 ... ignored
test tests::test_make_suffix_array_keen_unsafe ... ignored
test tests::bench_make_suffix_array_gfx ... bench: 481,257 ns/iter (+/- 13,803)
test tests::bench_make_suffix_array_keen ... bench: 165,853 ns/iter (+/- 15,270)
@KeenS
KeenS / dll.smi
Last active December 9, 2016 02:50
_require "basis.smi"
_require "ffi.smi"
functor ReadLine_(X: sig val name: string end) = struct
val readline: string -> string
end
// a parameterized monad
mod idx {
use std::marker::PhantomData;
#[derive(Debug)]
pub struct Idx<X, Y, A>
{
x: A,
pre: PhantomData<X>,
#![feature(trace_macros)]
macro_rules! add {
($e1: expr, $e2: expr) => {
$e1 + $e2
};
}
fn main() {
(defun read-file-into-string (file &key (buf-size 2048))
(with-output-to-string (s)
(with-open-file (f file)
(let ((buf (make-array 2048 :element-type 'base-char)))
(loop
:for size := (read-sequence buf f)
:while (= size buf-size)
:do (write-sequence buf s)
:finally
(write-sequence buf s :end size))))))
theory ToyList
imports Main
begin
no_notation Nil ("[]") and Cons (infixr "#" 65) and append (infixr "@" 65)
hide_type list
hide_const rev
datatype 'a list = Nil ("[]")
| Cons 'a "'a list" (infixr "#" 65)