??
练习1.17
这道题中有2个需要我们自己先写出来的函数double和halve,当然了,这都非常容易实现:
(define(double x)
(+ x x))
(define(halve x)
(/ x 2))
题目中要求我们设计一个类似于fast-expt的求乘积的过程,并且只用对数的步数。
(define(...
分类:
其他好文 时间:
2015-02-05 20:32:57
阅读次数:
96
1 //设置导航栏颜色2 let mainColor = UIColor(red: 0.92, green: 0.25, blue: 0.24, alpha: 1)3 self.navigationController?.navigationBar.barTintColor = mainColor4...
分类:
编程语言 时间:
2015-02-05 18:04:38
阅读次数:
169
??
以下是第一个加起两个正整数的方法,其中inc将参数加1,dec将参数减1。
(define (+ a b)
(if(= a 0)
b
(inc (+ (dec a) b))))
用代换模型展示(+ 4 5)如下:
(+ 4 5)
(inc (+ 3 5))
(inc ...
分类:
其他好文 时间:
2015-02-05 13:36:18
阅读次数:
115
一、对象的比较1、eq?这个函数用来比较2个对象的地址,如果相同的话就返回#t。在Scheme中真用#t表示,假则用#f。例如,(eq? str str)返回#t,因为str本身的地址的是一样的,但是"scheme"和"scheme"则被存储在不同的地址中,因此函数返回#f。注意,不要用eq?来比较...
分类:
其他好文 时间:
2015-02-05 13:22:40
阅读次数:
228
Let the Balloon Rise II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 131 Accepted Submission(s): 37
Problem Description
Con...
分类:
其他好文 时间:
2015-02-03 15:01:55
阅读次数:
184
Sumdiv
Time Limit: 1000MS
Memory Limit: 30000K
Total Submissions: 15033
Accepted: 3706
Description
Consider two natural numbers A and B. Let S be the sum of all nat...
分类:
其他好文 时间:
2015-02-02 23:21:21
阅读次数:
307
1,About Text Handling in iOSThe iOS platform gives you many ways to display text in your apps and let users edit that text. It also lets you display f...
分类:
移动开发 时间:
2015-02-02 17:31:08
阅读次数:
217
12.7.2 创建日志记录计算
清单 12.24 首先实现两个辅助函数,用于读写控制台,且两者还会把消息写入日志,所以,它们将括在 log 计算块中。为了显示如何组合非标准计算,我们在第三个函数中,使用了两个函数。在前面的示例中,我们使用 let! 基本操作,在清单 12.24 还引入了 do!。
清单 12.24 使用计算表达式的日志 (F# Interactive)
> le...
分类:
其他好文 时间:
2015-02-02 15:57:48
阅读次数:
264
题意:给定n表示有n个格子,下面每个格子为O的概率是多少。对于一段连续 x 个O的价值就是 x^2 ;求获得的价值的期望是多少。
思路:n^2=n×(n-1)+n,设ai为第i段连续O的长度,∑ai^2 = ∑[ ai+ ai*(ai-1) ] = ∑ ai*(ai-1) + ∑ai = ∑ C(ai, 2)*2 + ∑ai,那么问题可以转
化为求长度大于1的连续段数*2+O的个数的总期望。 ...
分类:
其他好文 时间:
2015-02-02 14:12:38
阅读次数:
88
Description
A numeric sequence of ai is ordered if a1 a2 <
... aN. Let the subsequence of the given numeric sequence (a1, a2,
..., aN) be any sequence (ai1, ai2,
..., aiK), where 1 i1 i2 <
...
分类:
其他好文 时间:
2015-02-02 10:54:35
阅读次数:
145