On Wed, Jun 04, 2008 at 04:04:15PM +0200, Lukas Ocilka wrote:
> Arvin Schnell wrote:
> >Hi YCP-Hackers,
> >
> >I've used some ITO time to implement two new YCP builtins:
> >
> >
> >1. splitlist (var x, list, block using x)
> >   
> >   Takes a list and a predicate function and splits the list where the
> >   predicate function says so. Returns a list of lists.
> >
> >   Example:
> >
> >   list<string> l = [ "0", "a", "1", "2", "b", "3", "4" ];
> >   splitlist(string s, l, { return isalpha(s); });
> >
> >   return is [ [ "0" ], [ "a", "1", "2" ], [ "b", "3", "4" ] ]
> >
> >   The difference to splitstring is that the 'delimiter' is included in the
> >   result since that's the way I need it. If desired I could add a 
> >   parameter
> >   that tells whether the 'delimiter' should be added to the previous list,
> >   the following list or not at all.
> 
> Hmm, and do you really see any possibility where *else* such a builtin 
> could be used? What are the use-cases?

Appart from my use in storage you could split logfiles,
e.g. split y2log at lines containing 'genericfrontend.cc ...
Launched YaST2 component' to present the individual runs. Or
maybe even split /var/log/messages in several hierarchy and
display the result in a tree widget so it's easy to fold/unfold
messages you don't care about.

But I understand that the use-cases are limited.

> Why should we have it?

Code reuse. Onlt builtins can have variable types.

>   * In conflict with the current /splitstring/ where the delimiter is
>     not included.

I consider that to be a limitation of splitstring and I could
improve splitlist to be compatible depending on a parameter.

ciao Arvin

-- 
Arvin Schnell, <[EMAIL PROTECTED]>
Software Engineer, Research & Development
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to