Mailinglist Archive: yast-devel (116 mails)

< Previous Next >
[yast-devel] Request for new Builtin
  • From: Arvin Schnell <aschnell@xxxxxxx>
  • Date: Fri, 13 Jun 2008 14:43:55 +0200
  • Message-id: <20080613124354.GA4543@xxxxxxx>

Hi,

it's ITO Friday again and I would like to add a tiny builtin to
YCP.

integer::range(integer n)
integer::range(integer s, integer n)

It produces a list with the integers from 0 or s to n-1 (as known
from the Python range builtin).

integer::range(3) -> [ 0, 1, 2 ]
integer::range(1, 5) -> [ 1, 2, 3, 4 ]

It's useful to iterate over a sequence of numbers (like with a
'for' in C), e.g.:

foreach(integer i, integer::range(size(addresses)), {
y2milestone("Address No %1 is %2", i+1, addresses[i]);
});

This is rather clumsy without range.

Comments?

ciao Arvin

--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >