![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
haskell
wu-kan
<https://wu-kan.cn>
展开
-
函数程序设计实验一:分式
--import Test.QuickCheckmodule MyFraction whereFraction=(Integer,Integer)--分式化简ratreduction::Fraction-&amp;gt;Fractionratreduction(x,y)=(div x g,div y g)where g=gcd x y--加法ratplus::Fraction-&amp;gt;F...原创 2018-10-16 10:49:46 · 278 阅读 · 0 评论 -
函数程序设计实验三:使用Newton-Raphson方式计算平方根
module Newton_Raphson wheresquareroot2 :: Float -> Integer -> Floatsquareroot2 x0 n=squareroot 2 x0 nsquareroot :: Float -> Float -> Integer -> Floatsquareroot r x0 0=x0squareroo...原创 2018-10-23 01:55:08 · 769 阅读 · 1 评论 -
函数程序设计实验二:递归练习
module HW where{-1. 定义求两个非负整数最大公因子的函数:mygcd ::Integer -&gt;Integer -&gt;Integer-}mygcd ::Integer -&gt;Integer -&gt;Integermygcd a 0=amygcd a b=mygcd b (mod a b){-2. 定义阶乘函数fac :: Integer -&...原创 2018-10-16 11:06:22 · 301 阅读 · 0 评论 -
函数程序设计实验四:列表练习(2)
{-称一个三元组(x,y,z)是毕达哥拉斯三元组,如果x*x + y*y == z*z。例如,(3,4,5), (4,3,5), (6,8,10)等。请定义一个函数triads :: Int -> [(Int, Int, Int)] 使得triads n 给出[1 .. n]中的毕达哥拉斯三元组,如 > triads 5 [(3,4,5),(4,3,5)] > tr...原创 2018-11-08 12:23:30 · 492 阅读 · 0 评论 -
函数程序设计实验五:打印购物小票
module HaskellStore whereimport Text.Printftype Items=[Item]type Item=(Name,Amount,Price)type Name=Stringtype Amount=Floattype Price=FloatprintItems::Items->IO()printItems its=putStr(prin...原创 2018-11-08 12:23:43 · 2356 阅读 · 0 评论 -
函数程序设计实验六:字符放大
module MyPicture whereimport Data.Charimport Data.Listimport Text.Printfsayit::String->IO()sayit s=putStr(unlines(say s))getid::Char->Intgetid c= if oc>=97 then (oc-97+10) el...原创 2018-11-08 12:23:58 · 421 阅读 · 0 评论