aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/math.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/math.lux')
-rw-r--r--stdlib/source/lux/math.lux18
1 files changed, 16 insertions, 2 deletions
diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux
index 110561901..4c7c2e92e 100644
--- a/stdlib/source/lux/math.lux
+++ b/stdlib/source/lux/math.lux
@@ -3,7 +3,7 @@
## If a copy of the MPL was not distributed with this file,
## You can obtain one at http://mozilla.org/MPL/2.0/.
-(;module: {#;doc "Common numerical operations."}
+(;module: {#;doc "Common mathematical constants and functions."}
lux
(lux (control monad)
(data (struct [list "" Fold<List>])
@@ -25,7 +25,10 @@
[pi "getstatic:java.lang.Math:PI"]
)
-(def: #export tau Real 6.28318530717958647692)
+(def: #export tau
+ {#;doc "The same as 2*PI."}
+ Real
+ 6.28318530717958647692)
(do-template [<name> <method>]
[(def: #export (<name> n)
@@ -153,4 +156,15 @@
))
(syntax: #export (infix [expr (infix^ [])])
+ {#;doc (doc "Infix math syntax."
+ (infix [x i.* 10])
+ (infix [[x i.+ y] i.* [x i.- y]])
+ (infix [[x n.< y] and [y n.< z]])
+ (infix [#and x n.< y n.< z])
+ (infix [(n.* +3 +9) gcd +450])
+
+ "The rules for infix syntax are simple."
+ "If you want your binary function to work well with it."
+ "Then take the argument to the right (y) as your first argument,"
+ "and take the argument to the left (x) as your second argument.")}
(wrap (list (infix-to-prefix expr))))