次世代言語議論スレ[Go Rust Scala Haskell]第5世代 [無断転載禁止]©2ch.net
■ このスレッドは過去ログ倉庫に格納されています
いざ、語ろうぞ。
スレタイ超過のため、一部省略。
その他もウェルカム。
前スレ
次世代言語議論スレ[Go Rust Kotlin Scala]第4世代
http://mevius.2ch.net/test/read.cgi/tech/1492631007/ ライブラリ内部にも似た様なパターンを関数化して無駄に似た様な少し違うコードが少ない様にしてる。
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)) 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 ■ このスレッドは過去ログ倉庫に格納されています