我应该在Turtle或Foldl包装中使用折痕吗?

编程入门 行业动态 更新时间:2024-10-26 00:31:12
本文介绍了我应该在Turtle或Foldl包装中使用折痕吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在使用Turtle时遇到了一些困难,仅在盯着无法理解的错误消息几分钟后,我才意识到我在使用错误的fold函数.

I'm having some difficulty using Turtle and only after several minutes staring at incomprehensible error messages realized that I was using wrong fold function.

hackage .haskell/package/turtle-1.5.8/docs/Turtle-Shell.html#v:fold hackage.haskell. org/package/foldl-1.4.0/docs/src/Control.Foldl.html#fold

为什么会有名称冲突?我不相信这是巧合,但我无法弄清楚.这些固有的折叠类型不同吗?

Why is there a name collision? I don't believe that's coincidence but I cannot figure it out. Are these inherently different kinds of folds?

具体来说,我想使用最长的修改时间将流文件名折叠为单个名称.

To be concrete, I wanted to fold a stream filenames into single name using maximum of modification time.

推荐答案

(首先,我们在此处讨论的折叠不是文件夹 折叠 中的/Data-Foldable.html#v:foldl-39-"rel =" nofollow noreferrer> foldl'函数,它们来自 foldl 软件包,从概念上讲,它们与Data.Foldable中的foldl'函数有关,是一种通用的概括,但有不同的定义.)

(First of all, the folds we are talking about here are not the foldr foldl foldl' functions from Data.Foldable, they are from the foldl package, which is conceptually related to the foldl' function from the Data.Foldable, as a sort of versatile generalization, but has separate definitions.)

Fold 数据类型表示要对传入的值序列执行的严格的有状态操作.它的Applicative实例使您可以对相同的值序列运行两个操作. Fold具有很好的属性,它们与值的来源无关.

The Fold datatype repesents a strict, stateful operation to perform on an incoming sequence of values. Its Applicative instance lets you run two operations combined on the same sequence of values. Folds have the nice property that they are agnostic about where the values come from.

每种类型的源将具有其自己的功能来提供值.这些功能可能共享名称fold,但这不是问题,因为通常的建议是导入合格的软件包.

Each type of source will have its own function to feed in the values. These functions might share the name fold, but it isn't a problem because the typical recommendation is to import the packages qualified.

折叠函数可提供任何Foldable容器的内容. 折叠 href ="hackage.haskell/package/turtle-1.5.8" rel ="nofollow noreferrer"> turtle 会提供Shell的结果.像管道"之类的流媒体库具有自己的适配器.

The fold function from the foldl package feeds the contents of any Foldable container. The fold from turtle feeds the results of a Shell. Streaming libraries like "pipes" have their own adapters.

更多推荐

我应该在Turtle或Foldl包装中使用折痕吗?

本文发布于:2023-11-27 05:35:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636808.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:折痕   Turtle   Foldl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!