prepend (was Re: Re: Reverse append refinement for write)
[1/3] from: louisaturk:coxinet at: 15-Aug-2002 9:48
Here's a function based on Gregg's code. Do you see any way to improve it?
rebol[]
prepend: func [
{
Inserts a value to the head of a file and returns the head.
Usage: prepend file value-to-prepend
}
file [file!]
value [any-type!]
][
close insert open file value
]
prepend %pig.txt newline
prepend %pig.txt " day!"
prepend %pig.txt "Have a good"
prepend %pig.txt reduce ["Another line." newline]
prepend %pig.txt reduce [now newline]
print read %pig.txt
At 11:54 AM 8/15/2002 +0200, you wrote:
[2/3] from: anton:lexicon at: 16-Aug-2002 2:27
It would be better if it was more general,
and consistent with append if it took the
same datatypes as append [series! port!].
I would suggest renaming the below function
to prepend-file, since it is for a specific
case.
Anton.
[3/3] from: louisaturk:coxinet at: 17-Aug-2002 21:13
Hi Anton,
At 02:27 AM 8/16/2002 +1000, you wrote:
>It would be better if it was more general,
>and consistent with append if it took the
>same datatypes as append [series! port!].
Thanks for taking a look. I tried to take this advice, but it was taking
too much time. Perhaps I'll try again later as I learn more.
>I would suggest renaming the below function
>to prepend-file, since it is for a specific
>case.
>
>Anton.
It has been renamed! Thanks.
Louis