修改密码

请输入密码
请输入密码 请输入8-64长度密码 和 email 地址不相同 至少包括数字、大写字母、小写字母、半角符号中的 3 个
请输入密码
提交

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

服务器的MAC地址

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
申请天数
审批时间
过期时间
MAC地址
申请理由
审核信息
关闭
基础信息
  • 用户昵称:
  • 手机号:
  • 公司名称:
  • 公司邮箱:
  • 地区:
  • 语言:
修改密码
申请证书

当前未申请证书.

申请证书
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

ProductName CreateTime ID Price File
ProductName CreateTime ID Price File

No Invoice

搜索
    中文

      reduce()

      概述

      函数reduce()使用列表中的所有元素依次进行某种运算,即先用初始值和第一个元素进行运算,再使用得到的结果和第二个元素进行相同的运算,依此类推直至列表的最后一个元素。

      函数reduce()的迭代方式类似于大部分编程语言中的for循环语句,但迭代次数没有暴露出来。

      参数:reduce(<result> = <init>, <element> in <list> | <expression>)

      • <result>:初始值和每次向后面的元素传递运算结果的变量名
      • <init>:初始值
      • <element>:列表元素变量名
      • <list>:列表的别名
      • <expression>:运算表达式

      返回值:

      • 最终的运算结果

      一般用法

      本例将列表[1,2,3,4]中的数字求和:

      with [1,2,3] as list
      return reduce(sum = 0, element in list | sum + element)
      

      6
      

      示例图集:

      在一个空图集中,依次运行以下各行语句创建示例图集:

      create().node_schema("firm").node_schema("human").edge_schema("hold")
      create().edge_property(@hold, "portion", double)
      insert().into(@firm).nodes([{_id:"F001", _uuid:1}, {_id:"F002", _uuid:2}])
      insert().into(@human).nodes([{_id:"H001", _uuid:3}, {_id:"H002", _uuid:4}])
      insert().into(@hold).edges([{_uuid:1, _from_uuid:3, _to_uuid:1, portion:0.3}, {_uuid:2, _from_uuid:2, _to_uuid:1, portion:0.7}, {_uuid:3, _from_uuid:3, _to_uuid:2, portion:0.4}, {_uuid:4, _from_uuid:4, _to_uuid:2, portion:0.6}])
      

      本例计算公司F001的各个最终受益人的持股份额:

      n({_id == "F001"}).le()[:5].n({@human} as UBO) as p
      with pedges(p) as edgeList
      call{
        with edgeList
        uncollect edgeList as edges
        with collect(edges.portion) as portionList
        return reduce(init = 1, element in portionList | init * element) as share
      }
      group by UBO
      return table(UBO._id, sum(share))
      

      | UBO._id | sum(share) |
      |---------|------------|
      | H001    | 0.58       |
      | H002    | 0.42       |
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写