Skip to content

Instantly share code, notes, and snippets.

View pasberth's full-sized avatar

pasberth pasberth

View GitHub Profile
@pasberth
pasberth / syllogism
Created January 25, 2014 08:13
三段論法
Theorem syllogism : forall (A B C : Prop), (B -> C) -> (A -> B) -> A -> C.
Proof.
intros A B C H H0 H1.
apply H.
apply H0.
apply H1.
Qed.
@pasberth
pasberth / default.hs
Created January 25, 2014 07:56
default宣言
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.ByteString
default (ByteString)
s = "hello world"
-- :: ByteString
-- デフォルトが ByteSTring になる
@pasberth
pasberth / print_all.cpp
Created January 12, 2014 01:34
すべての要素を出力する
#include <string>
#include <vector>
#include <list>
#include <iostream>
template<class Iterator>
void print_all(Iterator first, Iterator last)
{
while (first != last)
{
@pasberth
pasberth / vtable.cpp
Created January 9, 2014 14:35
進捗です
#include <iostream>
typedef void (*f_t)();
class Base {
public:
virtual void f();
};
struct Derivied : public Base {
@pasberth
pasberth / while.hs
Last active January 2, 2016 11:59
whileを使ったループ
import Data.IORef
doWhile :: Monad m => m Bool -> m a -> m a
doWhile test body = do
x <- body
testResult <- test
if testResult
then doWhile test body
else return x
@pasberth
pasberth / mp.v
Created December 31, 2013 05:27
Modus ponens
Theorem Modus_ponens: forall (P Q: Prop), (P -> Q) -> P -> Q.
Proof.
intro P.
intro Q.
intro H.
apply H.
Qed.
import qualified System.Environment as E
import qualified Data.HashMap.Strict as M
mathematicalScriptMap :: M.HashMap Char Char
mathematicalScriptMap = M.fromList [
('A', '\x1D49C'),
('B', '\x0212C'),
('C', '\x1D49E'),
('D', '\x1D49F'),
('E', '\x02130'),
@pasberth
pasberth / a.rb
Created December 23, 2013 15:43
# ユーザに文字列を入力させ、それが"true"か"真"なら"OK"それ以外なら"NG"と表示させなさい
# -*- coding: utf-8 -*-
s = gets.chomp
if s == "true" || s == "真" then
puts "OK"
else
puts "NG"
end
@pasberth
pasberth / a.rb
Created December 23, 2013 14:42
# メソッド random はtrueかfalseを返す # trueならば"OK"falseならば"NG"と表示させなさい
def random
[true, false].sample
end
if random then
puts "OK"
else
puts "NG"
end
--ちんちんっぽいことするやつ
import System.Random
chimpo :: String -> IO String
randomString :: String -> IO String
chimpo c = do s <- randomString c
if take 4 c == "ABCDE"
then return $ c ++ ("なんか終わりました" ++ (show (length c )))
else chimpo s