[表示 : 全て 最新50 1-99 101- 201- 301- 401- 501- 601- 701- 801- 901- 2ch.scのread.cgiへ]
Update time : 06/09 08:00 / Filesize : 265 KB / Number-of Response : 972
[このスレッドの書き込みを削除する]
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧] [類似スレッド一覧]


↑キャッシュ検索、類似スレ動作を修正しました、ご迷惑をお掛けしました

次世代言語議論スレ[Go Rust Kotlin Scala]第4世代



355 名前:デフォルトの名無しさん [2017/05/11(木) 17:14:36.14 ID:+i4P6kRh.net]
はいはい・・・。
んじゃ、検索で見つけた位置も追加で表示するように拡張。

import System.Environment

search w = search' (False,0,[],(1,0)) w
where
search' (b,n,ps,_) _ [] = (b,n,reverse ps)
search' (b,n,ps,(y,_)) w (c:cs) | c == '\n' = search' (b,n,ps,(y + 1,0)) w cs
search' (_,n,ps,(y,x)) w (c:cs) | take (length w) (c:cs) == w = search' (True,n + 1,(y,x + 1):ps,(y,x + 1)) w cs
search' (b,n,ps,(y,x)) w (_:cs) = search' (b,n,ps,(y, x + 1)) w cs

search2 w = search' (False,0,[],(1,0)) w
where
search' (b,n,ps,_) _ [] = (b,n,reverse ps)
search' (b,n,ps,(y,_)) w (c:cs) | c == '\n' = search' (b,n,ps,(y + 1,0)) w cs
search' (_,n,ps,(y, x)) w cts | take (length w) cts == w = search' (True,n + 1,(y, x + 1):ps,(y, x + 1)) w $ drop (length w) cts
search' (b,n,ps,(y,x)) w (_:cs) = search' (b,n,ps,(y, x + 1)) w cs

-- main = do 7777
-- (file:word:_) <- getArgs
-- content <- readFile file
-- print $ search word content

main = getArgs >>= \(file:word:_) -> readFile file >>= print.search2 word






[ 続きを読む ] / [ 携帯版 ]

全部読む 前100 次100 最新50 [ このスレをブックマーク! 携帯に送る ] 2chのread.cgiへ
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧]( ´∀`)<265KB

read.cgi ver5.27 [feat.BBS2 +1.6] / e.0.2 (02/09/03) / eucaly.net products.
担当:undef