aboutsummaryrefslogtreecommitdiff
path: root/lib/utils.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-01-03 01:04:21 -0800
committerBruce Hill <bitbucket@bruce-hill.com>2018-01-03 01:04:21 -0800
commitcd4196d36553530eac385dd909426509fa9aaeec (patch)
treeb881b2e37d89e25bc1ca0fccee71fa92003d76d5 /lib/utils.nom
parentcfee75b21b307b5d57c215cad5b1c089c91182fc (diff)
Tidying.
Diffstat (limited to 'lib/utils.nom')
-rw-r--r--lib/utils.nom10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/utils.nom b/lib/utils.nom
index 11f0ccf..a67b056 100644
--- a/lib/utils.nom
+++ b/lib/utils.nom
@@ -43,7 +43,7 @@ compile [random int %n, random integer %n, randint %n] to: "math.random(\(%n as
compile [random from %low to %high, random number from %low to %high, rand %low %high] to:
"math.random(\(%low as lua), \(%high as lua))"
rule [random choice from %elements, random choice %elements, random %elements] =:
- =lua "\(%elements)[math.random(#\(%elements))]"
+ =lua "\%elements[math.random(#\%elements)]"
# Math functions
compile [% as number] to: "tonumber(\(% as lua))"
@@ -66,7 +66,7 @@ compile [log % base %base] to: "math.log(\(% as lua), \(%base as lua))"
compile [floor %] to: "math.floor(\(% as lua))"
compile [round %, % rounded] to: "math.floor(\(% as lua) + .5)"
rule [%n rounded to the nearest %rounder] =:
- =lua "(\(%rounder))*math.floor(\(%n)/\(%rounder) + .5)"
+ =lua "(\%rounder)*math.floor((\%n / \%rounder) + .5)"
compile [tau] to: "(2*math.pi)"
compile [pi] to: "math.pi"
compile [e] to: "math.e"
@@ -78,7 +78,7 @@ compile [product of %items, product %items] to: "nomsu.utils.product(\(%items as
compile [all of %items] to: "nomsu.utils.all(\(%items as lua))"
compile [any of %items] to: "nomsu.utils.any(\(%items as lua))"
rule [avg of %items, average of %items] =:
- =lua "(nomsu.utils.sum(\(%items))/#\(%items))"
+ =lua "(nomsu.utils.sum(\%items)/#\%items)"
compile [min of %items, smallest of %items, lowest of %items] to:
"nomsu.utils.min(\(%items as lua))"
compile [max of %items, biggest of %items, largest of %items, highest of %items] to:
@@ -95,8 +95,8 @@ compile [max of %items by %value_expr] to: ".."
end)
compile [sort %items] to: "table.sort(\(%items as lua))"
rule [sort %items by %key] =: =lua ".."
- nomsu.utils.sort(\(%items), function(x)
- return (\(%key))(nomsu, {['']=x});
+ nomsu.utils.sort(\%items, function(x)
+ return (\%key)(nomsu, {['']=x});
end)
# String utilities