QueueRangeWithPreservedStream.yqls 797 B

12345678910111213141516171819202122232425262728293031
  1. (
  2. (let config (DataSource 'config))
  3. (let res_sink (DataSink 'result))
  4. (let list (AsList
  5. (Uint32 '1)
  6. (Uint32 '1)
  7. (Uint32 '2)
  8. (Uint32 '3)
  9. (Uint32 '5)
  10. (Uint32 '8)
  11. ))
  12. (let base_stream (Iterator list))
  13. (let queue (QueueCreate (ListItemType (TypeOf list)) (Void) (Uint64 '0)))
  14. (let stream (PreserveStream base_stream queue (Uint64 '100500)))
  15. (let update (lambda '(item state) (block '(
  16. (let cumulative_sum (+ item state))
  17. (let queue_content (Collect (QueueRange queue (Uint64 '0) (Uint64 '100500) (DependsOn item))))
  18. (return '('(item cumulative_sum queue_content) cumulative_sum))
  19. ))))
  20. (let result (FoldMap stream (Uint32 '0) update))
  21. (let world (Write! world res_sink (Key) (Collect result) '('('type))))
  22. (let world (Commit! world res_sink))
  23. (return world)
  24. )