Hi all,
list and cons functions are faster than append (no doubt about it) but sometimes append seems to be the best way.
If I don't misunderstand, the goal is to rotate the first item of a list to the end of this list:
(setq lst '(0 1 2 3 4 5 6 7 8 9))
(0 1 2 3 4 5 6 7 8 9) -> (1 2 3 4 5 6 7 8 9 0)
Neither curmudgeon nor CAB given expression do the trick:
(append (cdr lst) (list (list (car lst)))) returns (1 2 3 4 5 6 7 8 9 (0))
(list (cdr lst) (car lst)) returns ((1 2 3 4 5 6 7 8 9) 0)
Right expressions could be:
(append (cdr lst) (list (car lst)))
(reverse (cons (car lst) (reverse (cdr lst))))
which both return (1 2 3 4 5 6 7 8 9 0) and the append expression is faster than the reverse cons reverse one.