generated from chaos-lang/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.kaos
188 lines (178 loc) · 3.81 KB
/
test.kaos
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import math
// Mathematical Constants
str title1 = "# Mathematical Constants\n"
print title1
num pi = math.pi()
echo "pi: "
print pi
num e = math.e()
echo "e: "
print e
num golden_ratio = math.golden_ratio()
echo "golden_ratio: "
print golden_ratio
num inf = math.inf()
echo "inf: "
print inf
num nan = math.nan()
echo "nan: "
print nan
// Trigonometric Functions
str title2 = "\n\n# Trigonometric Functions\n"
print title2
echo "cos: "
print math.cos(60)
echo "sin: "
print math.sin(30)
echo "tan: "
print math.tan(45)
echo "acos: "
print math.acos(0.5)
echo "asin: "
print math.asin(0.5)
echo "atan: "
print math.atan(1.0)
echo "atan2: "
print math.atan2(-10.0, 10.0)
// Hyperbolic Functions
str title3 = "\n\n# Hyperbolic Functions\n"
print title3
echo "cosh: "
print math.cosh(0.693147)
echo "sinh: "
print math.sinh(0.693147)
echo "tanh: "
print math.tanh(0.693147)
echo "acosh: "
print math.acosh(3.762196)
echo "asinh: "
print math.asinh(3.626860)
echo "atanh: "
print math.atanh(0.761594)
// Exponential and Logarithmic Functions
str title4 = "\n\n# Exponential and Logarithmic Functions\n"
print title4
echo "exp: "
print math.exp(5)
num dict frexp = math.frexp(8)
echo "frexp mantissa: "
print frexp['mantissa']
echo "frexp exponent: "
print frexp['exponent']
echo "ldexp: "
print math.ldexp(0.95, 4)
echo "ln: "
print math.ln(5.5)
echo "log: "
print math.log(81, 3)
echo "log1p: "
print math.log1p(1.0)
echo "log2: "
print math.log2(1024.0)
echo "log10: "
print math.log10(1000)
num dict modf = math.modf(3.141593)
echo "modf integer: "
print modf['integer']
echo "modf fraction: "
print modf['fraction']
echo "expm1: "
print math.expm1(1.0)
// Power Functions
str title5 = "\n\n# Power Functions\n"
print title5
echo "pow: "
print math.pow(2, 3)
echo "sqrt: "
print math.sqrt(1024)
echo "cbrt: "
print math.cbrt(27)
echo "hypot: "
print math.hypot(3.0, 4.0)
// Error and Gamma Functions
str title6 = "\n\n# Error and Gamma Functions\n"
print title6
echo "erf: "
print math.erf(1.0)
echo "erfc: "
print math.erfc(1.0)
echo "gamma: "
print math.gamma(0.5)
echo "lgamma: "
print math.lgamma(0.5)
// Rounding and Remainder Functions
str title7 = "\n\n# Rounding and Remainder Functions\n"
print title7
echo "ceil: "
print math.ceil(3.8)
echo "ceil: "
print math.ceil(-3.8)
echo "floor: "
print math.floor(5.6)
echo "floor: "
print math.floor(-5.6)
echo "mod: "
print math.mod(23, 4)
echo "fmod: "
print math.fmod(18.5, 4.2)
echo "trunc: "
print math.trunc(3.8)
echo "trunc: "
print math.trunc(-3.8)
echo "round: "
print math.round(3.8)
echo "round: "
print math.round(-3.8)
echo "remainder: "
print math.remainder(18.5, 4.2)
num dict remquo = math.remquo(10.3, 4.5)
echo "remquo remainder: "
print remquo['remainder']
echo "remquo quotient: "
print remquo['quotient']
// Floating-point Manipulation Functions
str title8 = "\n\n# Floating-point manipulation functions\n"
print title8
echo "copysign: "
print math.copysign(-10.0, -1.0)
// Other Functions
str title9 = "\n\n# Other Functions\n"
print title9
echo "abs: "
print math.abs(3.1416)
echo "abs: "
print math.abs(-10.6)
echo "factorial: "
print math.factorial(5)
echo "factorial: "
print math.factorial(-5)
// Boolean Functions
str title10 = "\n\n# Boolean Functions\n"
print title10
echo "is_finite: "
print math.is_finite(0.0)
echo "is_finite: "
print math.is_finite(1.0 / 0.0)
echo "is_inf: "
print math.is_inf(0.0)
echo "is_inf: "
print math.is_inf(1.0 / 0.0)
echo "is_nan: "
print math.is_nan(0.0)
echo "is_nan: "
num nan_example = math.sqrt(-1.0)
print math.is_nan(nan_example)
echo "is_normal: "
print math.is_normal(1.0)
echo "is_normal: "
print math.is_normal(0.0)
echo "is_normal: "
print math.is_normal(1.0 / 0.0)
echo "is_positive: "
print math.is_positive(1.0)
echo "is_positive: "
print math.is_positive(-1.0)
echo "is_negative: "
print math.is_negative(1.0)
echo "is_negative: "
print math.is_negative(-1.0)