The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random function
Author Message
WRWR
Journeyman
*

Posts: 212
Likes Given: 30
Likes Received: 1 in 1 posts
Joined: Mar 2012
Reputation: 1



Post: #21
RE: Random function
how to get random number from 1, 2, 6, 7, 13, 19, 22, 24 only, for example?
07-12-2012 06:56 PM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #22
RE: Random function
Hmm you can try this :

[DEFNAME rand_defs]
random_list 1,2,6,7,13,19,22,24

[FUNCTION calc_random ]//This function take as input <def.random_list>
local.result = <R<argv>> // argv holds the total number of random_list, 8 in our case,since argv is 0 based we will have a result from 0 to 8-1
return <argv[<dlocal.result>]>

In theory is correct, i cannot test it right now but i think it's fineShock

Maybe there are already some random functions that use intervals, or it's possible to use weighted random like
local.result = {{1}1{2}1{6}1{7}1{13}1{19}1{22}1{24}1} where 1 is the weight, so we have a chance of 1/8 to get 1 or 2 or 6 etc..
I think this one works too
(This post was last modified: 07-12-2012 08:08 PM by darksun84.)
07-12-2012 07:53 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 3 Guest(s)