perm_fl()perm_fl()

计算 P(n, k)Calculate P(n, k)

函数 perm_fl() 计算 P(n, k),即从 n 个项中按顺序选择 k 个项的排列数。The function perm_fl()calculates P(n, k), the number of permutations for selection of k items out of n, with order. 它基于 Azure 数据资源管理器原生的 gamma() 函数来计算阶乘(请参见 facorial_fl())。It is based on the Azure Data Explorer native gamma() function to calculate factorial, (see facorial_fl()). 如果不按顺序选择 k 个项,请使用 comb_fl()For selection of k items without order, use comb_fl()

备注

此函数是 UDF(用户定义的函数)This function is a UDF (user-defined function). 有关详细信息,请参阅用法For more information, see usage.

语法Syntax

perm_fl(n, k)perm_fl(n, k)

参数Arguments

  • n:总项数。n: Total number of items.
  • k:选择的项数。k: Selected number of items.

使用情况Usage

perm_fl() 是用户定义的函数。perm_fl() is a user-defined function. 可以在查询中嵌入其代码,或将其安装在数据库中。You can either embed its code in your query, or install it in your database. 用法选项有两种:临时使用和永久使用。There are two usage options: ad hoc and persistent usage. 有关示例,请参阅下面的选项卡。See the below tabs for examples.

如果是临时使用,请使用 let 语句嵌入其代码。For ad hoc usage, embed its code using a let statement. 不需要权限。No permission is required.

let perm_fl=(n:int, k:int)
{
    let fact_n = gamma(n+1);
    let fact_nk = gamma(n-k+1);
    tolong(fact_n/fact_nk)
}
;
range n from 3 to 10 step 3
| extend k = n-2
| extend pnk = perm_fl(n, k)
n   k   pnk
3   1   3
6   4   360
9   7   181440