# [math_proportion]

 Link math_proportion Author Jason Huck Category Math Version 8.x License http://opensource.org/licenses/artistic-license.php Posted 16 Jan 2006 Updated 16 Jan 2006 More by this author...

#### Description

This tag accepts 4 values, representing 2 proportional ratios in the order given. ("A is to B as X is to Y.") Three of the given values must be integers, and the fourth must be a string, such as 'x', representing the missing value. The tag determines the value of x with a simple cross-multiply and divide operation.

#### Sample Usage

```math_proportion(12,63,'x',345);

-> 65

```

#### Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

```define_tag(
'proportion',
-namespace='math_',
-priority='replace',
-description='Finds missing value in basic cross-multiply and divide operation.'
);
fail_if(
params->size != 4,
-1,
'[math_proportion] requires 4 values (3 integers and an x).'
);

local('items') = array('a','b','x','y');

iterate(params, local('i'));
local(#items->get(loop_count)) = #i;
#i->isa('string') ? local('missing') = #items->get(loop_count);
/iterate;

select(#missing);
case('a');
local('out') = (#b * #x) / #y;
case('b');
local('out') = (#a * #y) / #x;
case('x');
local('out') = (#a * #y) / #b;
case('y');
local('out') = (#b * #x) / #a;
/select;

return(#out);
/define_tag;
```

#### Related Tags 