`
tangtong
  • 浏览: 64277 次
  • 来自: ...
社区版块
存档分类
最新评论

Section 2.1

阅读更多

2.1

{-data Ration x = R Integer Integer
    
instance (Show a) => Show (Ration a) where
    showsPrec _ (R n d)  = shows (n `div` g).showString " % ". shows (d `div` g)
        where g = gcd' n d
    
gcd' a b = if b==0 then a else gcd' b (a `mod` b)

makeRat a = show a
-}
makeRat x y = (x',y')
    where g = gcd x y
          s = signum (x*y)
          x'= s* abs (x `div` g)
          y'= abs (y `div` g)

 2.2

makePoint x y = (x,y)

xPoint (x,_) = x

yPoint (_,y) = y

makeSegment (a,b) (c,d) = ((a,b),(c,d))

startSegment ((a,b),_) = (a,b)

endSegment (_,(c,d)) = (c,d)

midpointSegment ((a,b),(c,d)) = ((a+c)/2 ,(b+d)/2)

printPoint (x,y) = do
    putStrLn $ show (x,y)
 

 2.3

makeSquare (a,b) (c,d) = ((a,b),(c,d))

getCirm ((a,b),(c,d)) = 2*((abs (c-a)) + (abs (d-b)))

getArea ((a,b),(c,d)) = abs (c-a) * abs (d-b)

  2.4~2.5 略

  2.6 不太懂,Church 数

one = \f -> \x -> f x

two = \f -> \x -> f (f x)

plus a b = a.b

  2-7~2-16 基本都是算法问题,不想做 TODO

分享到:
评论

相关推荐

    Python核心编程(英文版)

    Section 2.1. Program Output, the print Statement, and "Hello World!" Section 2.2. Program Input and the raw_input()Built-in Function Section 2.3. Comments Section 2.4. Operators Section 2.5. Variables...

    Programming Windows Presentation Foundation (wpf编程英文文字版)

    Table of Contents | Index ... Preface Who This Book Is For How This Book Is Organized What You Need to Use This Book Conventions Used in This Book ... Section 2.1. Layout Basics

    High Performance Python

    The Theory of Computation, Section 2.1. Introduction, Section 2.2. Problems, Section 2.3. Models of Computation, Chapter 3. Algorithms, Section 3.1. Introduction, Section 3.2. Anatomy of an Algorithm...

    计算机网络(第四版)(英文版+答案)

    Section 2.1. The Theoretical Basis for Data Communication Section 2.2. Guided Transmission Media Section 2.3. Wireless Transmission Section 2.4. Communication Satellites Section 2.5. The ...

    计算机网络英文版(第四版)

    Section 2.1. The Theoretical Basis for Data Communication Section 2.2. Guided Transmission Media Section 2.3. Wireless Transmission Section 2.4. Communication Satellites Section 2.5. The ...

    计算机网络 英文原版版(第四版)

    Section 2.1. The Theoretical Basis for Data Communication Section 2.2. Guided Transmission Media Section 2.3. Wireless Transmission Section 2.4. Communication Satellites Section 2.5. The Public ...

    计算机网络第四版(英文原版)

    Section 2.1. The Theoretical Basis for Data Communication Section 2.2. Guided Transmission Media Section 2.3. Wireless Transmission Section 2.4. Communication Satellites Section 2.5. The ...

    计算机网络_第四版(andrew S. Tanenbaum)

    Section 2.1. The Theoretical Basis for Data Communication Section 2.2. Guided Transmission Media Section 2.3. Wireless Transmission Section 2.4. Communication Satellites Section 2.5. The ...

    网络教程多所重点大学指定教材电子版

    Section 2.1. The Theoretical Basis for Data Communication Section 2.2. Guided Transmission Media Section 2.3. Wireless Transmission Section 2.4. Communication Satellites Section 2.5. The ...

    apache security 安全

    Section 2.1. Installation Section 2.2. Configuration and Hardening Section 2.3. Changing Web Server Identity Section 2.4. Putting Apache in Jail Chapter 3. PHP Section 3.1. Installation ...

    javascript语言精粹(中英文版)

    Section 2.1. Whitespace Section 2.2. Names Section 2.3. Numbers Section 2.4. Strings Section 2.5. Statements Section 2.6. Expressions Section 2.7. Literals Section 2.8. Functions Chapter 3. ...

    Embedded Linux Primer.pdf

    Section 2.1. Embedded or Not? Section 2.2. Anatomy of an Embedded System Section 2.3. Storage Considerations Section 2.4. Embedded Linux Distributions Section 2.5. Chapter Summary Chapter 3. Processor...

    CTIA_标准中文_.pdf

    **2.1 测试分类** 根据测试对象(发射机或接收机)和采用的技术(模拟AMPS、CDMA、TDMA、GSM),CTIA标准对测试程序进行了详细的分类。 **2.2 实验室基本性能测试** 本部分主要关注测试场地的基础性能评估,例如...

    Java Network Programming 3rd Edition By Elliotte Rusty Harold 2004

    Section 2.1. Networks Section 2.2. The Layers of a Network Section 2.3. IP, TCP, and UDP Section 2.4. The Internet Section 2.5. The Client/Server Model Section 2.6. Internet Standards ...

    Web Caching and Replication

    Section 2.1. Addressing Section 2.2. IP Datagram Header Section 2.3. Routing Section 2.4. Multicast Section 2.5. Summary Chapter 3. Transmission Control Protocol Section 3.1. Segment ...

Global site tag (gtag.js) - Google Analytics