[math_proportion]

Description

Link: [math_proportion]
Author: Jason Huck
Category: Math
Version: 8.x
License:
Posted: Jan. 16, 2006
Updated: Jan. 01, 0001
More by this author...
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.

Parameters

none


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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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



Comments

none

Email:


Password:



Newest

Most Popular