Re: [open-axiom-devel] String vs List
A system for computer algebra and symbolic mathematics
Brought to you by:
dos-reis
From: Gabriel D. R. <gd...@cs...> - 2012-02-07 09:35:02
|
Waldek Hebisch <he...@ma...> writes: | Serge D. Mechveliani wrote: | > | > On Sun, Feb 05, 2012 at 01:56:20AM +0100, Ralf Hemmecke wrote: | > > On 02/04/2012 06:13 PM, Serge D. Mechveliani wrote: | > >> [..] | > >>>> dropWhile(p: Character -> Boolean, xs: List Character) : | > >>>> List Character == | > >>>> empty? xs => xs | > >>>> p first(xs) => dropWhile(p, rest xs) | > >>>> xs | > >>>> Is this more efficient? [...] | Spad compiler will inline "simple enough" functions. Unfortunately, | currently this means functions consisting of single operation. | | Your version will generate the following Lisp code: | | (DEFUN |TTT;dropWhile;M2L;1| (|p| |xs| $) | (COND ((OR (NULL |xs|) (NULL (SPADCALL (|SPADfirst| |xs|) |p|))) |xs|) | ('T (SPADCALL |p| (CDR |xs|) (QREFELT $ 8))))) OpenAxiom resolves these SPADCALLs within the same package/domain and produces (DEFUN |SERGEI;dropWhile;M2L;1| (|p| |xs| $) (COND ((OR (NULL |xs|) (NOT (SPADCALL (|SPADfirst| |xs|) |p|))) |xs|) (T (|SERGEI;dropWhile;M2L;1| |p| (CDR |xs|) $)))) which any of the free Lisp supported by OpenAxiom is capable of recognizing as tail-recursive, and therefore optimize appropriately. -- Gaby |