[Implemented] Random

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Yeah, but Basic language is there for what then ? Not do make our program in one line, but it is there to minimize the number of lines... And if we have to rewrite commands like Random...
I don't know for the other language, but a minimize parameter is not what i would say useless.
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

I don't want PB to became a language with 10000 commands, where 80% are variations of other commands...
that way you have to check always the manual for the right one, when a "well constructed" command can do all:

Print (a$)
PrinN (a$)
PrintWithTabs (a$)
PrintWithAnsiOn (a$)
PrintWithAnsiOff (a$)
PrintWithUnicodeOn (a$)
PrintWithUnicodeOff (a$)
PrintFirstTenLetters (a$)
PrintLastTenLetters (a$)
PrintUppercase (a$)
PrintLowercase (a$)
PrintStipSlashes (a$)
PrintNumbersAsArabic (a$)
PrintNumbersAsRoman (a$)
PrintMyName ()
PrintFredsPreferredNumber ()

Do you want this? :wink:
Can you really call this Basic?
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Blade :lol:
Where can we buy this language?

EDIT: I just tried it...

Code: Select all

number.l = PrintFredsPreferredNumber () 
Debug number
It says "69"! Fred!!! :P
Good programmers don't comment their code. It was hard to write, should be hard to read.
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

Errr. I would extend the Random-command to the following:
Random(max) - returns an integer value from [0..max]
Random(min, max) - returns an integer value from [min..max]

RandomF(max, param) - returns a float value from 0..max
RandomF(min, max, param) - returns a float value from min..max
By default (param = 0) the intervall is closed, so it is [0..max] or [min..max]
For RandomF the param does:
#RandomF_LeftOpen => [a,b] -> ]a,b]
#RandomF_RightOpen => [a,b] -> [a,b[
#RandomF_Open = #RandomF_LeftOpen | #RandomF_RightOpen => ]a,b[

Further another optional parameter would be useful:
Random(min, max, *list) where *list is a linked list that contains values that should NOT be returned by Random, though they lay in range [min,max]. Further a parameter for that ONLY values from that list should be returned.
The same functionality should be done with RandomF in all variations.
Further it would be nice to extend this to Arrays, of course, and to combinations of Arrays and Lists, where from one of them the values should be NOT returned, from the other they should.
Of course we could extend this e.g., so that all entries with odd numbers in the overgiven arrays should NOT be returned, and so on.
Some more flags could control the behaviour of ....

[at this place I would like to fade-out my talking smoothly, so that these word disappears slightly...]

But anyway, of course there are endless possibilities, but I would like a command such as:

Random(max)
Random(min, max)

where min and max could become negative values.

RandomF() would be cool, too.

No need for them, but nice.

Just my 42 cents
%1>>1+1*1/1-1!1|1&1<<$1=1
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

RandomF() makes sens.
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

Froggerprogger wrote: Random(max) - returns an integer value from [0..max]
Random(min, max) - returns an integer value from [min..max]
RandomF(max, param) - returns a float value from 0..max
RandomF(min, max, param) - returns a float value from min..max
By default (param = 0) the intervall is closed, so it is [0..max] or [min..max]
For RandomF the param does:
#RandomF_LeftOpen => [a,b] -> ]a,b]
#RandomF_RightOpen => [a,b] -> [a,b[
#RandomF_Open = #RandomF_LeftOpen | #RandomF_RightOpen => ]a,b[
Random(min, max, *list)
Great! Better than my "Print" example! :lol:
...
ehmm...
perhaps you were serious about that? :cry:
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

Blade wrote:...
ehmm...
perhaps you were serious about that? :cry:
Of course! :wink:
%1>>1+1*1/1-1!1|1&1<<$1=1
Post Reply