aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/data/collection/stream.lux
blob: b1ada7c34a35b57414fd7623ef65db8529d9dfda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
(.using
 [library
  [lux (.except list pattern)
   ["$" documentation (.only documentation:)]
   [control
    ["<>" parser
     ["<[0]>" code]]]
   [data
    ["[0]" text (.only \n)
     ["%" format (.only format)]]]
   [macro
    [syntax (.only syntax:)]
    ["[0]" code]
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(documentation: (/.Stream it)
  "An infinite sequence of values.")

(documentation: /.iterations
  "A stateful way of infinitely calculating the values of a stream."
  [(iterations step init)])

(documentation: /.repeated
  "Repeat a value forever."
  [(repeated x)])

(documentation: /.cycle
  "Go over the elements of a list forever."
  [(cycle [start next])])

(documentation: /.item
  ""
  [(item idx stream)])

(documentation: /.only
  "A new stream only with items that satisfy the predicate."
  [(only predicate stream)])

(documentation: /.partition
  (format "Split a stream in two based on a predicate."
          \n "The left side contains all entries for which the predicate is #1."
          \n "The right side contains all entries for which the predicate is #0.")
  [(partition left? xs)])

(documentation: /.pattern
  (format "Allows destructuring of streams in pattern-matching expressions."
          \n "Caveat emptor: Only use it for destructuring, and not for testing values within the streams.")
  [(let [(pattern x y z _tail) (some_stream_func +1 +2 +3)]
     (func x y z))])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Stream
             ..iterations
             ..repeated
             ..cycle
             ..item
             
             ..only
             ..partition
             ..pattern
             ($.default /.head)
             ($.default /.tail)
             ($.default /.functor)
             ($.default /.comonad)
             ($.default /.while)
             ($.default /.until)
             ($.default /.first)
             ($.default /.after)
             ($.default /.split_when)
             ($.default /.split_at)]
            []))