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

World: r3wp

[!REBOL3]

Geomol
18-Feb-2010
[932x3]
Argh, my flatten function can be much simpler:

flatten: func [block /local result] [
	result: clear []
	forall block [
		append result block/1
	]
	result
]
Yet another version, that works with nested blocks:

flatten: func [block] [
	forall block [
		if block! = type? block/1 [
			change/part block block/1 1
		]
	]
	block
]

>> flatten [1 [2 [hmm] 42 3] 4]
== [1 2 hmm 42 3 4]
Well, last version can't cope with blocks as first element in blocks:

>> flatten [1 [[hmm] 42 3] 4]
== [1 [hmm] 42 3 4]

so not perfect.
Gregg
18-Feb-2010
[935]
flatten: func [block [any-block!]] [
        parse block [

            any [block: any-block! (change/part block first block 1) :block | 
            skip]
        ]
        head block
    ]
Paul
18-Feb-2010
[936x2]
Steeve, there was no Context! datatype in R2 either.  It has always 
been Object!
;Here is my old one from R2 just quickly formatted for R3:

flatten: make function! [[

    {Returns a new block with desired blocks flattened or removed}
    blk [block!] "block to flatten"
     /fine "Flattens blocks to finest representation"
     /semi "Flattens to support 'select operations"
     /full "Flatten fully - ignored with other refinements"
     /local blk2
    ][
    blk2: copy []
    fl: func [b][
        either parse b [block!][
            b: first b
            fl b
        ][
            either semi [
                insert tail blk2 b
            ][
                either full [

                    foreach val b [either block? val [fl val][insert tail blk2 val]]
                ][
                    insert/only tail blk2 b
                ]
            ]
        ]
    ]

    if fine [full: none while [parse blk [block!]][blk: first blk]]
    foreach item blk [
        either block? item [fl item][insert tail blk2 item]
    ]    
    blk2
]]
Gabriele
19-Feb-2010
[938]
Graham, so, if I load your rebol files, they would work differently 
on my machine because i have different preferences? :)
Graham
19-Feb-2010
[939x2]
Absolutely :)
but then I would expect you to have different data from mine
Steeve
19-Feb-2010
[941]
here's mine:

flatten: funco [data [block!] /deep][
    deep: if deep [[:data]]
    parse data [
        while [to block! data: change skip data/1 deep]
    ] 
    head data
]
>>flatten [[[1]] [[2]][[3]]]
== [[1] [2] [3]]
>>flatten/deep [[[1]] [[2]][[3]]]
==[1 2 3]
Gabriele
19-Feb-2010
[942]
graham, yes, but code is data as well. how can we make something 
like that apply to "data" only and not scripts? in the end, i think 
it's more a matter of needing "custom" parsing for your data, which 
could be made easier (eg. by having special built in parse rules 
for dates and so on)
Oldes
19-Feb-2010
[943]
This is a very nice version Steeve. You should post it to the "favourite 
parse" blog. So we at least get back to it's topic.
Steeve
19-Feb-2010
[944x2]
it's done since a while, but noone noticed it. :)
http://www.rebol.net/cgi-bin/r3blog.r?view=0302#comments
Ashley
19-Feb-2010
[946]
A little something I put together to help R3 developers: http://www.dobeash.com/REBOL/r3-ref.html
Graham
20-Feb-2010
[947]
Is r3 chat working?  I can't login
Henrik
20-Feb-2010
[948]
not working here
Sunanda
20-Feb-2010
[949]
not working for me either.
Henrik
20-Feb-2010
[950]
I get two different crashes. They should both be fixed.
Claude
20-Feb-2010
[951x2]
hi,
hi, where we can download makedoc3 script please ?
Henrik
20-Feb-2010
[953]
which one? there are makedoc3's by several authors. Carl's is not 
available for download.
Graham
20-Feb-2010
[954x2]
don't think it has been released
Carl doesn't release stuff he has no time to document!
Claude
20-Feb-2010
[956]
i think he start the documentation about makedoc3 http://www.rebol.com/r3/docs/markup.html
Pekr
20-Feb-2010
[957]
Does anyone know, if protecting R3 Docs Recent changes site is intentional? 
It served me well to look into new stuff.
Graham
20-Feb-2010
[958x2]
Interesting .. so we should push him to release it
Pekr, perhaps he doesn't want another debacle as with the license 
one
Claude
20-Feb-2010
[960x8]
hi another problem for me !!!
'import do not 'do a module !!!!
in R3 console
new_word: make object! [test: 1]
test_mod: module [title: "test"][o: make new_work[]]
no problem with this..................but
when i but new_word into a file new_word.r and test_mod into test_mod.r 
and i try to import them
>> import %new_word.r
>> import %test_mod.r
** Script error: new_word word is not bound to a context
** Where: do applier make module do applier make catch if import
** Near: do body obj
PeterWood
20-Feb-2010
[968]
AFAIK, import is for modules and your new_word appears to be an object 
This suggests that you should use do %new_word.r rather than import 
%new_word.r
Claude
20-Feb-2010
[969]
oki, but even if i use do for new_word.  test_mod.r have the same 
error !!!!
Graham
20-Feb-2010
[970x2]
posted feedback that r3 chat is now down for 2 days
Does r3 chat actually have a built in revision system?
Gregg
20-Feb-2010
[972]
Very nice Ashley.
Henrik
20-Feb-2010
[973]
Graham, it has an approval system like devbase, but I don't know 
about a real revision system.
Paul
20-Feb-2010
[974x3]
I put R3 on my host so I could attempt to run some cgi scripts.  
Anyone know why I would get this error:


 12:55-7:00 Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 
 20 Keep-Alive: timeout=10, max=29 Connection: Keep-Alive Content-Type: 
 application/cgi ‹
Just a small script:

#!/home/paulsite/dist/r3 -c
REBOL []
print [<HTML><BODY> now </BODY></HTML>]
print ""
I got it working.  Not sure what that was from though.
Graham
20-Feb-2010
[977x3]
I've created a git repository and stored all the protocol stuff there 
... http://github.com/gchiu/Rebol3
If anyone wants to collaborate and to add their stuff ... or add 
RT's stuff ... PM me and I'll add you as a collaborator
Note, a lot of the stuff is alpha quality ... but so is R3 :)
BrianH
20-Feb-2010
[980]
Ladislav, objects don't have a 'self field in R3 - the 'self binding 
is a side-effect of the BIND function. You shouldn't be using IN 
object 'self in R2 either - use BIND?.
Graham
21-Feb-2010
[981]
How do you get the members of an object then?