[REBOL] unsubscibe

2000-01-11 Thread 70740 . 503

How do I unsubscribe?



[REBOL] Printing Re:

2000-01-02 Thread 70740 . 503

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



[REBOL] Modified? returns wrong year Re:

2000-01-01 Thread 70740 . 503

Carlos,

Modified? works perfectly on my windows 98 system. 
Do you have the latest versions of REBOL and windows 98?

Jerry



[REBOL] Series essay Re:(8)

1999-12-29 Thread 70740 . 503

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



[REBOL] Series essay Re:(6)

1999-12-28 Thread 70740 . 503

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



[REBOL] Executing system commands from the REBOL console

1999-12-19 Thread 70740 . 503

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
4dos, which does support redirection. The cpp file was compiled using
Borland C++.

Jerry

// command.cpp
#include stdlib.h
#include stdio.h
#include string.h
#include dos.h
void main()
{
   FILE *fp;
   while(5==5)
{
  sleep(2);
  if (fp = fopen("f.bat","rt"))
  {
 system("f.bat  c.txt");
 fclose(fp);
 sleep(2);
 system("erase f.bat");
  }
   }
}

The REBOL function to invoke the system call is:

dos: func [cmd][
write %f.bat cmd
wait 2
print read %c.txt 
exit
]



[REBOL] Newbie seeks help Re:(5)

1999-12-08 Thread 70740 . 503

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 // 256)) + to-integer (n
/ 256) 4 "}"]
]
 byter 8760
== #{3822}


Jerry



[REBOL] RFF: empty? for blocks Re:

1999-12-08 Thread 70740 . 503

Robert,

It seems to me it already does:

 empty? []
== true
 empty? [1 2 3]
== false
 empty? {}
== true
 empty? {  }
== false


Jerry



[REBOL] Math and plotting functions.

1999-12-06 Thread 70740 . 503

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 you have.

Jerry



[REBOL] Objects: Preventing Code Duplication Re:(11)

1999-12-04 Thread 70740 . 503

Is it possible to make a sound (like a beep) from REBOL?



[REBOL] Off topic message

1999-12-04 Thread 70740 . 503

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



[REBOL] Encouraging functional programming Re:(9)

1999-12-01 Thread 70740 . 503

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



[REBOL] Newby needs some strings help Re:

1999-11-30 Thread 70740 . 503

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 and wouldn't be surprised if there is a much better
way to do it.

Jerry

substr: func [s k n /local a]
[
   a: ""
   for i k k + n - 1 1 [a: join a pick s i]
   a
]

keysubstr: func [s k1 k2]
[
   a1: find s k1
   a2: find s k2
   substr a1 1 + length? k1 (length? a1) - (length? a2) - length? k1
]



[REBOL] Newby needs some strings help Re:(3)

1999-11-30 Thread 70740 . 503

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



[REBOL] Encouraging functional programming Re:(2)

1999-11-29 Thread 70740 . 503

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




[REBOL] Encouraging functional programming Re:(3)

1999-11-29 Thread 70740 . 503

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 + i]
   x
]

testr: func [n x]
[
   either n  0 [testr n - 1 x + n] [return x]
]



[REBOL] Encouraging functional programming Re:(8)

1999-11-28 Thread 70740 . 503

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


xeq: func [f v x] [do join v [": " x]  do f]

binsrch: func [f v b e]
[
   if ((xeq f v b) * (xeq f v e))  0
   [print "binsrch: f must have different signs at endpoints"
   return none]
   either (xeq f v b)  0
   [binsrch0 f v b e 50]
   [binsrch0 f v e b 50]
]

binsrch0: function [f v b e n] [x]
[
   x: b + e / 2
   if n = 0 [return x]
   either (xeq f v x)  0
   [binsrch0 f v x e n - 1]
   [binsrch0 f v b x n - 1]
]



[REBOL] Encouraging functional programming Re:(5)

1999-11-27 Thread 70740 . 503

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 i 1000 1 -1 [insert a i]] 1000
0:00:31
 time-block/reps [a: array 1000  for i 1 1000 1 [poke a i i]] 1000
0:00:09
 a
== [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 4...




[REBOL] Encouraging functional programming Re:(6)

1999-11-27 Thread 70740 . 503

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



[REBOL] Encouraging functional programming Re:(7)

1999-11-27 Thread 70740 . 503

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?

Jerry



[REBOL] Encouraging functional programming Re:(8)

1999-11-27 Thread 70740 . 503

Jordan,

I am impressed with your clever function. It seems to take only 10% more
time than my non-recursive version.

Jerry



[REBOL] Encouraging functional programming Re:

1999-11-26 Thread 70740 . 503

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
for i 1 n 1 [z: z * pick x i]
]
 test 9
== 654729075
 test 149
== 3.75327411157192E+306




[REBOL] time function Re:(2)

1999-11-22 Thread 70740 . 503

Russ,

to-integer epoch works on my machine viz:

 x: epoch
== 943272946
 to-integer x
== 943272946
 type? to-integer x
== integer!


Jerry



[REBOL] Round function Re:(3)

1999-11-22 Thread 70740 . 503

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 ** - n)
   ]
   [x: - round - x n]
]



[REBOL] Date and time in American format

1999-11-22 Thread 70740 . 503


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: now/time
   a: t/1
   if a  12 [t: t - 12:00:00 t: join t " PM"]
   if a = 12 [t: join t " PM"]
   if a = 0  [t: t + 12:00:00 t: join t " AM"]
   d: join pick ['Monday 'Tuesday 'Wednesday 'Thursday 'Friday
 'Saturday 'Sunday] now/weekday ","
   m: pick ['January 'February 'March 'April 'May 'June 'July 'August
'September 'October 'November 'December] now/month
   Print [d m join now/day "," join now/year "," t]
   exit
]



[REBOL] almost counter CGI Re:(4)

1999-11-13 Thread 70740 . 503

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: function [][t d m]
[
   t: now/time
   t: fixtime reduce [t/1 t/2 t/3]
   d: join pick ['Monday 'Tuesday 'Wednesday 'Thursday 'Friday
 'Saturday 'Sunday] now/weekday ","
   m: pick ['January 'February 'March 'April 'May 'June 'July 'August
'September 'October 'November 'December] now/month
   Print [d m join now/day "," join now/year "," t]
]


fixtime: function [t][a]
[
   a: t/1
   if and (a  12)(a  0) [return join a [":" t/2 ":" t/3 " AM"]]
   if a  12 [a: a - 12 return join a [":" t/2 ":" t/3 " PM"]]
   if a = 12 [return join 12 [":" t/2 ":" t/3 " PM"]]
   if a = 0 [return join 12 [":" t/2 ":" t/3 " AM"]]
]



[REBOL] Declaring Arrays Re:

1999-10-28 Thread 70740 . 503

Phil,

Try my-array: array j

Jerry



[REBOL] Round function Re:

1999-01-17 Thread 70740 . 503

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 all you are interested in.

Jerry
[EMAIL PROTECTED]