推荐答案转换为小数并查看数字,似乎第21项将超出"最大值:Converting to decimals and looking at the numbers, it seems the 21st item would 'overshoot' max:let dl = 9.5m / 11.mlet min = 21.5m + dllet max = 40.5m - dllet a = [ for z in min .. dl .. max -> z ] // should have 21 elementslet b = a.Lengthlet lastelement = List.nth a 19let onemore = lastelement + dllet overshoot = onemore - max那可能是由于let dl = 9.5m / 11.m中缺乏精度吗?That is probably due to lack of precision in let dl = 9.5m / 11.m?要摆脱这种复合错误,您必须使用另一个数字系统,即Rational. F#Powerpack带有一个BigRational类,可以这样使用:To get rid of this compounding error, you'll have to use another number system, i.e. Rational. F# Powerpack comes with a BigRational class that can be used like so:let dl = 95N / 110Nlet min = 215N / 10N + dllet max = 405N / 10N - dllet a = [ for z in min .. dl .. max -> z ] // Has 21 elementslet b = a.Length 这篇关于在F#中使用float迭代器列出列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-28 08:06