我的程序中某处有一个无限循环,导致<<loop>>
正常运行时出现异常.使用GHCi,我已经将问题追踪到了thunk
f = Constructor1
(Constructor2 A :
(_t3::[DataType2]))
Run Code Online (Sandbox Code Playgroud)
试图对thunk进行排序seq _t3 ()
导致GHCi挂起,所以如果我理解正确的话,无限循环正在减少到弱头正常形式.有没有办法调查这个thunk,例如,逐步看到试图用来评估它的减少步骤?
正如标题所说,我在GHCi中创建了一个无限循环:
f x = x - 2
g x = if f x < x then g (f x + 2) else x
g 2
Run Code Online (Sandbox Code Playgroud)
通常按Ctrl + C会产生"中断".并返回GHCi提示符.如果我:set -fbreak-on-exception
事先预定,Ctrl + C不会破坏循环,我唯一的办法是从外部杀死程序.
有没有办法使用GHCi进入无限循环?这是一个错误吗?
我可以看到可以编写像map/sortBy/findIndex这样的函数以及其他一些与List相关的函数(至少是那些用整数索引的函数.)这是在标准库中的任何地方完成的,还是我需要滚动我的拥有?
我需要在我的程序中使用一个数组进行就地更新,但是我还想在其中使用一些上面的列表函数.在两者之间来回转换是最好的解决方案吗?
(我一直在看的数组来自Data.Array.IArray.我也很高兴使用任何其他实现此功能的数组库.)
给定的数据帧df
和一个局部变量z
,我想设置列y
的df
为等于z
:
df <- data.frame(x=1:5)
z <- 5
df %>%
mutate(y = z)
Run Code Online (Sandbox Code Playgroud)
但是,如果在中z
已经存在一个名为的列,则此列df
将y
等于该列,而不是等于局部变量的值:
df <- data.frame(x=1:5, z=4)
z <- 5
df %>%
mutate(y = z)
Run Code Online (Sandbox Code Playgroud)
我如何确保将其设置为局部变量,而不管其中的列如何df
?
(我知道我可以重命名/删除有问题的列,但是我正在处理其列在运行时之前未知的数据。)
我遇到了函数无法进行类型检查的情况,除非我明确地在其类型签名的开头添加了forall.
有问题的功能是:
test :: (Typeable a) => a -> a
test x
| typeOf (undefined :: a) == typeOf (undefined :: a) = x
| otherwise = x
Run Code Online (Sandbox Code Playgroud)
GHC对以上内容发出以下警告:
Ambiguous type variable `a0' in the constraint:
(Typeable a0) arising from a use of `typeOf'
Probable fix: add a type signature that fixes these type variable(s)
In the first argument of `(==)', namely `typeOf (undefined :: a)'
In the expression:
typeOf (undefined :: a) == typeOf (undefined :: a)
In a …
Run Code Online (Sandbox Code Playgroud) 在Visual Studio 2010中,我为作为.lib文件提供的外部库编写了C++/CLI托管类包装器,我们将其称为ExternalLibrary.lib..lib作为项目的依赖项包含在内,并且在编译时不会发出警告或错误.
当我尝试通过将它包含为C#项目的依赖项来使用此包装器项目时,我在调试模式下运行时会出现以下错误(项目在没有调试的情况下无法运行):
FileNotFoundException was unhandled
Could not load file or assembly 'WrapperProject.dll' or one of its dependencies.
The specified module could not be found
Run Code Online (Sandbox Code Playgroud)
我验证了WrapperProject.dll位于C#项目的调试文件夹中,因此我决定使用Dependency Walker(http://dependencywalker.com/)检查其依赖项.列表中的第一个依赖项是"ExternalLibrary.dll".我认为这是问题,因为"ExternalLibrary.dll"从未存在过,只有"ExternalLibrary.lib".如何告诉Visual Studio不要求不存在的DLL,而是包含.lib文件?
如果我从链接器路径中删除.lib,它已经抛出错误,所以它正在寻找并找到该文件; 我不确定为什么最终它会在不存在的.dll上添加依赖性.
谢谢