Optimising Recursive Functions Yielding Multiple Results in Tuples in a Lazy Functional Language

نویسنده

  • John H. G. van Groningen
چکیده

We discuss a new optimisation for recursive functions yielding multiple results in tuples for lazy functional languages, like Clean and Haskell. This optimisation improves the execution time of such functions and also reduces the amount of memory allocated in the heap by these functions, which reduces garbage collection costs. In some cases execution time is improved by more than a factor of two and allocation costs by a factor of four. Furthermore, the space leak that is caused by selector nodes is removed. This is achieved by reusing nodes allocated in the previous iteration of the recursion to create the nodes for the next iteration, by updating these nodes. Only the parts of the nodes that have changed are updated. Because of these updates, the code that is used to select an element of a tuple is not executed anymore for many selections, because the selector node was overwritten with a new selector node or the result before it is evaluated.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Recursive Expressions

\Recursive expressions" is an expression language that allows explicit substitution recur-sively. It lacks functional abstraction, function application and higher order functions, but is powerful enough to construct all partial recursive functions. It may be regarded as a lazy rst-order functional language without functions. We give xpoint semantics and rewrite semantics and prove equality betw...

متن کامل

Purely functional data structures

When a C programmer needs an efficient data structure for a particular problem, he or she can often simply look one up in any of a number of good textbooks or handbooks. Unfortunately, programmers in functional languages such as Standard ML or Haskell do not have this luxury. Although some data structures designed for imperative languages such as C can be quite easily adapted to a functional se...

متن کامل

A Supercompiler for Core Haskell

Haskell is a functional language, with features such as higher order functions and lazy evaluation, which allow succinct programs. These high-level features present many challenges for optimising compilers. We report practical experiments using novel variants of supercompilation, with special attention to let bindings and the generalisation technique.

متن کامل

Stricti cation of Lazy Functions

This papers describes a transformation from lazy functions into e cient non-lazy ones. The functions we study perform multiple traversals over a data structure. Our transformation performs a global analysis of the calling structure of a set of mutually recursive lazy-functions in order to transform them into sets of functions which must be called in sequence. Many of the resulting functions can...

متن کامل

Ph.D. Interim Report: Mathematical Studies of Infinite Computation

Polymorphic stream functions operate on the structure of streams, infinite lists of elements, without inspection of the contained data. We prove that a simple system for specifying recursive stream functions, consisting of equations using only stream constructors and destructors and recursive calls, is already enough to define all computable polymorphic stream functions. Requiring an entirely d...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1999