[過去ログ]
関数型プログラミング言語Haskell Part33 (1002レス)
関数型プログラミング言語Haskell Part33 http://mevius.5ch.net/test/read.cgi/tech/1581326256/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
446: デフォルトの名無しさん [sage] 2020/08/30(日) 11:24:16.79 ID:uCpf8zkM 質問です 次のプログラムが走りません Ratio Integer型の割算です mainの最後の行を受け付けてくれません import Data.Ratio import Data.Complex (///) (x:+y) (z:+w) = let d = z^2 + w^2 in ((x*z-y*w)/d):+((x*w+y*z)/d) x :: Ratio Integer x = 1%1 y = 3%1 z = 2%1 w = 4%3 main = do print $ (x:+y) /// (z:+w) print $ x / (z^2+w^2) print $ (x:+y) /// ((z:+w) + (x:+y)) http://mevius.5ch.net/test/read.cgi/tech/1581326256/446
447: デフォルトの名無しさん [sage] 2020/08/30(日) 11:24:49.92 ID:uCpf8zkM エラーメッセージは以下です 何がダメかどなたかわかりませんか? Haskell Online Compiler [ghc-8.4.4] Copyright (c) The University of Glasgow Compiling your program... [1 of 1] Compiling Main ( prog.hs, prog.o ) prog.hs:23:25: error: • No instance for (RealFloat (Ratio Integer)) arising from a use of ‘+’ • In the second argument of ‘(///)’, namely ‘((z :+ w) + (x :+ y))’ In the second argument of ‘($)’, namely ‘(x :+ y) /// ((z :+ w) + (x :+ y))’ In a stmt of a 'do' block: print $ (x :+ y) /// ((z :+ w) + (x :+ y)) | 23 | print $ (x:+y) /// ((z:+w) + (x:+y)) | ^^^^^^^^^^^^^^^ http://mevius.5ch.net/test/read.cgi/tech/1581326256/447
448: デフォルトの名無しさん [sage] 2020/08/30(日) 11:27:13.14 ID:uCpf8zkM あ、11行目は in ((x*z-y*w)/d):+((-x*w+y*z)/d) でした でも同じエラーメッセージ出てきます 何故でしょう? http://mevius.5ch.net/test/read.cgi/tech/1581326256/448
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.041s