product

function product( x, ... ) --> res

Description

Computes the product of x with all the additional value ().

Parameters

x

The first number you want to add to the product.

An variable number of values that will be multiplied with x.

Return Values

res

The calculated product value.

Code

--ZFUNC-product-v1
local function product( x, ... ) --> res
   local res = x
   for _, v in ipairs{ ... } do
      res = res * v
   end
   return res
end

return product

Examples

local t = require( "tapered" )
local product = require( "product" )

t.is( 2250, product( 5, 15, 30 ) )
t.is( 4500, product( 5, 15, 30, 2 ) )

t.done()

Inspired by