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

World: r3wp

[Core] Discuss core issues

Brett
27-Jul-2005
[1589]
Agreed Anton and perhaps that shows the obtuse method is not a great 
idea for this situation  - though perhaps an interesting one ;-)
Gabriele
29-Jul-2005
[1590]
In case anyone is interested... http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=reboldiff.r
Henrik
30-Jul-2005
[1591]
Are there any other instances where the a: copy [] vs. a: [] "problem" 
appears?

I'm have a bug where two arrays:

1. an array with data that can be manipulated

2. a similar one containing default data, which is used whenever 
I want to reset the first one


They apparently "stick" together with synchronized values. When I 
manipulate array 1, array 2 changes too. This would be the old COPY 
problem, but I use COPY everywhere, whenever I need to create array 
2.


However I do frequently PICK values from array 2 and POKE it in array 
1 at the same location to reset a specific location to a default 
value. Would that create a similar problem?
Gabriele
30-Jul-2005
[1592x2]
it depends on the kind of value you are picking/poking.
i guess you need copy/deep and poke ... copy pick ...
Henrik
30-Jul-2005
[1594]
I pick and poke arrays
Gabriele
30-Jul-2005
[1595]
i mean, what is the result of PICK? i.e. what is inside the arrays?
Volker
30-Jul-2005
[1596]
if the arrays have multiple dimensions, you need copy/deep. And if 
there are objects inside, those objects are not copied, then you 
need explicit work (copying all objects in a loop using 'make)
Henrik
30-Jul-2005
[1597x2]
Volker, the arrays are indeed both 2 dimensional and contain objects. 
I'll try a different init method.
gabriele, the arrays contain other arrays, hence PICK returns arrays 
of objects.
Gabriele
30-Jul-2005
[1599]
so, copy/deep, and, as volker suggests, you're likely to need to 
clone the objects too.
Henrik
31-Jul-2005
[1600]
thanks, both. problem solved. :-)
Henrik
6-Aug-2005
[1601]
a one liner I didn't see on rebol.com: Sum of all numbers in a block!:

do do replace/all mold [1 2 3 4 5] " " " + "
Sunanda
7-Aug-2005
[1602]
Clever!
But crucially dependent on the block being contained on one line:
 xx: {
 do do replace/all mold [1 2 3
  4 5] " " " + "
 }
 do xx

But then you did call it a one-liner :-)
Henrik
7-Aug-2005
[1603]
do trim/lines xx could fix that
Volker
7-Aug-2005
[1604]
Is there a function which cuts the suffix, so i can go from %file.txt 
to %file.html ? I  remember darkly there is one now.
Henrik
7-Aug-2005
[1605]
I think there is one which splits a file up in an object with path, 
filename and extension. can't remember which though....
Volker
7-Aug-2005
[1606]
thats decode-url, good thought, but not in my case.
Pekr
7-Aug-2005
[1607]
what about cutting at last occurance of "dot"?
Volker
7-Aug-2005
[1608]
longer :) but thats what i do now.
Pekr
7-Aug-2005
[1609x3]
>> prefix: func [filename][copy/part file find/last file "."]
>> prefix file
== %movie.cd1.divx-rel6
where - >> file: %movie.cd1.divx-rel6.avi
maybe 'prefix? would be good addition to Core, as we have 'suffix? 
already? :-)
Volker
7-Aug-2005
[1612]
thats cool, better than mine :) thanks.
Pekr
7-Aug-2005
[1613x2]
but prefix is wrong :-) body uses my global 'file variable - should 
be prefix: func [filename][copy/part filename find/last filename 
"."]
maybe some solution based upon short parse rule could be produced 
too :-)
Volker
7-Aug-2005
[1615]
i guess parse-rule would be longer in this case. now trying

re-suffix: func [file suffix][append copy/part file find/last file 
"." suffix]
Pekr
7-Aug-2005
[1616]
cute!
Rebolek
8-Aug-2005
[1617x3]
I'm tring to expand functions, but unfortunatly I'm not good in bind-magic 
so I've no success. I've got following code:
>> b: func [value][print ["value:" value]]
>> a: func [value][probe value]
>> append second :a compose [b (first :a)]
== [probe value b value]
>> a 1
1
** Script Error: value word has no context
** Where: a
** Near: b value
I've tried to bind it to 'a or 'value but without success. Can somebody 
help me?
Volker
8-Aug-2005
[1620x3]
!>f1: func[a[integer!]][?? a]
!>third :f1
== [a [integer!]]
!>f2: func third :f1 append second :f1 [print ["=" a]]     
!>source f2
f2: func [a [integer!]][?? a print ["=" a]]
!>f2 24
a: 24
= 24
(needs recent rebol for the [integer!]-part)
of course instead of third :f1 you can just copy the source for the 
argument-list, and maybe add locals.
Rebolek
8-Aug-2005
[1623x3]
volker it's not exactly what I needed but I can probably do it this 
way
I'll try it, when I get home and let you. Thanks
let you know
Volker
8-Aug-2005
[1626x2]
i thought so. you want to append something to the function body. 
and to make that use the functions variables, you have to re-func-ing.
but i read now again.
Rebolek
8-Aug-2005
[1628x2]
Oh, I did not know I need to re-func it
I'm trying to append something to feel/over so I need to make new, 
expanded 'over and than replace old 'over with the new one, if I 
understand you correctly
Volker
8-Aug-2005
[1630x2]
hmm, not sure what you want to do. the words in the header are not 
bound to the locals, just names. only the words in the body are bound. 
done by 'func.
yes, expand a copy of the body (thats second :over), then make a 
new func with the same argument list. and the old vars are now bound 
to new function.
Rebolek
8-Aug-2005
[1632]
Have to go now, I'll try it at home and let you know.
Volker
8-Aug-2005
[1633]
Bye Kru, hpe it works.
Rebolek
8-Aug-2005
[1634x2]
Thanks
volker thanks, now it does exactly what I wanted and I can expand 
functions
[unknown: 10]
8-Aug-2005
[1636x2]
Has anyone seen an Language overview regarding Performance on funtions 
etc... that includes Rebol ??
somekind of comparisment chart...
Ladislav
8-Aug-2005
[1638]
Bolek, your first example would have worked too, if you did: append 
second :a compose [b (second second :a)]