AltME: REBOL3

Messages

Rebolek
Bo, I wrote one some time ago: http://r.mraky.net/flatten.reb

Endo
I wrote as follow;
flatten: func [b [block!] /local r][
    r: make block! length? b
    head any [foreach v b [insert tail r v] r]
]
Endo
Rebolek: Just a small note, in your function "value" word changed in global. And it looks like my version runs twice faster in 300'000 iteration.
Pekr
It depends, how big your block is - you are effectively building a new block, hence consume memory, just as a preparation to make it 'find friendly ...
Endo
"you are effectively building a new block", that part same as Rebolek's function.
For bigger blocks the difference is more:
>> benchmark2/iteration [Endo x] [Rebolek x] 1000  ; x has 10000 items block
Execution time for the #1 job: 0:00:02.438
Execution time for the #2 job: 0:00:08.243
The difference is, Rebolek's version is more general, my version is flattens just one level:
>> endo [ [2 [3 4] [ [ 5 ] 6]]]
== [2 [3 4] [[5] 6]]
>> Rebolek [ [2 [3 4] [ [ 5 ] 6]]]
== [2 3 4 5 6]
I merged them and added /DEEP refinement.
flatten: func [b [block!] /deep /local r value rule] [
    either deep [
        local: make block! length? b
        rule: [
            into [some rule]
        |   set value skip (append local value)
        ]
        parse b [some rule]
        local
    ] [
        r: make block! length? b
        head any [foreach v b [insert tail r v] r]
    ]
]
DocKimbel
Endo, could you benchmark this one?
flatten: func [blk][load form blk]
It's probably fast but wouldn't work well for all datatypes.
Endo
Hi, yes it is faster;
>> benchmark2/iteration [flatten x] [flatten2 x] 1000
Execution time for the #1 job: 0:00:02.969
Execution time for the #2 job: 0:00:01.625  <-- Ladislav's version
But it has some undesired effects like:
>> flatten [ "3 4"  "5 6" ]
== [3 4 5 6]
And fails on non-loadable values:
>> flatten [ " '3 " ]
** Syntax Error: Invalid word-lit -- '3

Bo
So, I'm fighting with 'call and other stuff for a project. I'm trying to launch FLITE which is a TTS engine. It works perfectly fine if I run it from a shell, like follows:
    flite "this is a test"
But if I try to run it from Rebol that was launched in that exact same shell, I get:
    >> call/wait [{flite} {"this is a test"}]
    Home directory not accessible: Permission denied
    audio_open_alsa: failed to set sample rate near 8000. Invalid argument.
Also, if I try:
    call/wait/shell {flite "this is a test"}
same error. Any ideas?
Ashley
call/wait/output {cmd /C "c:\Program Files\flite\flite.exe" "this is a test"}
Oops ... sans the /output refinement
Also, I'm assuming Windows here

Gregg
Some things are unhappy if you don't use /show. A workaround, if you launch them a lot, is to use call/show "" once at the top of your app. This primes things so they work.
Permission wise, have you tried running rebol as admin? In addition to Ashley's trick, try using a fully qualified path to the exe you're launching.
I haven't seen that exact error, so these are just my normal CALL tricks when I have issues.

Gregg
parse "12345" [2 skip -1 skip]
** Script error: value out of range: -1
** Where: parse
** Near: parse "12345" [2 skip -1 skip]
Is it a bug that negative skip values aren't supported?
Bo
Ashley: Thanks for the input, but I'm using Linux.
Gregg: In R3, 'call doesn't have a /show refinement.
Gregg
Ah, right, R3. Are you using the latest from Atronix? I had issues with earlier versions.
Bo
Yes, latest Atronix version.

Arie
Hi, can somebody point me to the latest r3-gui.r3 on the web? I find it very difficult to know what to use these days ;-) Atronix, Saphirion, RT website which is very outdated ...

Last message posted 164 weeks ago.