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

World: r3wp

[Rebol School] Rebol School

Claude
19-Feb-2009
[2307x5]
it is just a simple example of a create refresh update delete of 
a pretty db rebdb with rebgui
i would like to optimize this with rebdb and rebgui
like we can have example with java
with entity and "percistence"  i would like to have a java EE5  but 
in rebol or better in R3
I would like to see proposals from the community to improve this 
point in R2 and rebdb, rebgui at first.
and later in R3!
kib2
23-Feb-2009
[2312]
Hi. Is there a build-in function do do something like this : given 
the number 5 and the string "abc"  construct the string "abcabcabcabcabc" 
(equal 5 times "abc")?
Henrik
23-Feb-2009
[2313x2]
I think the closest is to-string reduce array/initial 5 "abc"
to-string reduce
 is faster than rejoin
kib2
23-Feb-2009
[2315]
Henrik: thanks you!
Henrik
23-Feb-2009
[2316]
I see that reduce is not even necessary.
Geomol
23-Feb-2009
[2317]
And if you're really concerned about speed, this is a little faster:

to string! array/initial 5 "abc"
kib2
23-Feb-2009
[2318]
Ok, but I found it strange that there's no build-in function to do 
that.
Geomol
23-Feb-2009
[2319x3]
Well, array just give a block. Maybe you didn't want a string but 
an issue:
>> to issue! array/initial 5 "abc"
== #abcabcabcabcabc

or something else. Strings are just one form of series.
So we use to-<some datatype> to get, what we want.
This looks funny:
>> to email! array/initial 5 "abc"
== [abc-:-abc-:-abc-:-abc-:-abc]
kib2
23-Feb-2009
[2322x2]
oh : really cool !
Geomol: have you finished your work on LaTeX backend ?
Geomol
23-Feb-2009
[2324]
Almost. Some other work came in the way. I believe, I'll get something 
released this week.
kib2
23-Feb-2009
[2325]
Have you got a look at the XeLaTeX output ?
Geomol
23-Feb-2009
[2326]
Yes, and it looks nice. I have someting to think about. On one side 
keep it as simple as possible, on the other side, it should look 
nice.
kib2
23-Feb-2009
[2327]
Ok; like REBOL
Geomol
23-Feb-2009
[2328x2]
A motto I like very much and think about daily:
Everything should be made as simple as possible, but not simpler.
- A. Einstein
And my own:
It's more important to get it right than to get it fast.
:-)
kib2
23-Feb-2009
[2330]
For sure !
Henrik
23-Feb-2009
[2331]
even when the customers are pounding you for fixes... :-)
BrianH
23-Feb-2009
[2332]
Kib2, try this:
>> head insert/dup copy "" "abc" 5
== "abcabcabcabcabc"
Gregg
23-Feb-2009
[2333]
And then just wrap it up:

    string-of: func [
        "Returns a string of <value> repeated <count> times."
        count [integer!]
        value [word! char! any-string!]
    ][
        head insert/dup copy "" value count
    ]
kib2
23-Feb-2009
[2334x2]
BrianH and Gregg : thanks, I need to write all these tips on a page 
now.
as I've just finished implementing nested list in my markup engine.
Geomol
23-Feb-2009
[2336]
Still having fun with REBOL, kib? Watch it! You're caught in the 
web now. ;-)
kib2
23-Feb-2009
[2337x2]
Geomol: more than ever. But I'm rather fed up now working on this 
markup engine. I need fresh air.

I was thinking of a game, and in fact I've found one, but I think 
I need your help. Beware : that's not easy !
See http://www.indigopuzzles.com/ipuz/help.action?helpId=hashi/index
Geomol
23-Feb-2009
[2339x2]
:-) We have a game group. You could start posting there and see, 
what will happen.
games
kib2
23-Feb-2009
[2341]
Thanks Geomol. I think I have to study game programming before!
kib2
24-Feb-2009
[2342x2]
How could I generate a random number (a real number) between 2 given 
values, ie between -pi and pi ?
random pi gives me an integer
Henrik
24-Feb-2009
[2344]
interesting
Geomol
24-Feb-2009
[2345]
I can think of a way to do it, but it isn't easy. I have a feeling, 
REBOL has a problem with random decimals.
Henrik
24-Feb-2009
[2346]
I've posted this issue on rebdev. R3 rounds decimals as well.
Geomol
24-Feb-2009
[2347x6]
You can build a hex value from an integer with TO-HEX.
And you can put that hex value into a decimal using struct!
So something like:

>> d: make struct! [v [float]] none
>> i: to integer! (random 2 ** 32) - (2 ** 31) - 1
== -198913422
>> h: to-hex i
== #F424D272
>> change third d h
>> d/v
== 11532.55078125
To get the result between some values, you have to use a factor somewhere.
hm, I'm not sure, this is right. The length of third d is 8. It should 
be 4, I guess.
Yeah, the change line should read:

change third d debase/base h 16

I said, it wasn't easy. ;-P
I'm wondering, if this has come up before? I didn't find a random 
decimal function in the library (rebol.org). Some of the math guys 
here may have a better way?
Henrik
24-Feb-2009
[2353]
how about randoming a big integer and divide by that integer and 
multiply with your desired max-value?
Geomol
24-Feb-2009
[2354]
Yes, that's an easy way, but I'm afraid rounding will lead to the 
result not being very random (or a limit in possible outcome). It 
has to be checked at least.
Anton
24-Feb-2009
[2355]
Rebol decimal! is 8 bytes and integer! is only 4 bytes. So you would 
need to make a struct of 2 integer!, then swap its contents with 
a struct of 1 decimal!
Geomol
24-Feb-2009
[2356]
I used float up there, which is 32 bit afaik. What do I write to 
make a 64 bit decimal struct?