\documentclass{article} \usepackage{axiom} \begin{document} \title{\$SPAD/src/algebra ituple.spad} \author{Clifton J. Williamson} \maketitle \begin{abstract} \end{abstract} \eject \tableofcontents \eject \section{domain ITUPLE InfiniteTuple} <>= )abbrev domain ITUPLE InfiniteTuple ++ Infinite tuples for the interpreter ++ Author: Clifton J. Williamson ++ Date Created: 16 February 1990 ++ Date Last Updated: 16 February 1990 ++ Keywords: ++ Examples: ++ References: InfiniteTuple(S:Type): Exports == Implementation where ++ This package implements 'infinite tuples' for the interpreter. ++ The representation is a stream. Exports ==> CoercibleTo OutputForm with map: (S -> S, %) -> % ++ map(f,t) replaces the tuple t ++ by \spad{[f(x) for x in t]}. filterWhile: (S -> Boolean, %) -> % ++ filterWhile(p,t) returns \spad{[x for x in t while p(x)]}. filterUntil: (S -> Boolean, %) -> % ++ filterUntil(p,t) returns \spad{[x for x in t while not p(x)]}. select: (S -> Boolean, %) -> % ++ select(p,t) returns \spad{[x for x in t | p(x)]}. generate: (S -> S,S) -> % ++ generate(f,s) returns \spad{[s,f(s),f(f(s)),...]}. construct: % -> Stream S ++ construct(t) converts an infinite tuple to a stream. Implementation ==> Stream S add generate(f,x) == generate(f,x)$Stream(S) pretend % filterWhile(f, x) == filterWhile(f,x pretend Stream(S))$Stream(S) pretend % filterUntil(f, x) == filterUntil(f,x pretend Stream(S))$Stream(S) pretend % select(f, x) == select(f,x pretend Stream(S))$Stream(S) pretend % construct x == x pretend Stream(S) -- coerce x == -- coerce(x)$Stream(S) @ \section{package ITFUN2 InfiniteTupleFunctions2} <>= import InfiniteTuple )abbrev package ITFUN2 InfiniteTupleFunctions2 InfiniteTupleFunctions2(A:Type,B:Type): Exports == Implementation where ++ Functions defined on streams with entries in two sets. IT ==> InfiniteTuple Exports ==> with map: ((A -> B),IT A) -> IT B ++ \spad{map(f,[x0,x1,x2,...])} returns \spad{[f(x0),f(x1),f(x2),..]}. Implementation ==> add map(f,x) == map(f,x pretend Stream(A))$StreamFunctions2(A,B) pretend IT(B) @ \section{package ITFUN3 InfiniteTupleFunctions3} <>= import InfiniteTuple import Stream )abbrev package ITFUN3 InfiniteTupleFunctions3 InfiniteTupleFunctions3(A:Type, B:Type,C:Type): Exports == Implementation where ++ Functions defined on streams with entries in two sets. IT ==> InfiniteTuple ST ==> Stream SF3 ==> StreamFunctions3(A,B,C) FUN ==> ((A,B)->C) Exports ==> with map: (((A,B)->C), IT A, IT B) -> IT C ++ map(f,a,b) \undocumented map: (((A,B)->C), ST A, IT B) -> ST C ++ map(f,a,b) \undocumented map: (((A,B)->C), IT A, ST B) -> ST C ++ map(f,a,b) \undocumented Implementation ==> add map(f:FUN, s1:IT A, s2:IT B):IT C == map(f, s1 pretend Stream(A), s2 pretend Stream(B))$SF3 pretend IT(C) map(f:FUN, s1:ST A, s2:IT B):ST C == map(f, s1, s2 pretend Stream(B))$SF3 map(f:FUN, s1:IT A, s2:ST B):ST C == map(f, s1 pretend Stream(A), s2)$SF3 @ \section{License} <>= --Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd. --All rights reserved. -- --Redistribution and use in source and binary forms, with or without --modification, are permitted provided that the following conditions are --met: -- -- - Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- -- - Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in -- the documentation and/or other materials provided with the -- distribution. -- -- - Neither the name of The Numerical ALgorithms Group Ltd. nor the -- names of its contributors may be used to endorse or promote products -- derived from this software without specific prior written permission. -- --THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS --IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED --TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER --OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, --EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, --PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @ <<*>>= <> <> <> <> @ \eject \begin{thebibliography}{99} \bibitem{1} nothing \end{thebibliography} \end{document}