関数型プログラミング言語 Haskell について語るスレです。
Haskell Language(公式サイト)
https://www.haskell.org/
日本Haskellユーザーグループ - Haskell-jp
https://haskell.jp/
前スレ
関数型プログラミング言語Haskell Part32
https://mevius.5ch.net/test/read.cgi/tech/1548720347/
関数型プログラミング言語Haskell Part33
■ このスレッドは過去ログ倉庫に格納されています
1デフォルトの名無しさん
2020/02/10(月) 18:17:36.49ID:L6eYQqyh563デフォルトの名無しさん
2020/11/09(月) 19:55:38.03 rootsInternal :: Quadratic -> Double -> Roots
rootsInternal q d
= let
two_a = 2.0 * (a q)
realpart = - (b q) / two_a
dside d = (sqrt d) / two_a
dpart = dside d
complexpart = dside (-d)
in if d==0
then -- Discriminant is zero, (single) root is real
Root $ realpart :+ 0
else
if d<0
then -- Discriminant is negative, roots are complex
Roots (realpart :+ complexpart) (realpart :+ (-complexpart))
else -- Discriminant is positive, all roots are real
Roots ((realpart + dpart) :+ 0) ((realpart - dpart) :+ 0)
のlet 〜 in みたいなのを
rootsInternal q d
| d==0 = ...
| d<0 = ...
| otherwise = ...
みたいな書き方の時にもやりたいんです
rootsInternal q d
= let
two_a = 2.0 * (a q)
realpart = - (b q) / two_a
dside d = (sqrt d) / two_a
dpart = dside d
complexpart = dside (-d)
in if d==0
then -- Discriminant is zero, (single) root is real
Root $ realpart :+ 0
else
if d<0
then -- Discriminant is negative, roots are complex
Roots (realpart :+ complexpart) (realpart :+ (-complexpart))
else -- Discriminant is positive, all roots are real
Roots ((realpart + dpart) :+ 0) ((realpart - dpart) :+ 0)
のlet 〜 in みたいなのを
rootsInternal q d
| d==0 = ...
| d<0 = ...
| otherwise = ...
みたいな書き方の時にもやりたいんです
564デフォルトの名無しさん
2020/11/09(月) 19:58:42.43 おっと無用な改行が一々入っちゃった。。。
■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 【サッカー】U-17日本代表、激闘PK戦制す 北朝鮮撃破で6大会ぶり8強入り U17W杯 [久太郎★]
- 日本行き空路49万件キャンセル 中国自粛呼びかけ 日本行きチケット予約の約32%に相当 ★3 [ぐれ★]
- 【芸能】日中関係悪化でエンタメ業界に大ダメージ… JO1の中国でのイベント中止、邦画は公開延期、STARTOアイドルへの影響も [冬月記者★]
- XやChatGPTで広範囲の通信障害 投稿や閲覧できず [蚤の市★]
- 現役猟師・東出昌大、クマ被害続出も過熱する報道に「クマはそんな危ないもんじゃない」理由語る [muffin★]
- 【インバウンド】中国人観光客の日本での消費額は年間約2兆円超…中国政府は公務員の出張取り消し [1ゲットロボ★]
