[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposal: conversion functions

This page is part of the web mail archives of SRFI 101 from before July 7th, 2015. The new archives for SRFI 101 contain all messages, not just those from before July 7th, 2015.



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.