Page 1 of 1
Suggestions
Posted: Sat Oct 15, 2005 8:53 pm
by Fanda
1) How do I append list to the list?
> (setq x '(1 2))
(1 2)
> (setq x (append x '(3 4)))
(1 2 3 4)
In this case, 'push' cannot be used:
> (push '(3 4) x -1)
(3 4)
> x
(1 2 (3 4))
>
Function 'write-buffer' accepts only file (integer) or string. Could we add appending to the lists?
Thank you, Fanda
Posted: Sat Oct 15, 2005 9:37 pm
by Sammo
> (setq x '(1 2))
(1 2)
> (setq x (cons x '(3 4)))
((1 2) 3 4)
> x
((1 2) 3 4)
Posted: Sun Oct 16, 2005 12:45 am
by Fanda
Let me explain more:
I mean destructive function (like push) that would add (append) elements to the list from inside of other list.
> (setq x '(1 2))
(1 2)
new write-buffer or other function: (write-buffer x '(3 4))
> x
(1 2 3 4)
Fanda
Posted: Mon Oct 17, 2005 6:09 pm
by Fanda
I thought, I might needed it in recursive functions, but (append) will work fine, I guess ;-)
Lutz - do you have any comments to 1) ?
2) Could we add the 'int?' function?
> integer
integer <417ED0>
> int
int <417ED0>
> integer?
integer? <40BC50>
> int?
nil
>
3) I also noticed that we don't have function for rounding numbers:
I am suggesting: (round x [n]) -- x = int/float -- n = int (float?)
(round 1.9) => 2
(round 123.48) => 123
(round 123.48 0) => 123
(round 123.48 1) => 120
(round 123.48 2) => 100
(round 123.48 3) => 0
(round 123.48 -1) => 123.5
Fanda
Posted: Tue Oct 18, 2005 12:47 am
by Lutz
I want to keep the predicates 'integer?' and 'symbol?' in the long form so they are easier to distinguish from the 'int' and 'sym' functions.
For rounding numbers just try to use 'format' which will do it for you when displaying numbers:
(format "%0.2f" 1.235) => "1.24"
Lutz