slice negative counter
Posted: Wed Jul 25, 2007 11:17 am
Hi all!
it's probably been discussed before but i haven't searched enough (i got the result on negative offset for slice)
is there any easy way to get negative counter act as position?
inclusive start and end
like:
(set 'a '(1 2 3 4 5 6 7))
(2 -2 a) ;want (3 4 5 6), newlisp gives (3 4 5 6 7)
in code:
(define (my-slice l s c)
(if (>= c 0)
(slice l s c)
(slice l s (+ (length l) c -1))))
a; (1 2 3 4 5 6 7)
(my-slice a 2 -2) ;gives (3 4 5 6)
(my-slice a 2 0); gives ()
(my-slice a 2 2); gives (3 4)
it would be nice to have it in implicit slicing too like (2 -2 a)
thx!
it's probably been discussed before but i haven't searched enough (i got the result on negative offset for slice)
is there any easy way to get negative counter act as position?
inclusive start and end
like:
(set 'a '(1 2 3 4 5 6 7))
(2 -2 a) ;want (3 4 5 6), newlisp gives (3 4 5 6 7)
in code:
(define (my-slice l s c)
(if (>= c 0)
(slice l s c)
(slice l s (+ (length l) c -1))))
a; (1 2 3 4 5 6 7)
(my-slice a 2 -2) ;gives (3 4 5 6)
(my-slice a 2 0); gives ()
(my-slice a 2 2); gives (3 4)
it would be nice to have it in implicit slicing too like (2 -2 a)
thx!