标题说明了一切。 foldl1
和foldl'
都推广到Foldable
,而foldl1'
则不是。foldl1' :: (a -> a -> a) -> [a] -> a
。这只是最近的疏忽吗?或者它是一种设计选择?
foldl1'
的类型是
foldl1
我希望它与foldl1 :: Foldable t => (a -> a -> a) -> t a -> a
具有相同的类型:
foldl1'
我还看到// https://mvnrepository.com/artifact/joda-time/joda-time
libraryDependencies += "joda-time" % "joda-time" % "2.9.4"
// https://mvnrepository.com/artifact/org.joda/joda-convert
libraryDependencies += "org.joda" % "joda-convert" % "1.8.1"
导出import org.joda.time.Duration
import org.joda.time.format.DateTimeFormat
val funcTimeDiffernceInSeconds = (startTime: String, endTime: String) => {
//println("starttime is "+startTime+"\nendtime "+endTime)
if (startTime.matches("[\\d]{4}-[\\d]{2}-[\\d]{2}[\\s]{1}[\\d]{2}:[\\d]{2}:[\\d]{2}:[\\d]+") && endTime.matches("[\\d]{4}-[\\d]{2}-[\\d]{2}[\\s]{1}[\\d]{2}:[\\d]{2}:[\\d]{2}:[\\d]+")) {
//val start = new JDateTime(startTime, "yyyy-MM-dd HH:mm:ss:SSS")
val formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss:SSS")
val start = formatter.parseDateTime(startTime)
val end = formatter.parseDateTime(endTime)
new Duration(start, end).getStandardSeconds.toString
}
else
"Invalid"
}
但Data.List
导出funcTimeDiffernceInSeconds("2016-02-21 00:17:43:126", "2016-02-22 00:17:43:126")
res0: String = 86400
。也许这是相关的?