Skip to content

Instantly share code, notes, and snippets.

View tyabu12's full-sized avatar

Tomohito YABU tyabu12

  • Tokyo, Japan
View GitHub Profile
#!/bin/bash
set -ex
cd ~
TMP_DIR=`mktemp -d --suffix=-home`
# すべてのファイルを一時的に退避
sudo mv * .[^\.]* $TMP_DIR
theory Situation
type person = A | B | C
type status = Honest | Liar
function status (person) : status
axiom Honest_is_the_only_one:
(status A = Honest /\ status B = Liar /\ status C = Liar) \/
(status A = Liar /\ status B = Honest /\ status C = Liar) \/
(status A = Liar /\ status B = Liar /\ status C = Honest)
require './vb'
filename = ARGV[0]
File.open(filename, 'rb') do |file|
until file.eof
# ほげほげ
puts "#{tag}\t#{numbers.join(',')}"
end
end
require './vb'
filename = ARGV[0]
File.open(filename, 'r').each_line do |line|
line.chomp! # 末尾の改行を削除
# ほげほげ
print [tag.bytesize, vb.bytesize], tag, vb
end
@tyabu12
tyabu12 / vb.rb
Last active August 24, 2017 09:21
module VB
# 整数nの符号化
# バイト列のバイナリへの変換を忘れないこと!
def self.encode_number(n)
bytes = []
# ほげほげ
bytes # このままだと…
end
CAMLC = ocamlc
CAMLOPT = ocamlopt
CAMLMKLIB = ocamlmklib
EXEC = test testopt
all: round.cma round.cmxa $(EXEC)
round.o: round.c
$(CAMLC) -c $<
x = 1.000000e+00, y = 1.000000e-40, z = -1.000000e-40
round NearestTiesToEven:
x + y = 1.000000000000000000e+00
x + z = 1.000000000000000000e+00
round ToZero:
x + y = 1.000000000000000000e+00
x + z = 9.999999999999998890e-01
round Up:
x + y = 1.000000000000000222e+00
x + z = 1.000000000000000000e+00
let print x y z =
let print_line mode mode_name =
Printf.printf " round %s:\n x + y = %.18e\n x + z = %.18e\n"
mode_name (Round.add mode x y) (Round.add mode x z) in
Printf.printf "x = %e, y = %e, z = %e\n" x y z;
print_line Round.NearestTiesToEven "NearestTiesToEven";
print_line Round.ToZero "ToZero";
print_line Round.Up "Up";
print_line Round.Down "Down";
Printf.printf "\n"
#include <stdio.h>
#include <math.h>
#include <fenv.h>
#include <assert.h>
#include <caml/mlvalues.h>
#include <caml/alloc.h>
static void change_round_mode(int mode) {
switch (mode) {
case NearestTiesToEven:
type round_mode =
| NearestTiesToEven
| ToZero
| Up
| Down
(* | NearestTiesToAway *)
external add: round_mode -> float -> float -> float = "addc"