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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! Function wave output generation
//!
//! This module provides functionality to generate and output mathematical
//! function wave data. The wave is generated using a sine function over a
//! specified range and output as comma-separated floating-point values.
//!
//! # Examples
//!
//! ```rust,no_run
//! use hx::output_function;
//!
//! // Generate 10 values with 2 decimal places
//! output_function(10, 2);
//! ```
/// Generates and outputs a mathematical function wave to stdout
///
/// Generates a sequence of floating-point values representing a sine wave
/// function. The wave is calculated as `sin((y / len) * π / 2)` for each value
/// `y` from `0` to `len-1`. Values are formatted with the specified number of
/// decimal places and printed as comma-separated values, with newlines inserted
/// every 10 values for readability.
///
/// # Mathematical Formula
///
/// For each index `y` in `0..len`:
/// ```text
/// x = sin((y / len) * π / 2)
/// ```
///
/// This produces a wave that starts at 0.0 and reaches approximately 1.0
/// at the end of the sequence.
///
/// # Output Format
///
/// Values are printed as comma-separated floating-point numbers with the
/// specified precision. A newline is inserted after every 10th value (indices
/// 9, 19, 29, etc.) for better readability. A final newline is printed after
/// all values.
///
/// # Arguments
///
/// * `len` - The number of values to generate (wave length). Must be a positive integer.
/// * `places` - Number of decimal places for formatting the floating-point values
///
/// # Examples
///
/// ```rust,no_run
/// use hx::output_function;
///
/// // Generate 5 values with 2 decimal places
/// // Output: 0.00,0.00,0.31,0.59,0.81,
/// output_function(5, 2);
///
/// // Generate 20 values with 4 decimal places
/// output_function(20, 4);
///
/// // Generate 100 values with 6 decimal places (for high precision)
/// output_function(100, 6);
/// ```
///
/// # Note
///
/// This function writes directly to stdout. To capture the output programmatically,
/// consider redirecting stdout or using a custom writer implementation.