April 13, 201213 yr 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
April 13, 201213 yr 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
April 13, 201213 yr 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 ) ) )
April 13, 201213 yr 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 April 13, 201213 yr by Lee Smith Please don't quote the whole post if you aren't making in line comment.
April 13, 201213 yr Author 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 : )
Create an account or sign in to comment