Kris M Posted April 13, 2012 Share Posted April 13, 2012 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 Link to comment Share on other sites More sharing options...
imoree Posted April 13, 2012 Share Posted April 13, 2012 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 Link to comment Share on other sites More sharing options...
comment Posted April 13, 2012 Share Posted April 13, 2012 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 ) ) ) 2 Link to comment Share on other sites More sharing options...
Kris M Posted April 13, 2012 Author Share Posted April 13, 2012 Solved.. thanks Comment Link to comment Share on other sites More sharing options...
LaRetta Posted April 13, 2012 Share Posted April 13, 2012 EYOUZZA!!! :wink3: Link to comment Share on other sites More sharing options...
imoree Posted April 13, 2012 Share Posted April 13, 2012 (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 April 13, 2012 by Lee Smith Please don't quote the whole post if you aren't making in line comment. Link to comment Share on other sites More sharing options...
bcooney Posted April 13, 2012 Share Posted April 13, 2012 imoree, what? We're here to give answers. Link to comment Share on other sites More sharing options...
Kris M Posted April 13, 2012 Author Share Posted April 13, 2012 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 : ) Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 4408 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 accountSign in
Already have an account? Sign in here.
Sign In Now