Proposal: conversion functions
David Van Horn 18 Sep 2009 21:09 UTC
Here is a proposal for converting between representation of pairs and
lists. -- David
(pair->pair pair) procedure
Returns a pair whose car and cdr fields are the same (in the sense of
eqv?) as the given pair.
In systems in which random-access pairs are disjoint from sequential
pairs, this procedure converts between representations, i.e. given a
sequential pair, it produces a random-access pair. Given a
random-access pair, it produces a sequential pair.
In systems in which all pairs are random-access pairs, this procedure
behaves as an identity function on pairs.
This operation must take O(1) time. The resulting pair may be newly
allocated.
(list->list list) procedure
Returns a list whose elements are the same (in the sense of eqv?) as the
elements of the given list.
In systems in which random-access pairs are disjoint from sequential
pairs, this procedure converts between representations, i.e. given a
sequential list, it produces a random-access list. Given a
random-access list, it produces a sequential list.
In systems in which all pairs are random-access pairs, this procedure
behaves as an identity function on lists.
This operation may take O(n) time, where n is the size of the list. The
resulting list may be newly allocated.