How do I unsubscribe?
Eric,
I have a little C program which sends command to DOS in windows 98. I can
print from REBOL with this. If you have any interest let me know. It might
work in other operating systems with minor modifications.
Jerry
Carlos,
Modified? works perfectly on my windows 98 system.
Do you have the latest versions of REBOL and windows 98?
Jerry
Gabriele,
Thanks for your note. I just redid the experiment with a fresh copy of
REBOL. Same result; REBOL says x/1 = x/2 is true but (do x/1) = (do x/2)
is false. It seems we may have slightly different versions of REBOL. I use
windows 98.
Jerry
Gabriele,
I think, using your example, that I have found a bug in REBOL.
block: copy [] repeat i 4 [use [x] [x: i * i append block 'x]]
== [x x x x]
do x/1
== 1
do x/2
== 4
x/1 = x/2
== true
x/1 == x/2
== true
What do you think? Is it a bug?
Jerry
Under windows 98 the following cpp program will execute system commands
from the REBOL console. If the version of dos used supports redirections,
the output, if any, will appear on the console screen. If not, the results
will appear in the dos box from which command.exe has been invoked. I use
Larry,
My face is red. I don't know how I managed to send an incorrect version. Of
course I had checked my results against yours. In any case, the correct
version and its result from the console:
source byter
byter: func [n [integer!]][
do join "#{" [skip to-string to-hex (256 * (n //
Robert,
It seems to me it already does:
empty? []
== true
empty? [1 2 3]
== false
empty? {}
== true
empty? { }
== false
Jerry
Russ,
I sent you via direct email the all my REBOL functions except those which
communicate with dos. If you have REXX you might want them also. I hope you
are right that others might be interested--the more comments and feedback I
get the better. Please don't hesitate to ask me any questions
Is it possible to make a sound (like a beep) from REBOL?
Russell,
Sorry about that. I didn't realize the topic was copied when I sent a
message. I will be more careful in the future.
Jerry
The Fibonnacci series is defined by the recurrence relations
a(n)=a(n-1)+a(n-2)
a(1)=1
a(2)=1
The series resulting is
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 ...
Jerry
JW,
I think the code below does what you want. Here is what it does:
s: "sfsfkppiovranmnsvkey1=8key2=key3=22"
== {sfsfkppiovranmnsvkey1=8key2=key3=22}
keysubstr s "key1=" "key2="
== "8"
keysubstr s "key2=" "key3="
== ""
I'm fairly new to REBOL
Elan,
Thanks for your kind words. I knew that arrays had the property you tell me
now strings have. I will fix up my function.
Jerry
Gisle,
What do you think of the following example? I expect the 10 could be
increased significantly, but I get tired of waiting.
Jerry
tree: array 0 for n 1 10 1 [insert tail tree 1.0 * n]
== []
length? tree
== 10
last tree
== 10
I think the following example shows that in some cases recursion is
undesirable.
Jerry
testnr 1000
== 500500
testr 1 0.0
** Internal Error: Stack overflow.
** Where: either n 0 [testr n - 1 x + n]
testr 1000 0.0
== 500500
testnr: func [n]
[
x: 0.0
for i 1 n 1 [x: x +
Ladislav,
I am impressed by your recursive fib. In fact it inspired me to write a
zero finding routine in a similar manner. If I am not imposing too much,
can you tell me if it is functional programming?
Jerry
x: binsrch "x - exp - x" 'x 0 1
== 0.567143290409784
exp - x
== 0.567143290409784
Erich,
I timed three methods of filling a block with successive integers from `
1 to 1000. The times are for 1000 iterations. It would seem that head
recursion is rather slow.
Jerry,
time-block/reps [a: array 0 for i 1 1000 1 [insert tail a i]] 1000
0:00:11
time-block/reps [a: array 0 for
Jordan,
I calculate the Fibonnacci numbers without recursion using REBOL. For
example
fib 100
== 3.54224848179262E+20
How would you calculate it with recursion?
Jerry
Brent,
I'm confused. You seem to say that
test: func [n /local sum] [sum: 0 for i 1 n 1 [sum: sum + i]]
is not functional since it contains an index. On the other you seem to say
it is functional in that the output depends only on the input without any
side effects.
Where did I go wrong?
Jordan,
I am impressed with your clever function. It seems to take only 10% more
time than my non-recursive version.
Jerry
John,
I don't know what functional code is. However the following example shows
the calculation of the product of successive odd numbers for quite a range.
What kind of code is it?
Jerry
source test
test: func [n /local x z][
x: array 0
for i 1 n 1 [insert x 2 * i + 1]
z: 1
Russ,
to-integer epoch works on my machine viz:
x: epoch
== 943272946
to-integer x
== 943272946
type? to-integer x
== integer!
Jerry
Donald,
Try the script below. It rounds to n digits after the decimal point. n may
even be negative. Use do read %filename to load the script.
Jerry
round: func [x[integer! decimal!] n[integer!]]
[
either x = 0
[
x: (x * (10 ** n)) + 0.5
x: x - (x // 1)
x: x * (10 **
To all
I think some of you might be interested in the following script, which
prints date and time in standard American long format. I would appreciate
comments and suggestions.
Jerry
{ date returns the current date and time in pretty American format}
date: function [][t a d m]
[
t:
To all,
The following program creates pretty date and time in American format. To
use it, enter do read %file, where file is the name of the file in which
the program is stored.
I think the code is quite clear, but if you have any difficulties, I shall
be glad to explain further.
Jerry
date:
Phil,
Try my-array: array j
Jerry
Andrew,
You asked "Any one got any other maths functions?".
I have a great many including such things as roots of polynomials, prime
factors, eigenvalues and eigenvectors of matrices, inverse of matrices etc.
I have started to upload some of them. However, if you would like, I can
email any or
28 matches
Mail list logo