Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

I'm looking to build a recursive cf that generates a non repeating value list of positive integers within the upper limit and the quantity of items in the list specified at run time.

for example the user enters 12 into a global field (ceiling) and 5 into a global field (qty). The cf should return a list of 5 random, non repeating, numbers in the range of 1 thru 12..

1, 2, 4, 7, 12 ....good

1, 1, 2, 6, 9 ... no good because of the repeating 1

0, 6, 8, 9 11 .. no good because of the 0

3, 9, 10, 11, 13 ... no good because of the 13

4, 5, 6, .. no good because their are only 3 numbers

-3, 4, 5, 8, 10... no good because of the -3

you get the picture.

I've been trying to wrap my left brain around this for a while now and cant seem to get it.

TIA

Help me Obi Wan.. your my only hope

Posted

Heres a start; YOu can tweak to build a list using List Function and add a third param for qty

http://sixfriedrice.com/wp/creating-random-numbers-in-filemaker-pro/

; ia

Posted

Try:

UniqueSet ( limit ; setSize ) =

Case (

setSize > limit ; "error" ;



Let ( [

item = Int ( Random * limit ) + 1 ;

cache =  List ( item ; Case ( setSize > 1 ; UniqueSet ( limit ; setSize - 1 ) ) )

] ;

Case (

ValueCount ( FilterValues ( cache ; item ) ) > 1 ; UniqueSet ( limit ; setSize ) ;

cache

)

)



)

  • Like 2
Posted (edited)

Try:

UniqueSet ( limit ; setSize ) =

When you give everyone the answer, no one learns anything! .. I know it usually just drags out the entire conversation usually huH!.

Happy Tax days!!!

-i

Edited by Lee Smith
Please don't quote the whole post if you aren't making in line comment.
Posted

When you give everyone the answer, no one learns anything! .. I know it usually just drags out the entire conversation usually huH!.

Happy Tax days!!!

-i

Imoree..

In my case I learned alot from the solution... might take me a while but probably could write a recursive CF of my own... so speak for yourself, not for me : )

This topic is 4605 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.