いざ、語ろうぞ。
スレタイ超過のため、一部省略。
その他もウェルカム。
前スレ
次世代言語議論スレ[Go Rust Kotlin Scala]第4世代
http://mevius.2ch.net/test/read.cgi/tech/1492631007/
次世代言語議論スレ[Go Rust Scala Haskell]第5世代 [無断転載禁止]©2ch.net
■ このスレッドは過去ログ倉庫に格納されています
2017/06/13(火) 08:54:07.99ID:O1HnBMDk
84デフォルトの名無しさん
2017/06/25(日) 18:17:06.53ID:pYBZiqDJ ライブラリ内部にも似た様なパターンを関数化して無駄に似た様な少し違うコードが少ない様にしてる。
Myfunc.hs自作ライブラリ
module Myfunc where
import Data.List
import Text.Printf
consnum::(Int,String) -> String
consnum (i,xs) = printf "%4d:%s" i xs
fline f = unlines.f.lines
fnumbering f = fline ((map consnum).(zip [1..]).f)
redstr::String -> String
redstr [] = []
redstr w = printf "\ESC[1m\ESC[31m%s\ESC[39m\ESC[0m" w
bluestr::String -> String
bluestr [] = []
bluestr w = printf "\ESC[34m%s\ESC[39m" w
grep w = fline (filter (isInfixOf w))
Myfunc.hs自作ライブラリ
module Myfunc where
import Data.List
import Text.Printf
consnum::(Int,String) -> String
consnum (i,xs) = printf "%4d:%s" i xs
fline f = unlines.f.lines
fnumbering f = fline ((map consnum).(zip [1..]).f)
redstr::String -> String
redstr [] = []
redstr w = printf "\ESC[1m\ESC[31m%s\ESC[39m\ESC[0m" w
bluestr::String -> String
bluestr [] = []
bluestr w = printf "\ESC[34m%s\ESC[39m" w
grep w = fline (filter (isInfixOf w))
85デフォルトの名無しさん
2017/06/25(日) 18:17:18.21ID:pYBZiqDJ replace _ _ [] = []
replace [] _ cs = cs
replace w nw cs | w == xs = nw ++ replace w nw ys
where
(xs,ys) = splitAt (length w) cs
replace w nw (c:cs) = c:replace w nw cs
putfc (f,c) = printf "%s\n%s" f c
writefc (f,c) = writeFile f c
mfptn fs f ofs output = mapM readFile fs >>=
return.(zip ofs).map f >>=
mapM_ output
mfput f fs = mfptn fs f (map bluestr fs) putfc
mfwrite f fs = let tfs = map (++ ".temp") fs in
mfptn fs f tfs writefc >>
mfptn tfs id fs writefc
replace [] _ cs = cs
replace w nw cs | w == xs = nw ++ replace w nw ys
where
(xs,ys) = splitAt (length w) cs
replace w nw (c:cs) = c:replace w nw cs
putfc (f,c) = printf "%s\n%s" f c
writefc (f,c) = writeFile f c
mfptn fs f ofs output = mapM readFile fs >>=
return.(zip ofs).map f >>=
mapM_ output
mfput f fs = mfptn fs f (map bluestr fs) putfc
mfwrite f fs = let tfs = map (++ ".temp") fs in
mfptn fs f tfs writefc >>
mfptn tfs id fs writefc
■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 【地震速報】青森県で震度6強 沿岸部に津波警報 ★6 [ぐれ★]
- 「日の丸にバツ印」掲げた大学生 あいまいな国旗損壊罪に「怖い」 The Mainichi [少考さん★]
- 【音楽】BARBEE BOYS・KONTAが事故で四肢麻痺を公表、新体制で活動は継続 [少考さん★]
- 【野球】野球の未来に危機感「マイナースポーツになる」 宮本慎也氏が開催…学童大会 [尺アジ★]
- 中国「捜索レーダー起動は各国の通常の手法」 火器管制用か回答せず [蚤の市★]
- 【訃報】声優・西村知道さん死去 「SLAM DUNK」安西先生役 9月に体調不良のため一時休業 [少考さん★]
- ぺこーら、地震で同僚が次々配信を止めるなか強行し続けるので悪目立ちするwww [268244553]
- みなみけ三姉妹誰が一番好き?
- 中国「日本のネトウヨを根絶してやるからな」。ネトウヨ、人生が終わる [805596214]
- 【速報】高市早苗、起床 [779938112]
- 自民党怒りのブルーインパルスまだ?
- ひま
