假设我有一个功能(它没有任何实际应用,只是学术兴趣,因此编写它的奇怪方式,使用monoids,applicative functors和fixpoint combinators)
f :: Num a => a -> Sum a
f = fix ((<>) <$> Sum <*>)
Run Code Online (Sandbox Code Playgroud)
它可能会出现问题,但我无法确定它是否会在我测试之前完成预期的操作.
如何进行测试和/或调试呢?我的意思是像在可能的情况下在几次迭代之后看到结果take 10 [1..].
我了解一些简单的调试工具ghci一样:break和:step,但步入非终止计算,所以我不能检查任何东西(它甚至有问题的^C话).我想不出如何使用trace从Debug模块中的这一功能无论是.
任何指针将不胜感激.
这是代码,我不太明白,它是如何工作的.谁能告诉,这是一种预期的行为吗?
$ipython
In [1]: 1 in [1] == True
Out[1]: False
In [2]: (1 in [1]) == True
Out[2]: True
In [3]: 1 in ([1] == True)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/dmedvinsky/projects/condo/condo/<ipython console> in <module>()
TypeError: argument of type 'bool' is not iterable
In [4]: from sys import version_info
In [5]: version_info
Out[5]: (2, 6, 4, 'final', 0)
Run Code Online (Sandbox Code Playgroud) 我想删除\u2022,dList但我再次获得相同的列表
dList = [u'\u2022 Slim fit',
u'\u2022 Barrel cuffs with two buttons',
u'\u2022 One button on sleeve placket',
u'\u2022 Turndown collar',
u'Washing Care: ',
u'\u2022 Machine wash low in cold water',
u'\u2022 Medium iron',
u'\u2022 Do not bleach',
u'\u2022 Hang to dry',
u'\u2022 Do not tumble dry',
u'\u2022 Wash separately',
u'Model\'s measurements: Chest 34", Waist 30", Hips 32"',
u'Height: 175cm.',
u'He is wearing a N. Tyler Size 15.5.',
u'Please note: ',
u'Although we do our best …Run Code Online (Sandbox Code Playgroud) 我刚开始学习golang并决定实现一些基本的排序算法(冒泡排序,选择排序和插入排序)来尝试使用包,切片和测试基础设施.
这是实施:
package child_sort
func SortBubble(xs []int) {
for i := range xs {
swapped := false
for j := 1; j < len(xs)-i; j++ {
if xs[j-1] > xs[j] {
xs[j-1], xs[j] = xs[j], xs[j-1]
swapped = true
}
}
if !swapped {
break
}
}
}
func SortSelection(xs []int) {
for i := range xs {
min_i := i
for j := i + 1; j < len(xs); j++ {
if xs[j] < xs[min_i] {
min_i = j …Run Code Online (Sandbox Code Playgroud)