我在F#中有一个浮点数序列,我需要获得一个定义为(Math.Log currentElement)/(Math.Log previousElement)
的序列.显然,它将比原始序列短一个元素.
I have a sequence of floats in F#, and I need to get a sequence defined of (Math.Log currentElement)/(Math.Log previousElement)
. Obviously it will be shorter than the original sequence by one element.
在F#中实现这一目标的最优雅的方法是什么?我当时想在内部使用带for循环的seq {}表达式,但是即使那样,以一种相当不错的方式处理第一个元素似乎还是困难的……
What is the most elegant way to achieve this in F#? I was thinking to use a seq{} expression with a for loop inside, but even then handling the first element in a reasonably nice way seems difficult...
items |> Seq.pairwise |> Seq.map (fun (x, y) -> log y / log x)
这篇关于计算F#中序列的后续元素的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程技术网(www.editcode.net)!