gpt4 book ai didi

list - XQuery 从列表中获取随机文本

转载 作者:行者123 更新时间:2023-12-02 05:48:03 25 4
gpt4 key购买 nike

假设我有一个列表 100 字符串 元素和我想得到这些随机文本字符串中的 50 个 随机退回。

我尝试这样做:

let $list := ("a","b",..."element number 100")
return xdmp:random(100)

此查询返回一个字符串,我想返回 50 个彼此不同的字符串。

最佳答案

最容易通过 xdmp:random() 订购并限制为前 50 个:

(for $x in (1 to 100)
order by xdmp:random()
return $x
)[1 to 50]

关于list - XQuery 从列表中获取随机文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42250103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com