From cd4196d36553530eac385dd909426509fa9aaeec Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 3 Jan 2018 01:04:21 -0800 Subject: Tidying. --- lib/utils.nom | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/utils.nom') 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 -- cgit v1.2.3