Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!rutgers!apple!bionet!ig!arizona!jcp From: jcp@arizona.edu (John Peterson) Newsgroups: comp.lang.lisp Subject: The BEST way to sum a list Message-ID: <7559@megaron.arizona.edu> Date: 27 Oct 88 04:17:31 GMT Organization: U of Arizona CS Dept, Tucson Lines: 22 The discussion comparing different ways to sum a list has missed an important point. Although the solution (apply '+ list) is very elegent, it ignores a basic limitation of Common Lisp: call-arguments-limit. This will not work (nor will eval) if the list is longer than this value. CLtL only states this limit must be at least 50, not much of a list. To be safe (or at least postable), either the iterative solution or reduce should be used. Also, note that this brings up the issue of whether &rest should provide a freshly consed list or not. If it is, &rest would incur the additional overhead of a list copy. This issue is not addressed in CLtL. (There are some very good implementation reasons for this limit. Using registers for parameter passing yields dramatic speedup, but only a finite number of registers or psuedo registers are available.) John Peterson University of Arizona, Dept of Computer Science jcp@megaron.arizona.edu Think Granite