Skip to content

Instantly share code, notes, and snippets.

View TakashiHarada's full-sized avatar

HARADA Takashi TakashiHarada

  • Kochi University of Technology
  • Kami City, Kochi, Japan
View GitHub Profile
@TakashiHarada
TakashiHarada / prm.hs
Last active September 13, 2022 08:18
import Data.List
data Var = Var Int deriving Eq
instance Show Var where
show (Var x) = "v" ++ show x
data Const = Zero | One deriving Eq
instance Show Const where
\documentclass{jlreq}
%% \documentclass{ltjsarticle}
%% \usepackage[haranoaji,deluxe]{luatexja-preset}
%% \usepackage[uplatex,deluxe]{otf}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{ascmac}
\usepackage{amsmath}
\usepackage{amsthm}
(define rember-f
(lambda (test? a l)
(cond
((null? l) (quote ()))
((test? (car l) a) (rember-f test? a (cdr l)))
(else (cons (car l) (rember-f test? a (cdr l)))))))
(rember-f = 5 '(6 2 5 3))
(rember-f eq? 'jelly '(jelly beans are good))
(define eqan?
(lambda (a1 a2)
(cond
((and (number? a1) (number? a2) (= a1 a2)))
((or (number? a1) (number? a2)) #f)
(else (eq? a1 a2)))))
(eqan? 3 5)
(eqan? 3 'hoge)
# http://folk.uio.no/hpl/scripting/doc/gnuplot/Kawano/intro/working.html
# gnuplot < graph.plt
# sed "s/latency/time/g" graph.plt | gnuplot
set term epslatex # color 12
set output "acl_latency.tex"
# set output "acl_time.tex"
set boxwidth 1
# set key at 6.5,7000
n=3
for ((i = 1; i <= 3; ++i))
do
sort -n acl_given_latency${i} | awk '{v[i++]=$1;}END {x=int((i+1)/2); if(x<(i+1)/2) print (v[x-1]+v[x])/2; else print v[x-1];}' >> acl_median_latency0
sort -n acl_hikin_latency${i} | awk '{v[i++]=$1;}END {x=int((i+1)/2); if(x<(i+1)/2) print (v[x-1]+v[x])/2; else print v[x-1];}' >> acl_median_latency1
sort -n acl_takeyama_latency${i} | awk '{v[i++]=$1;}END {x=int((i+1)/2); if(x<(i+1)/2) print (v[x-1]+v[x])/2; else print v[x-1];}' >> acl_median_latency2
sort -n acl_sgm_latency${i} | awk '{v[i++]=$1;}END {x=int((i+1)/2); if(x<(i+1)/2) print (v[x-1]+v[x])/2; else print v[x-1];}' >> acl_median_latency3
sort -n acl_swbp_latency${i} | awk '{v[i++]=$1;}END {x=int((i+1)/2); if(x<(i+1)/2) print (v[x-1]+v[x])/2; else print v[x-1];}' >> acl_median_latency4
sort -n acl_proposed_latency${i} | awk '{v[i++]=$1;}END {x=int((i+1)/2); if(x<(i+1)/2) print (v[x-1]+v[x])/2; else print v[x-1];}' >> acl_median_latency5
#! /bin/bash -
n=5
m=10
# m=1
for (( i = 1; i <= n; i += 1 ))
do
for (( j = 1; j <= m; j +=1 ))
do
## script for experiments
#! /bin/bash -
n=5
m=10
for (( i = 1; i <= n; i += 1))
do
for ((j = 1; j <= m; j += 1))
-- もっと効率の良い実装があるはず...
import Data.Char
main :: IO ()
main = putStrLn "Enter a length of element: "
>> (readLn :: IO Int)
>>= \d -> putStrLn ("graph Lattice" ++ show d ++ " {")
>> putStr "\n graph [\n rankdir = BT\n ]\n\n"
>> putStrLn ((unlines . concatMap piyo . reverse . mkLattice) d ++ "}")
import System.Random.Shuffle
import System.Random
import System.Environment
import Data.List
main :: IO ()
main =
getArgs >>=
\args -> if 3 /= (length args)
then putStrLn "Usage: $ ./mkC1Pmatrix 100 32 randomC1Pmatrix"