解答・コメントを送る方法

コメントを送るには2つの方法があります。
  • 匿名でコメントを書く
    ログインせずにコメントを書くことができます。 名前は「匿名」となります。
  • アカウントを作成してコメントを書く
    アカウントを作成すると、記名での投稿ができます。 また、プロフィールページが作成され、 簡単なプロフィールや 統計情報が表示されるようになります。
どちらの場合も投稿後の修正・削除はできないので、 投稿前によくご確認下さい。

投稿ボタンを押す前に以下の文章を確認してください

  • 当サイトへの投稿は クリエイティブ・コモンズ・ライセンス BY(表示)および、その解釈に同意するものとみなされます。各ページには下のようにライセンス表示が行われます。
    Creative Commons License このサイトの内容は、 クリエイティブ・コモンズ・ライセンスの下でライセンスされています。 [詳細]
  • あなたの投稿したコード・コメント・トピックが再利用・添削されることを望まない場合は、投稿をお控えください。
  • 自分が書いていない、ウェブサイトや書籍などからの無断コピーは著作権の侵害です。著作権者の了解を得るか、自分で0から書いてください。
  • 著作権の侵害、名誉毀損、など投稿内容に問題がある場合、削除することがあります。
  • これらのことにあなたはあらかじめ同意したものとみなされます。

Post comment

Post a comment to the following challenge: 固定長データ (Nested Flatten)

As a reply to the following comment: いげ太: うーん。もうちょっとキレイに書けるかと思...(#6097) [show]

[hide]

うーん。もうちょっとキレイに書けるかと思ったけど挫折した。。

あ、このお題、実用的でいいお題だなと思いました!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module Doukaku170 =
struct
  open System
  open System.IO
  
  type sex   = F | M | U
  
  type meal  = { Morning : string;
                 Lunch   : string;
                 Dinner  : string }
  
  type data  = { LastName  : string;
                 FirstName : string;
                 Sex       : sex;
                 Age       : int;
                 Year      : int;
                 Month     : int;
                 MealDays  : (int * meal) list }
  
  let get_datas file =
    let (|Sex|) s = if s = "F" then F else if s = "M" then M else U in
    let step_read n (r:#TextReader) =
      let buffer = Array.zero_create n in
      ignore (r.Read(buffer, 0, n));
      String.trim [' '] (new string(buffer))
    in
    { use r = new StreamReader(File.OpenRead(file)) in
      while not r.EndOfStream do
        yield { LastName  = step_read 12 r;
                FirstName = step_read 12 r;
                Sex       = (match step_read 1 r with Sex x -> x);
                Age       = Int32.Parse(step_read 3 r);
                Year      = Int32.Parse(step_read 4 r);
                Month     = Int32.Parse(step_read 2 r);
                MealDays  = [for _ in 1..31
                             -> (Int32.Parse(step_read 2 r),
                                 { Morning = step_read 500 r;
                                   Lunch   = step_read 500 r;
                                   Dinner  = step_read 500 r })] }
      done }
end;;

let _ =
  let datas = @"C:\test.txt" |> Doukaku170.get_datas |> Seq.to_list in
  printf "%A\n" (List.hd datas);;


コメント本文
形式 [?]
コード
言語

タグ
半角スペースで区切って複数のタグを入力できます。
参考ページタイトル

参考ページURL
利用規約を読んで同意する必要があります。
by guest

Index

Feed

Other

Link

Pathtraq

loading...