For the Compleat Fan
-
Dmi
- Posts: 408
- Joined: Sat Jun 04, 2005 4:16 pm
- Location: Russia
-
Contact:
Post
by Dmi »
Can't find a simple way for truncating from the end of the list.
In general:
(set 's "abcdefg")
(2 s) => "cdefg"
(-2 s) => "fg"
But, if I want to truncate a number of symbols from the end:
(truncate-2-symbols s) => "abcde"
then I must count the string's length before.
The same situation is for the list's contents...
Is there a simple solution?
WBR, Dmi
-
newdep
- Posts: 2038
- Joined: Mon Feb 23, 2004 7:40 pm
- Location: Netherlands
Post
by newdep »
do you mean this perhpas?
(reverse ( 2 (reverse "hello")))
>"hel"
-- (define? (Cornflakes))
-
Dmi
- Posts: 408
- Joined: Sat Jun 04, 2005 4:16 pm
- Location: Russia
-
Contact:
Post
by Dmi »
Something like that :-)
Thanx.
WBR, Dmi
-
Lutz
- Posts: 5289
- Joined: Thu Sep 26, 2002 4:45 pm
- Location: Pasadena, California
-
Contact:
Post
by Lutz »
and there is also 'chop' with the number of chars/elements to chop:
(chop "abcdefg" 2) => "abcde"
(chop '(a b c d e f g) 2) => (a b c d e)
Lutz
-
Dmi
- Posts: 408
- Joined: Sat Jun 04, 2005 4:16 pm
- Location: Russia
-
Contact:
Post
by Dmi »
Thanks, Lutz!
WBR, Dmi