# 《Two Dozen Short Lessons in Haskell》学习（十）- Private Definitions — the where-clause

## 第十章 私有定义----where从句

where从句把数学中的局部定义的概念直接用在编程语言中了。

1 Integral numbers are denoted in Haskell by

a decimal numerals enclosed in quotation marks

b decimal numerals — no quotation marks involved

c decimal numerals with or without quotation marks

d values of type String

2 The Haskell system, when interpreting scripts, represents numbers as

a decimal numerals

b binary numerals

3 Encapsulation

a prevents name clashes

b prevents one software component from messing with the internal details of another

c is one of the most important concepts in software engineering

d all of the above

4 A where-clause in Haskell defines variables that

a will be accessible from all where-clauses

b take the name of the where-clause as a prefix

c cannot be accessed outside the definition containing the clause

d have strange names

5 In Haskell, the beginning and end of a definition is determined by

a begin and end statements

b matched sets of curly braces { }

c indentation

6 The intrinsic function foldr

a is more generally applicable than foldr1

b takes more arguments than foldr1

c can accommodate an empty sequence as its last argument

d all of the above

7 What value does the following command deliver?

HASKELL COMMAND • ct [1, 2, 3, 4]

a 10, by computing 1+(2+(3+(4+0)))

b 4, by computing 1+(1+(1+(1+0)))

c 5, by computing 1+(1+(1+(1+1)))

d nothing — ct is not properly defined

=========================================================

=========================================================

1 b

5678是整数，而"5678”就是字符串，在各种编程语言都是这样。

2 d

3 d

4 c

5 c

6 d

foldr1函数有2个参数，而foldr有3个参数。

foldr函数可以保证在空列表情况时，也可以得到返回值。而foldr1在给空列表时，出报错。

7 b

《Two Dozen Short Lessons in Haskell》学习（一）Hello World

《Two Dozen Short Lessons in Haskell》学习（二）Definitions

《Two Dozen Short Lessons in Haskell》学习（四）List Comprehensions

《Two Dozen Short Lessons in Haskell》学习（五）Function Composition and Currying

《Two Dozen Short Lessons in Haskell》学习（六）Patterns of Computation – Composition, Folding, and Mapping

《Two Dozen Short Lessons in Haskell》学习（七）- Types

《Two Dozen Short Lessons in Haskell》学习（八）- Function Types, Classes, and Polymorphism

《Two Dozen Short Lessons in Haskell》学习（九）- Types of Curried Forms and Higher Order Functions

《Two Dozen Short Lessons in Haskell》学习（十）- Private Definitions — the where-clause

《Two Dozen Short Lessons in Haskell》学习（十一）- Tuples

《Two Dozen Short Lessons in Haskell》学习（十二） 数值相关的类

《Two Dozen Short Lessons in Haskell》学习（十三）迭代及重复的常规模式

《Two Dozen Short Lessons in Haskell》学习（十四）截断序列和惰性求值

《Two Dozen Short Lessons in Haskell》学习（十五）- Encapsulation — modules

《Two Dozen Short Lessons in Haskell》学习（十六）- Definitions with Alternatives

《Two Dozen Short Lessons in Haskell》学习（十七） - 模块库

《Two Dozen Short Lessons in Haskell》学习（十八） - 交互式键盘输入和屏幕输出

《Two Dozen Short Lessons in Haskell》学习（十九) - 文件输入与输出

《Two Dozen Short Lessons in Haskell》学习（二十）- 分数

《Two Dozen Short Lessons in Haskell》学习（二十一）- 在形式参数中使用模式匹配

《Two Dozen Short Lessons in Haskell》学习（二十二）- 递归

《Two Dozen Short Lessons in Haskell》（二十四）代数类型

posted @ 2012-12-08 17:25  申龙斌的程序人生  阅读(760)  评论(0编辑  收藏  举报