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

World: r3wp

[Core] Discuss core issues

Janko
12-Feb-2009
[12345x2]
para-do: func [ codes- /local codes cnt values code- value- all-done 
] [
  codes: copy codes-
	cnt: length? codes
  values: make block! cnt
	loop cnt [ append values none ]
	until [ 
		all-done: true
		repeat idx cnt [
			code: pick codes idx
			if not empty? code [
				set/any [ value- code- ] do/next code
				codes/:idx: code-
				values/:idx: value-
				all-done: false
				print mold value-
			]
		] all-done
	] 
	values
]
usage example: 

>> codes: [ [ a: 12 + 23 b: a + 100 c: b * a ] [ t: join "aaa" join 
"bbb" "ccc" find t "b"  ] ] 
>> para-do codes
35
aaabbbccc
135
bbbccc
4725
== [4725 "bbbccc"]
(it collects results of all blocks when done and returns them)
BrianH
12-Feb-2009
[12347]
I wonder if we can do MAP-REDUCE in REBOL :)
Janko
12-Feb-2009
[12348x4]
(it throws error on expressions that retun unset like print .. because 
value- get's undef, but it can probably be made to work)
I think it should be perfectly possible
also.. something para-do could be made so that it would send code 
blocks to multiple rebol processes via tcp or pipes maybe and collect 
results back
it can do 1000 blocks with 5 expressions in 0.03s on my (little slower) 
comp , 10.000 in 0.25s , 100.000 in 3.75s ... so it seems stepping 
the blocks is not horribly slow, and I am sure my func could be made 
better
Steeve
12-Feb-2009
[12352]
clearly, it could be faster but i'm not sure of the interest of such 
thing. If i want a small granularity in a process, i build tiny functions 
and push them in a to-do stack
Janko
12-Feb-2009
[12353]
I am also not yet sure how/if this could be usefull :), but as I 
said it's very impressive that you can do that (I have to go to sleep 
now)
Tomc
13-Feb-2009
[12354x2]
I want to partition a block in place ,that is wohout copy.. 
e.g. 
blk: [ red green blue plum apple orange ]
partition  blk 3
>>  [ [red green blue] [ plum apple orange ] ]
without
BrianH
13-Feb-2009
[12356x2]
while [not empty? blk] [
	blk: change/part blk copy/part blk span
]
Put that in a function.
Tomc
13-Feb-2009
[12358x2]
thanks I have that
but I am interested in manageing without copy
BrianH
13-Feb-2009
[12360]
Sorry, change/part -> change/part/only
Tomc
13-Feb-2009
[12361]
if it is possible
Steeve
13-Feb-2009
[12362]
ouch Brian, one second more and it was my reply :)
BrianH
13-Feb-2009
[12363]
You have to copy - you are turning one series into three (in your 
example).
Steeve
13-Feb-2009
[12364]
missing: span span
BrianH
13-Feb-2009
[12365]
Right :)
Steeve
13-Feb-2009
[12366x2]
unless [empty? blk: change/part blk copy/part blk span span]
(unless is a litlle faster than while)
just my 2 cents :)
BrianH
13-Feb-2009
[12368]
Yes, but he wants it to repeat.
Tomc
13-Feb-2009
[12369]
on large datasets a copyless repartitioning would be more efficent 
more like adding pointers to delimiters within the block
BrianH
13-Feb-2009
[12370]
If you want it to speed up, use until.
Steeve
13-Feb-2009
[12371x2]
argh, i meant until, not unless
grrrrrrrrrrr.....
BrianH
13-Feb-2009
[12373]
Tomc, you can't do copyless and get subseries, but you can build 
a block of before and after references.
Tomc
13-Feb-2009
[12374x2]
thanks steeve  that is about  what I am doing  but while[ not tail 
block ] [change...
brian yes that is what bugs me

if it was in a file  or an un loaded string I could insert  brackets 
to my hearts content . but not once i start useing it.
BrianH
13-Feb-2009
[12376]
new: make blk 2 * divide length? blk span
while [not tail? blk] [
	new: insert/only insert/only blk blk: skip blk span
]
new: head new

Then use /part references.
Steeve
13-Feb-2009
[12377]
uh !?
BrianH
13-Feb-2009
[12378]
make blk -> make block!
Steeve
13-Feb-2009
[12379]
not only that :)
BrianH
13-Feb-2009
[12380]
The resluting block will be pairs of references to the beginning 
and end of his subseries. He can then get any subseries he needs 
by referencing it using the beginning and references with the /part 
option of COPY or INSERT, though using CHANGE or REMOVE will mess 
up the offsets of any subsequent references unless he is referring 
to a list! type.
Tomc
13-Feb-2009
[12381]
a rose by any name ....  new and block both end up with the data 
so it is still copying
BrianH
13-Feb-2009
[12382]
No, you are not inserting copies, you are inserting *references to 
the original*.
Steeve
13-Feb-2009
[12383]
ok Brian, but still missing something, (insert/only new) :)
BrianH
13-Feb-2009
[12384]
Yeah. I am actually working on something else right now, so errors 
are to be expected here.
Tomc
13-Feb-2009
[12385]
Ahhh! I see  hmmm  I think all I will  need to do is reorder *between* 
references and subject those  sub-blocks 
 to further partitioning
BrianH
13-Feb-2009
[12386]
The new block is really an index (in the database sense). You can 
sort and manipulate the index, then use the result to build a new 
version of the data if you like.
Tomc
13-Feb-2009
[12387]
yep
Steeve
13-Feb-2009
[12388]
the only thing you can't do is a mold or a form of this index :)
BrianH
13-Feb-2009
[12389x2]
I'm backporting the last of the R3 reflection functions to R2 right 
now...
TYPES-OF - it's a nasty one to implement.
Tomc
13-Feb-2009
[12391]
what are the costs when a (sub)block is reordered ?
Steeve
13-Feb-2009
[12392]
skiped or sorted ?
Tomc
13-Feb-2009
[12393]
both actually
BrianH
13-Feb-2009
[12394]
You want to make all of your planned changes to the index, then build 
them all at once into new data.