Jump to content
Server Maintenance This Week. ×

ListMatrix ( ListOne ; ListTwo ; separator ; counter1 ; counter2 ; result )


This topic is 6270 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Name & Parameters: [color:red][big] ListMatrix ( ListOne ; ListTwo ; separator ; counter1 ; counter2 ; result ) [/big]

Description: While the FileMaker function "Combinations" predits the amount of combinations from two lists, ListMatrix actually outputs all unique combinations. You can also add a ListOne offset, specify a separator for the values from ListOne and ListTwo, and add a header to the result.

Sample Input:

ListMatrix( "a¶b¶a", "1¶2¶3¶4¶2"; " and "; ""; ""; "Combinations of Alpha and Nums:¶" )

Results:

Combinations of Alpha and Nums:

a and 1

a and 2

a and 3

a and 4

b and 1

b and 2

b and 3

b and 4

Recursive: yes

Formula:

Let( [

numListOne = ValueCount( ListOne );

numListTwo = ValueCount( ListTwo );

counter2 = Case( counter2 < 1; 1; counter2 >= numListTwo; 1; counter2 + 1);

counter1 = Case( counter1 < 1; 1; counter2 = 1; counter1 + 1; counter1 );

result = If( counter1 + counter2 > 2; result & “¶” ) & If( PatternCount( result; ( GetValue( ListOne; counter1 ) & separator & GetValue( ListTwo; counter2 ) ) ) = 0; ( GetValue( ListOne; counter1 ) & separator & GetValue( ListTwo; counter2 ) ) )

];

Case( counter1 >= numListOne and counter2 >= numListTwo; result; ListCombiner( ListOne; ListTwo; separator; counter1; counter2; result ))

) 

Required Functions:

Author(s): gephry

Date: 02/06/07

Credits:

Disclaimer:

FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.

ListMatrix.zip

Edited by Guest
Attachment didn't upload
Link to comment
Share on other sites

Might as well ask this in the meantime:

I tried to program it so that the only parameters you send to it were ListOne, ListTwo, and separator. But, when defining the custom function it said counter1, counter2, and result were invalid parameters. So, I ended up specifying them as parameters, of which I'd prefer not to.

How can I define this function with those last three variables being internal parameters only (so they do not need to be specified when the function is called)?

Link to comment
Share on other sites

Whoops, I lied. I must have modified that script so you couldn't add a header to the result as I show in the example. This version of the script however will let you add a header (no ¶ necessary after the header):

Let( [

numListOne = ValueCount( ListOne );

numListTwo = ValueCount( ListTwo );

counter2 = Case( counter2 < 1; 1; counter2 >= numListTwo; 1; counter2 + 1);

counter1 = Case( counter1 < 1; 1; counter2 = 1; counter1 + 1; counter1 );

result = result & "¶" & If( PatternCount( result; ( GetValue( ListOne; counter1 ) & separator & GetValue( ListTwo; counter2 ) ) ) = 0; ( GetValue( ListOne; counter1 ) & separator & GetValue( ListTwo; counter2 ) ) )

];

Case( counter1 >= numListOne and counter2 >= numListTwo; result; ListMatrix( ListOne; ListTwo; separator; counter1; counter2; result ))

)

Link to comment
Share on other sites

  • 4 weeks later...

Here's an version that lets you use an evaluate statement on the header:

// ListMatrixEval( ListOne; ListTwo; separator; counter1; counter2; result )

Let( [

numListOne = ValueCount( ListOne );

numListTwo = ValueCount( ListTwo );

result = Case(counter2 = "eval"; Evaluate(result); result);

counter2 = Case( counter2 < 1; 1; counter2 >= numListTwo; 1; counter2 + 1);

counter1 = Case( counter1 < 1; 1; counter2 = 1; counter1 + 1; counter1 );

result = result & "¶" &

If(

PatternCount( result; ( GetValue( ListOne; counter1 ) & separator & GetValue( ListTwo; counter2 ) ) ) = 0;

GetValue( ListOne; counter1 ) & separator & GetValue( ListTwo; counter2 )

)

];

Case( counter1 >= numListOne and counter2 >= numListTwo; result;

ListMatrixEval( ListOne; ListTwo; separator; counter1; counter2; result )

))

Link to comment
Share on other sites

This topic is 6270 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.