Mailinglist Archive: yast-devel (116 mails)

< Previous Next >
Re: [yast-devel] new YCP builtins
  • From: Arvin Schnell <aschnell@xxxxxxx>
  • Date: Wed, 4 Jun 2008 19:57:36 +0200
  • Message-id: <20080604175735.GA19096@xxxxxxx>
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.


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
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 ' ...
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, <aschnell@xxxxxxx>
Software Engineer, Research & Development
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG N├╝rnberg)
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >