aboutsummaryrefslogtreecommitdiff
path: root/lib/math.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-01-31 15:31:06 -0800
committerBruce Hill <bitbucket@bruce-hill.com>2018-01-31 15:31:13 -0800
commita387fd86a870bd1a34f206ec89c32d9d5c4d1c77 (patch)
treeaedb8d409cabefb1680f581067ea3000f8085189 /lib/math.nom
parentb1406a3203901392b98df431157e04f9a9164ff2 (diff)
Added colons for aesthetics.
Diffstat (limited to 'lib/math.nom')
-rw-r--r--lib/math.nom16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/math.nom b/lib/math.nom
index 13c6cc3..70e7de4 100644
--- a/lib/math.nom
+++ b/lib/math.nom
@@ -34,37 +34,37 @@ compile [log % base %base, log_%base %, log base %base %] to {expr:"math.log(\(%
compile [floor %] to {expr:"math.floor(\(% as lua expr))"}
compile [ceiling %, ceil %] to {expr:"math.ceil(\(% as lua expr))"}
compile [round %, % rounded] to {expr:"math.floor(\(% as lua expr) + .5)"}
-action [%n to the nearest %rounder]
+action [%n to the nearest %rounder]:
=lua "(\%rounder)*math.floor((\%n / \%rounder) + .5)"
# Any/all/none
-compile [all of %items, all %items] to
+compile [all of %items, all %items] to:
unless: (%items' "type") is "List"
return {expr:"utils.all(\(%items as lua expr))"}
%clauses <- []
for all (%items' "value"): lua> "table.insert(\%clauses, \(% as lua expr));"
return {expr:"(\(%clauses joined with " and "))"}
parse [not all of %items, not all %items] as: not (all of %items)
-compile [any of %items, any %items] to
+compile [any of %items, any %items] to:
unless: (%items' "type") is "List"
return {expr:"utils.any(\(%items as lua expr))"}
%clauses <- []
for all (%items' "value"): lua> "table.insert(\%clauses, \(% as lua expr));"
return {expr:"(\(%clauses joined with " or "))"}
parse [none of %items, none %items] as: not (any of %items)
-compile [sum of %items, sum %items] to
+compile [sum of %items, sum %items] to:
unless: (%items' "type") is "List"
return {expr:"utils.sum(\(%items as lua expr))"}
%clauses <- []
for all (%items' "value"): lua> "table.insert(\%clauses, \(% as lua expr));"
return {expr:"(\(%clauses joined with " + "))"}
-compile [product of %items, product %items] to
+compile [product of %items, product %items] to:
unless: (%items' "type") is "List"
return {expr:"utils.product(\(%items as lua expr))"}
%clauses <- []
for all (%items' "value"): lua> "table.insert(\%clauses, \(% as lua expr));"
return {expr:"(\(%clauses joined with " * "))"}
-action [avg of %items, average of %items]
+action [avg of %items, average of %items]:
=lua "(utils.sum(\%items)/#\%items)"
compile [min of %items, smallest of %items, lowest of %items] to {..}
expr:"utils.min(\(%items as lua expr))"
@@ -82,7 +82,7 @@ compile [max of %items by %value_expr] to {..}
end)
# Random functions
-action [seed random with %]
+action [seed random with %]:
lua> ".."
math.randomseed(\%);
for i=1,20 do math.random(); end
@@ -91,5 +91,5 @@ compile [random number, random, rand] to {expr:"math.random()"}
compile [random int %n, random integer %n, randint %n] to {expr:"math.random(\(%n as lua expr))"}
compile [random from %low to %high, random number from %low to %high, rand %low %high] to
"math.random(\(%low as lua expr), \(%high as lua expr))"
-action [random choice from %elements, random choice %elements, random %elements]
+action [random choice from %elements, random choice %elements, random %elements]:
=lua "\%elements[math.random(#\%elements)]"