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

World: r3wp

[Core] Discuss core issues

eFishAnt
27-Aug-2005
[1795]
I guess reduce/deep would not be very hard to implement...was just 
surprised there isn't one already...;-)
Volker
27-Aug-2005
[1796]
depends if ou code some themplate, then maybe compose/deep. if its 
data, maybe better reduce/deep.
eFishAnt
27-Aug-2005
[1797]
compose makes strings...I am trying to get it down to literal words.
Volker
27-Aug-2005
[1798]
No, compose makes blocks. If  you mean "flattens blocks", use /only.
eFishAnt
27-Aug-2005
[1799]
going from VID to literal-words...to do comms syncing...so say a: 
"cat" and b: "dog"  I want [cat [dog]] NOT ["cat"["dog"]]
Volker
27-Aug-2005
[1800]
compose [ blah [  (to-word "desired-literal-word") ] ]
eFishAnt
27-Aug-2005
[1801]
[blah [(to-word "desired-literal-word")]]   ;is what returns, instead 
of  [blah [ desired-literal-word]]
Volker
27-Aug-2005
[1802x7]
sorry,
  compose/deep [ blah [  (to-word "desired-literal-word") ] ]
and to be defensive, compose/deep/only.
A first version:
reduce-deep: func[blk /local][
 blk: reduce blk
 forall blk[
  if block? blk/1[
   blk/1: reduce-deep blk/1
  ]
 ]
 blk
]

probe reduce-deep [ 1 + 2 [ 3 + 4 ] ]
probe reduce-deep [ a: [1 + 2] a/1] ; limitation, does not work
reduce-deep: func[blk /local][
 forall blk[
  if block? blk/1[
   blk/1: reduce-deep blk/1
  ]
 ]
 reduce blk
]
probe reduce-deep [ 1 + 2 [ 3 + 4 ] ]
probe reduce-deep [ a: [1 + 2] a/1] ; limitation, does not work
[3 [7]]
[[3] 3]
better. perfect one is hard.
(drop the "limitation, does not work" in last post)
this breaks then, because inner blocks are evaluated first:
  a: 2 probe reduce-deep [ a: 1 [a]]
eFishAnt
27-Aug-2005
[1809]
that's interesting, I figured the order of evaluation might be why 
there isn't on...why I instinctively thought of /nested as a refinement...thanks 
for the insights.
Volker
27-Aug-2005
[1810x4]
problem here is, we need do/next to know how long one experession 
is. but before do/next, we can not reduce subblocks. that should 
be done only for one expression. but we do not which blocks before 
do/next.. maybe it should be really inbuild?
but if you don't do such tricky assigining in reduce, this should 
work
What did i write? Trying explanation again.. We need do/next to know 
which blocks are in the next expression. Then expand only these. 
But by using do/next, we have already used the old, unreduced blocks..
So the workarounds is to expand all blocks at once, either before 
reducing that level or after. breaks a bit semantic, means do not 
depend on evaluation-order.
eFishAnt
28-Aug-2005
[1814]
thanks...sorry, got pulled off by my daughter to google when her 
power would be restored...your thoughts here are greatly appreciated, 
as always, Volker.
Maarten
28-Aug-2005
[1815]
I went down this road once. Using do/next terribly slows things down. 
I think that you need parse for this.
Brett
29-Aug-2005
[1816x3]
Just passing. Thought that the function would be interesting, came 
up with this draft.
reduce-deep: func [
	block [block!]
	/local queue result file eval-state sub-result
][

	; Initialise
	queue: make list! 10
	result: reduce []


 ; Loop until we exhaust all unfinished blocks and we exhaust current 
 block.
	until [

		either empty? :block [
			; If finished this block, but more to process - add our
			; result to higher block result and set that block as current.
			if not empty? queue [
				set/any 'sub-result get/any 'result
				set [result block] queue/1
				insert/only tail result get/any 'sub-result
				queue: remove queue
			]
		][

			; Process current block item.

			either block? block/1 [
				; Save current level to process later,
				; set this new block as current.
				queue: head insert/only queue reduce [result next block]
				result: reduce []
				block: block/1
			][
				; Evaluate item.
				eval-state: do/next block
				insert/only tail result eval-state/1
				block: eval-state/2
			]
		]

		all [tail? block tail? queue]
	]

	; Return final result
	result
]
Not robustly tested.
JaimeVargas
30-Aug-2005
[1819]
How can I access a network drive?
Graham
30-Aug-2005
[1820]
I'm sure it's just  %uncname/
JaimeVargas
30-Aug-2005
[1821]
Humm. Not working here.
Graham
30-Aug-2005
[1822]
perhaps it's %/uncname
Volker
30-Aug-2005
[1823]
IIRC /myserver/volker/...
Anton
31-Aug-2005
[1824]
umm.. tried leading double slash ? eg. %//uncname/
Graham
31-Aug-2005
[1825x3]
My primary scsi hard drive in my server killed windows 2003 somehow. 
 It fails the seagate diagnostics though the seatools can't identify 
the drive.  I put in another scsi drive but even though they all 
have different ids, the new windows 2003 server dies when I reattach 
the old drive ( i want to recover files off it ).  It just reboots 
even in safe mode.  Anyone any ideas as to why it should do that?
Unfortunately BartPE doesn't have the driver for the scsi controller 
so I can't use that to examine the drive.
oops .. wrong channel.
JaimeVargas
31-Aug-2005
[1828]
Not of the suggested ways work for me. I am using XP.
Anton
31-Aug-2005
[1829x2]
Maybe you can read a file directly from the share, but it looks like 
you can't access it because you can't CHANGE-DIR to it ?:

http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlPCHJ
Hey! The rebol.org mail search is pretty good ! Faster than my computer. 
:)
Sunanda
31-Aug-2005
[1831]
Thanks Anton! We had some fun tuning it (it's done with just REBOL 
objects and blocks by the way)--- It should be even faster if implemented 
on your computer as REBOL.org runs (as far as I can tell) on a shared 
1ghz machine with the slowest hard drives outside of a museum.
Geomol
5-Sep-2005
[1832x5]
context question:
If I inside a context block (an object) in one program write:
do %some-program.r

then I can't reach words and functions in the first program from 
the second. I've also tried to bind words to the first context, but 
without luck. Any ideas? Maybe I should put 2 small test-scripts 
here:
prg1.r:

REBOL []
mycontext: context [
do %prg2.r
o: context [
	f: does [print "Hello World!"]
]
f2
]
prg2.r: 

REBOL[]
f2: does [o/f]
I get this error:

>> do %prg1.r
** Script Error: o has no value
** Where: f2
** Near: o/f
If I exclude mycontext from prg1.r binding the words to the global 
context, then it works. But that's not a nice solution.
Ladislav
5-Sep-2005
[1837x3]
this may work:

prg1.r:

REBOL []
mycontext: context [
#include %prg2.r
o: context [
	f: does [print "Hello World!"]
]
f2
]
include %prg1.r
you just have to use my INCLUDE function
Geomol
5-Sep-2005
[1840]
Okay, taking a look...
Ladislav
5-Sep-2005
[1841]
http://www.fm.vslib.cz/~ladislav/rebol/include.r
Geomol
5-Sep-2005
[1842]
Hmm, still doesn't work.
Ladislav
5-Sep-2005
[1843]
checking
Geomol
5-Sep-2005
[1844]
REBOL []

do %include.r

mycontext: context [

include %prg2.r

o: context [
	f: does [print "Hej!"]
]

f2
]	; context