[REBOL] Re: (Fwd) fine tuning question of Rebol
From: volker:nitsch:gm:ail at: 25-Apr-2005 16:49
forall would drop a line. the "res: copy[]" not, we have no collecting
loops inbuild.
insert-separator: func [ condSerie separator ] [
rez: copy []
forall condSeries [
repend rez [ first condSerie ]
if not tail? next condSerie [ repend rez separator ]
; dropp this: tail? condSerie: next condSerie
]
return rez
]
another trick is to add the seperator allways, and drop it later:
insert-separator: func [ condSerie separator ] [
rez: copy []
forall condSeries [
repend rez [ seperator first condSerie ] ;sep. first!
; drop this: if not tail? next condSerie [ repend rez separator ]
; drop this: tail? condSerie: next condSerie
]
return remove rez ;drop first seperator
]
or append [condSeries seperator] in that order, and
return head (clear back tail rez) ;parens for clarity
slightly faster, more ugly
On 4/25/05, [sags--apollo--lv] <[sags--apollo--lv]> wrote:
> Hi, Rebolers!
>
> I wrote a function, that allows me to construct where parts of
> sql, coma separated lists etc:
>
> Ssee attached file.
>
> Is it possible to do it in some shorter and more effective way?
>
> brgds
> Janeks
>
> I am trying second time because of some conversions of []
> characters.
> Sorry if it will be the same!
>
> -- Attached file included as plaintext by Ecartis --
> -- Desc: Text from file 'insep.r'
>
> insert-separator: func [ condSerie separator ] [
> rez: copy []
> until [
> repend rez [ first condSerie ]
> if not tail? next condSerie [ repend rez separator ]
> tail? condSerie: next condSerie
> ]
> return rez
> ]
>
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
>
--
-Volker
Any problem in computer science can be solved with another layer of
indirection. But that usually will create another problem.
David
Wheeler