いろんな言語で宿題スレ 第三編at TECH
いろんな言語で宿題スレ 第三編 - 暇つぶし2ch741:デフォルトの名無しさん
10/02/19 23:11:30
>>729
// F#

open System.Text.RegularExpressions

let paternal last =
    use client = new System.Net.WebClient()
    let rec paternal' url =
        seq {
            let page = "URLリンク(www.jbis.or.jp)" + url + "pedigree/" |> client.DownloadString
            let firstRow = Regex.Match(page, @"<tr>(.+?)</tr>", RegexOptions.Singleline).Groups.[1].Value
            let horses = Regex.Matches(firstRow, @"<(?:td|th).*?><a href=""(.+?)"">(.+?)</a>")
                        |> Seq.cast<Match> |> Seq.map (fun m -> (m.Groups.[1].Value, m.Groups.[2].Value))
                        |> Seq.cache
            yield! Seq.map snd horses
            yield! Seq.nth (Seq.length horses - 1) horses |> fst |> paternal' }
    let horses = paternal' "/horse/0000742976/" |> Seq.cache
    Seq.take (Seq.findIndex ((=) last) horses + 1) horses

paternal "Eclipse" |> Seq.iter (printfn "%s")


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch