首页 \ 问答 \ 懒惰的评估实施(Lazy Evaluation implementation)

懒惰的评估实施(Lazy Evaluation implementation)

我有一个函数fromRange ,它接受一个过滤器函数和一个时间间隔,并返回一个满足过滤器函数的区间中所有元素的集合。

我使用列表理解来实现它:

fromRange   :: (Integer->Bool) -> (Integer,Integer)  -> [Integer]
fromRange f (x,y) = [i | i<-[x..y], f i]

但是它需要很长的时间,所以我找到了懒惰的评估概念,但我不知道如何实现它,任何帮助?


I have a function fromRange which takes a filter function and an interval and returns a set with all elements in the interval that satisfy the filter function.

I implemented it using list comprehension:

fromRange   :: (Integer->Bool) -> (Integer,Integer)  -> [Integer]
fromRange f (x,y) = [i | i<-[x..y], f i]

but it takes very long time with big list so I found the lazy evaluation concept but I do not know how exactly to implement it, any help??


原文:https://stackoverflow.com/questions/13476336
更新时间:2022-03-10 18:03

最满意答案

该程序正在通过任务计划程序执行。 失败的实例在最小的priveliges下运行。

我认为一个具有合理描述的SecurityException会更有意义,但是一旦将计划任务配置为作为更加有用的进程运行,问题就会消失。


The program was being executed via Task Scheduler. The instances that failed were running under minimum priveliges.

I reckon a SecurityException with a sensible description would have made more sense, but once the scheduled task was configured to run as a more priveliged process, the problem disappeared.

相关问答

更多
  • 所以,我认为我“有点 - 有点”想出了我自己的问题。 我仍然不是百分之百确定是什么原因引起了它,但是我会把它留给其他任何一天遇到同样问题的人: 当你收到这个错误时,不要像我一样绝望,因为VBE窗口没有突出显示为问题区域的代码。 查看每个对象/模块/表中的所有VBA代码; 在我的情况下,我最终发现一个功能突出显示为问题的原因。 我能够通过关闭自动计算暂时绕过错误,并且我注释掉了有问题的功能。 它破坏了我的工作簿中的一些东西,但它让我有机会在Visual Studio中调试我的VB.net代码,当我在这样做之后 ...
  • 好的,所以我遇到了这个问题并修复了它。 我知道这是一个很老的线程,但我会回答它,以防其他人遇到这个问题。 这是我如何做到的。 问题似乎是设置为DestinationItem的组需要在其中包含项目。 在该组为空的情况下,这会产生问题。 当组位于其他填充组之间时, 不会发生此问题,因为它的长度为0,因此无法定位。 当它在结尾时(或者可能是开始时,还没有尝试过),这就产生了一个问题,因为当鼠标经过视图的末尾时, GridView / ListView 以列表中的最后一个为目标 。 那么,如何解决它: 您需要为On ...
  • 问题没有解决,但我发现了MapControl的一个错误。 使用案例: 创建一个面向Windows 10的UWP应用。 在MainPage里面放一个MapControl 在Windows Phone上启动应用程序 点按地图 繁荣。 Protip:在MainPage中放置一个控件(如Button)。 然后,如果你关注这个控件,那么你点击地图,没关系。 如果在没有其他控制之前点击地图,则会出现问题。 编辑:Windows 10 build 10565解决了问题。 Problem not solved, but I ...
  • 该程序正在通过任务计划程序执行。 失败的实例在最小的priveliges下运行。 我认为一个具有合理描述的SecurityException会更有意义,但是一旦将计划任务配置为作为更加有用的进程运行,问题就会消失。 The program was being executed via Task Scheduler. The instances that failed were running under minimum priveliges. I reckon a SecurityException wit ...
  • 我只是重新安装了VS 2013 RC,错误已修复。 I simply reinstalled VS 2013 RC, and the error was fixed.
  • 如果未处理的异常转义了类的safecall方法,则调用TObject.SafeCallException()将异常转换为HRESULT错误代码,然后由COM将其返回给调用者。 默认情况下, TObject.SafeCallException()始终返回E_UNEXPECTED ( $8000FFFF )。 类可以重写SafeCallException()以返回更有意义的HRESULT 。 TComObject , TComObject和TAutoIntfObject完全相同(它们也调用SetErrorInf ...
  • 我已经想出如何解决这个问题,并且我会在将来发布具有相同问题的任何人发布我的解决方案。 system()命令在%windir%\ SysWoW64 \中运行32位可执行文件,而不是本机64位版本。 要解决这个问题,我必须使用以下内容: PVOID OldValue = NULL; if( Wow64DisableWow64FsRedirection(&OldValue) ) { // Anything in this block uses the system native files and n ...
  • 我认为您正在崩溃,因为您重建图像的字节数组是ARGB值的“原始”数组,而Source属性期望构成有效PNG或JPG文件的字节流。 原始ARGB数据极不可能是有效的PNG或JPG文件,因为它几乎肯定不包含每种格式所需的有效标头。 我无法重现崩溃; 相反,我运行代码时创建的BitmapImage的PixelWidth和PixelHeight都为零。 这可能是因为我正在使用与您正在使用的图像不同的图像。 无论哪种方式,崩溃或没有崩溃,这是不希望的行为。 如果要将修改后的数据加载回Image ,则无需创建byte数 ...
  • 完成Outlook Mailitem后关闭它然后释放它 For Each item As Outlook.MailItem In oFolder.Items ' 'Close the item 'SaveMode Values 'olDiscard = 1 'olPromptForSave = 2 'olSave = 0 item.Close(1) 'Release item Marshal.ReleaseCom ...
  • 这是一个IDE错误。 有很多。 你可以做的不是很多。 这可能是Delphi或插件的问题。 您正在运行XE,XE将不再有更新。 你可以试试Andy Hausladen的IDE FixPack。 这可能有所帮助。 您或许可以看看是否可以隔离故障的再现,然后找到一种方法来解决它。 It's an IDE bug. There are plenty of them. There's not very much that you can do about it. And it could be a problem e ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)