Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F# 如何在hedgehog中定义生成特定长度列表的生成器?_F#_Haskell Hedgehog - Fatal编程技术网

F# 如何在hedgehog中定义生成特定长度列表的生成器?

F# 如何在hedgehog中定义生成特定长度列表的生成器?,f#,haskell-hedgehog,F#,Haskell Hedgehog,我尝试在f#hedgehog中创建一个整数列表。该列表应包含10到20个元素,并包含0到5之间的整数 Gen.list (Range.linear 10 20) (Gen.int <| Range.constant 0 5) |> Gen.printSample Gen.list(Range.linear 10 20)(Gen.int Gen.printSample 引发异常: === Outcome === [5; 5; 2; 2; 0; 2; 3; 1; 1; 4] ===

我尝试在f#hedgehog中创建一个整数列表。该列表应包含10到20个元素,并包含0到5之间的整数

Gen.list (Range.linear 10 20) (Gen.int <| Range.constant 0 5) |> Gen.printSample
Gen.list(Range.linear 10 20)(Gen.int Gen.printSample
引发异常:

=== Outcome ===
[5; 5; 2; 2; 0; 2; 3; 1; 1; 4]
=== Shrinks ===
> System.ArgumentException: The index is outside the legal range.
count = 9, distance past the list = 9
Parameter name: count
   at Microsoft.FSharp.Core.DetailedExceptions.invalidArgOutOfRange[?](String arg, Int32 index, String text, Int32 bound) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 57
   at Microsoft.FSharp.Collections.ListModule.loop@474-29[a](Int32 count, Int32 i, FSharpList`1 lst) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\list.fs:line 477
   at Hedgehog.Gen.atLeast[a](Int32 n, FSharpList`1 xs)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.next@193[T](FSharpFunc`2 f, IEnumerator`1 e, FSharpRef`1 started, Unit unitVar0) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 194
   at Microsoft.FSharp.Collections.Internal.IEnumerator.filter@188.System-Collections-IEnumerator-MoveNext() in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 196
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@75.DoMoveNext(b& curr) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 77
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext() in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 64
   at Hedgehog.Gen.PrintSample[a](Gen`1 g)
   at <StartupCode$FSI_0044>.$FSI_0044.main@()
==结果===
[5; 5; 2; 2; 0; 2; 3; 1; 1; 4]
==收缩===
>System.ArgumentException:索引超出了法定范围。
计数=9,超过列表的距离=9
参数名称:count
在F:\workspace\\u work\1\s\src\FSharp\FSharp.Core\local.fs中的Microsoft.FSharp.Core.DetailedExceptions.InvalidArgoOutOfRange[?](字符串参数,Int32索引,字符串文本,Int32绑定)处:第57行
位于Microsoft.FSharp.Collections.ListModule。loop@474-F:\workspace\\u work\1\s\src\fsharp\fsharp.Core\list.fs中的29[a](Int32计数,Int32 i,FSharpList`1 lst):第477行
至少在Hedgehog.Gen.a.(int32n,FSharpList`1xs)
位于Microsoft.FSharp.Collections.Internal.IEnumerator。next@193[T] (FSharpFunc`2 f,IEnumerator`1 e,FSharpRef`1已启动,Unit unitVar0)在f:\workspace\\u work\1\s\src\fsharp\fsharp.Core\seq.fs中:第194行
位于Microsoft.FSharp.Collections.Internal.IEnumerator。filter@188.System-F:\workspace\\u work\1\s\src\fsharp\fsharp.Core\seq.fs中的Collections-IEnumerator-MoveNext():第196行
位于Microsoft.FSharp.Collections.Internal.IEnumerator。map@75.DoMoveNext(b&curr)在F:\workspace\\u work\1\s\src\fsharp\fsharp.Core\seq.fs中:第77行
在F:\workspace\\u work\1\s\src\FSharp\FSharp.Core\seq.fs中的Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()中
在Hedgehog.Gen.PrintSample[a](Gen`1g)
地址:$FSI_0044.main@()
因此,通常情况下,生成器会创建正确的结果,但收缩逻辑会出现问题。这是错误吗?我做错了吗?我是否错过了解释此问题的文档?

此处跟踪问题:此处跟踪问题: