simply scheme 第二章 练习
Exercises
Use the functions program for all these exercises.
2.1 In each line of the following table we’ve left out one piece of information. Fill inthe missing details.
function |
arg 1 |
arg 2 |
result |
word |
now |
here |
nowhere |
sentence |
now |
here |
(now here) |
first |
blackbird |
none |
b |
first |
(blackbird) |
none |
blackbird |
+ |
3 |
4 |
7 |
every |
first |
(thank you girl) |
(hank ou irl) |
member? |
e |
aardvark |
#F |
member? |
the |
(the days) |
#t |
keep |
vowel? |
(i will) |
(i) |
keep |
vowel? |
不会 |
eieio* |
last |
() |
none |
not in domain |
every |
last |
(honey pie) |
(y e) |
keep |
vowel? |
taxman |
aa |
2.2 What is the domain of the vowel? function?
所有的字母
2.3 One of the functions you can use is called appearances. Experiment with it, and then describe fully its domain and range, and what it does. (Make sure to try lots of cases. Hint: Think about its name.)
定义域:单个字母、数字 值域:0,1
2.4 One of the functions you can use is called item. Experiment with it, and then describe fully its domain and range, and what it does.
定义域:正整数,字符串 值域:单个字符 结构返回字符串的第i个字符