jed-users mailing list

[2003 Date Index] [2003 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

a[[i1:i2]], substring and min, max


a= "abc"
a[[0:-3]]  returns "a"
a[[0:-4]]  returns ""
a[[0:-5]]  returns ""
a[[0:-6]]  returns "a" ???

Is there an explanation for this behaviour?

I think the following functions would be nice to have, in C for performance:

define min( a, b)
{
   if ( a < b) return a; else return b;
}
define max( a, b)
{
   if ( a > b) return a; else return b;
}
define substring( s, i1, i2)
{
   if ( strlen(s) == 0) return "";

   if ( i1 < 0) i1+= strlen(s);
   if ( i2 < 0) i2+= strlen(s);

   i1= max( 0, i1);
   i2= min( i2, strlen(s)-1);

   if ( i1 > i2) return "";

   return a[[i1:i2]];
}


Of course I wished the documentation would go deeper into
details in some places. I am glad, there is the possibility to look
into the sources (SLang and C), but even better I think would be
to have some easy readable SLang-code (or pseudo-code) for
some functions right in the documentation.
This would avoid lengthy explanations of details, which are
sometimes harder to understand than some lines of code.
I would invest some time in this -- supposed I am not the only one ;)

-- Klaus


--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2003 date index] [2003 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]