r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Gabriele
2-May-2007
[7753x3]
with BASE being a string with 64 1s and 64 0s, this is a way to get 
64 random bits:
>> debase/base copy/part random/secure base 64 2
== #{2A244E8E385DEB95}
>> debase/base copy/part random/secure base 64 2
== #{FA7E48B23C8453B2}
>> debase/base copy/part random/secure base 64 2
== #{C4953D9C7AD2E832}
>> debase/base copy/part random/secure base 64 2
== #{D4CC627C5EE1B2DC}
>> debase/base copy/part random/secure base 64 2
== #{4E43B4503F6C76D8}
>> debase/base copy/part random/secure base 64 2
== #{5CC4C2F66F425FBF}
>> debase/base copy/part random/secure base 64 2
== #{77A4BC7F4C67A025}
>> debase/base copy/part random/secure base 64 2
== #{96FAA6879A2FE0E2}
>> debase/base copy/part random/secure base 64 2
== #{1B7D4F3C6DE6047A}

now we need someone to check if this can actually produce 2^64 different 
results ;)
Anton
3-May-2007
[7756x2]
Not today. :) Hmm Geomol, what did you need it for ?
(I can't remember the reason, but I expected random decimals to work 
too.)
Geomol
3-May-2007
[7758]
Anton, for an astronomy exercise at university. Actually it's about 
the distribution of galaxies, but the exercise goes like this:


Suppose that in the Sherwood Forest, the average radius of a tree 
is 1 m and the average number of trees per unit area is 0.005 m^-2. 
If Robin Hood shoots an arrow in a random direction, how far, on 
average, will it travel before it strikes a tree?


I'm making a simulation about this problem and need a good random 
generator to place the trees.
Sunanda
3-May-2007
[7759]
For truly random numbers:
http://www.random.org/
Maxim
3-May-2007
[7760x2]
IIRC, you can ask for their service to return a set of random numbers 
generated by the random.org server.  They have very good analysis 
of their numbers to prove their system is very random.
(it uses analog source sampling, radio noise IIRC)
Sunanda
3-May-2007
[7762]
Lots of background info into random, and some code too:

 http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlDPKJ
Anton
3-May-2007
[7763]
Geomol, well, the answer can't be more than 1km!  (I like questions 
like that, though.)
Geomol
4-May-2007
[7764x2]
Thanks guys! :-)
Anton, based on my simulation, I think the answer is below 100 m. 
The distribution of the trees is a Poisson distribution, the space 
between the trees is an Erlang distribution.
Brock
4-May-2007
[7766x4]
something on the trivial side....  I've been trying to get the below 
command to work in a dynamic fashion,
do [write/append %test.txt "This is text"]
I want the /append to either appear or not based on earlier condition 
checking.  However, the mutliple attempts I've made to either compose 
or reduce the necessary block isn't working.
I've tried many combinations, here are some that get the proper block, 
but it doesn't evaluate properly, indicating invalid path...

do compose [(reform[to-path join 'write ["/" 'append]]) %test.txt 
"This is text"]

do reform [to-path join 'write ["/" 'append]] %test.txt "This is 
text"]

do compose [(reform [to-path join 'write ["/" 'append]]) %test.txt 
"sample text"]
Pekr
4-May-2007
[7770]
hmm, I miss your evaluation of your condition here?
Brock
4-May-2007
[7771]
Any pointers would be great
Henrik
4-May-2007
[7772x2]
brock, notice this:

to-path ['write 'append]
sorry, strip the 's
Pekr
4-May-2007
[7774]
why not simply use:


either condition [write/append %test.txt "This is a text"][write 
%test.txt "This is a text"]
Anton
4-May-2007
[7775]
do pick [write write/append] condition %test.txt "This is text"
Henrik
4-May-2007
[7776x2]
do [to-path [write all [append? 'append]] %test.txt "this is a text"]
if append? is a flag, that is
Pekr
4-May-2007
[7778]
Anton - very elegant!
Anton
4-May-2007
[7779x2]
must reduce first
and even then, if the condition is false:
>> to-path reduce ['write all [false 'append]]
== write/none
Brock
4-May-2007
[7781x2]
checking out the options provided, may take a while to respond... 
thanks for the responses
Anton, that is an interesting solution indeed
Anton
4-May-2007
[7783x3]
do to-path compose [write (any [all [true 'append] ()])] %testible.txt 
"test"
I use the empty paren to generate an unset! value. Compose then dissolves 
a false condition to nothing.
Thankfully a path! with only one word ('write) in it still works 
just like a word! ('write) does.
Brock
4-May-2007
[7786]
Anton, the last options seems to auto-detect if the file is created 
and appends if it created, is that true?
Anton
4-May-2007
[7787]
Correct.
Brock
4-May-2007
[7788x3]
your first solution is more along the lines of what I need.   I need 
to be able to control whether I write or append through the condition.
Thanks for your solutions.  I'm going to play around with Pekr's 
contributions to see what he did and better understand where I went 
wrong.  Thanks guys
Pekr, regarding not simply doing this in an either statement.  I 
have this scenario in a couple of locations and wanted a be a little 
more elegant.  I know it wouldn't add alot of space, just was trying 
to be more elegant.
Anton
4-May-2007
[7791]
Hard to achieve elegance here. Different people wrote helper functions 
for this type of thing. DO PICK is good for just one refinement, 
but the second one is better for several refinements (and accompanying 
arguments).
Brock
4-May-2007
[7792x2]
Henrik, your solution is nice as well.  Pekr, I see the err in my 
ways with the to-path command.  That and enclosing the entire command 
in a block made all the difference.
Anton, yes, I am really just trying to minize my overuse of either 
yet still be readable, and memorable for future use.
Anton
4-May-2007
[7794]
http://anton.wildit.net.au/rebol/doc/flag-val-doc.txt
Henrik
4-May-2007
[7795]
This is one of my pet peeves, that optionally using refinements can't 
be simpler than this.
Anton
4-May-2007
[7796]
I think it was decided some function will be built into R3 which 
makes refinement and argument propagation easier.
Gabriele
4-May-2007
[7797]
and that would be APPLY
Henrik
6-May-2007
[7798]
A question: Does anyone know the ratio of mezzanine vs. native functions 
in a standard REBOL/View 1.3.2? I'm trying to use that as a statistical 
argument of how much of REBOL 2 is currently open source. :-)
Sunanda
6-May-2007
[7799]
These two lines get you close to a answer
  help function!
  help native!

May also need to count various things in the system object as available 
source (not quite *open* source)
btiffin
6-May-2007
[7800]
Hi,  I've been pondering electrical circuits.  Should NOT none return 
none?

low voltage NOT should be high, high voltage NOT should go low, but 
a zero voltage NOT should be no volts? No?
Sunanda
6-May-2007
[7801]
REBOL has slightly wonky three-value logic:
(not none) = (not false)
== true
>> none = false
== false
btiffin
6-May-2007
[7802]
Yeah, I was looking at that.  The output wire I have on a NOT circuit 
is always lit.  I
have to test for "no input" along with the 1's and 0's.  :)