0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

「F#きしょ」ってなる瞬間

Last updated at Posted at 2025-05-07

F#を愛用している私ですら「きしょ」ってなります

本編

 私が知っているだけ書きました

// 以下はVS2022で動く、1~10の整数が順番に並んだ配列を表示する

// Array.zeroCreate => Array.mapi
printfn "%A" (Array.zeroCreate 10 |> Array.mapi (fun i _ -> 1 + i))

// Array.init
printfn "%A" (Array.init 10 (fun i -> 1 + i))

// Array.collect
printfn "%A" ([|1..10|] |> Array.collect (fun x -> [|x|]))

// コンピューテーション式 シーケンス
printfn "%A" (seq { for i in 1 .. 10 do yield i } |> Array.ofSeq)

// コンピューテーション式 シーケンス 2
printfn "%A" [|for i in 1 .. 10 do yield i|]

// レンジ構文
printfn "%A" [|1..10|]

// レンジ構文 2
printfn "%A" [|1..1..10|]

出力

[|1; 2; 3; 4; 5; 6; 7; 8; 9; 10|]
[|1; 2; 3; 4; 5; 6; 7; 8; 9; 10|]
[|1; 2; 3; 4; 5; 6; 7; 8; 9; 10|]
[|1; 2; 3; 4; 5; 6; 7; 8; 9; 10|]
[|1; 2; 3; 4; 5; 6; 7; 8; 9; 10|]
[|1; 2; 3; 4; 5; 6; 7; 8; 9; 10|]

 一言言います。「きしょい」

終わりに

 他にもあれば、コメントして教えてください

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?