List.permute<'T> 函数 (F#)

返回一个列表,其中所有元素都按指定的排序规则重新排序。

命名空间/模块路径: Microsoft.FSharp.Collections.List

程序集:FSharp.Core(在 FSharp.Core.dll 中)

// Signature:
List.permute : (int -> int) -> 'T list -> 'T list

// Usage:
List.permute indexMap list

参数

  • indexMap
    类型:int -> int

    用于将输入索引映射到输出索引的函数。

  • list
    类型:'T list

    输入列表。

返回值

排列后的列表。

备注

此函数在编译的程序集中名为 Permute。 如果从 F# 以外的语言中访问函数,或通过反射访问成员,请使用此名称。

示例

下面的代码演示如何使用 List.permute

let printPermutation n list1 =
    let length = List.length list1
    if (n > 0 && n < length) then
        List.permute (fun index -> (index + n) % length) list1
    else
        list1
    |> printfn "%A"
let list1 = [ 1 .. 5 ]
// There are 5 valid permutations of list1, with n from 0 to 4.
for n in 0 .. 4 do
    printPermutation n list1

Output

  

平台

Windows 8,Windows 7,Windows server 2012中,Windows server 2008 R2

版本信息

F#核心库版本

支持:2.0,4.0,可移植

请参见

参考

Collections.List 模块 (F#)

Microsoft.FSharp.Collections 命名空间 (F#)