aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/data/collection/stream.lux
blob: 4d3e89a52e69fc9dce3654ae17452b1c8153c1d6 (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 {"-" list}
   ["$" documentation {"+" documentation:}]
   [control
    ["<>" parser
     ["<[0]>" code]]]
   [data
    ["[0]" text {"+" \n}
     ["%" format {"+" format}]]]
   [macro
    [syntax {"+" 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)]
            []))