Your sub list
doesn't work for list(qw('foo bar'))
, or any list()
using references and your sub liststar
is wrong for liststar(qw(a))
In lisp, you'd usually use a tail-cdr algorithm- except on implementations which cdr-code (in which case list
maps neatly to a primitive). In practice, reverse
is so absurdly fast in perl that it usually isn't worth optimizing away.