Help us understand the problem. What is going on with this article?

HaskellでCを計算するプログラムをF#に置き換える

前回投稿したHaskellプログラムをF#に置き換えてみました

前回の投稿記事はこれです。
Haskellでリストを使って、コンビネーション(C)の計算プログラムを作って遊ぶ

このHaskellのプログラムを、F#に置き換えてみました。

Program.fs
let c (m,n) = let denom = if m <= 0 || n <= 0 || m < n then [1;1]
                            else match m with
                                    |1 -> [1;1]
                                    |x -> [x-n+1..x]
              let nume = if n <= 0 || m < n then [1;1]
                            else match n with
                                    |1 -> [1;1]
                                    |x -> [1..x]

              (List.reduce (*) denom) / (List.reduce (*) nume)

[<EntryPoint>]
let main argv =

    let conbi = [(10,9);(9,9);(8,3);(7,-2);(1,3)]
    for n in conbi do
        printfn "%d" (c n)

    0

実行結果は

10
1
56
1
1

Haskellでは、リストは

[0,1,2,3,4,5]

と、カンマで区切りますが
F#では

[0;1;2;3;4;5]

と、セミコロンで区切ります。

あと、Haskellのprintは、リストをそのまま表示してくれますが、F#は、できませんでした。(方法はあるかどうか分かりません)
なのでfor文でそれぞれの要素を1つ1つ表示させています。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした