--* From JONMS%WATSON.vnet.ibm.com@yktvmv.watson.ibm.com  Fri Aug 12 14:23:36 1994
--* Received: from yktvmv-ob.watson.ibm.com by asharp.watson.ibm.com (AIX 3.2/UCB 5.64/930311)
--*           id AA20664; Fri, 12 Aug 1994 14:23:36 -0400
--* Received: from watson.vnet.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 0723; Fri, 12 Aug 94 14:23:39 EDT
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.JONMS.NOTE.VAGENT2.1509.Aug.12.14:23:38.-0400>
--*           for asbugs@watson; Fri, 12 Aug 94 14:23:39 -0400
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id 1503; Fri, 12 Aug 1994 14:23:37 EDT
--* Received: from pi.watson.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with TCP; Fri, 12 Aug 94 14:23:37 EDT
--* Received: by pi.watson.ibm.com (AIX 3.2/UCB 5.64/4.03)
--*           id AA25265; Fri, 12 Aug 1994 14:19:31 -0500
--* Date: Fri, 12 Aug 1994 14:19:31 -0500
--* From: jonms@pi.watson.ibm.com
--* Message-Id: <9408121919.AA25265@pi.watson.ibm.com>
--* To: asbugs@watson.ibm.com
--* Subject: [2] asharp -G run swap.as (from UsrGuide) core dumps [swap.as][0.36.2 for AIX RS/6000]

--@ Fixed  by:  SSD   Mon Aug 15 18:32:39 EDT 1994 
--@ Tested by:  none 
--@ Summary:    gen0Extend needs to handle initialization of domain definitions as gen0Define does. 


--+ --> testcomp
--+ --> testrun
--+
--+ #include "aslib.as"
--+ #pile
--+
--+ I  ==> SingleInteger;
--+ Ag ==> (S: BasicType) -> LinearAggregate S with { export from S };
--+
--+ Agg(S: Type): Category == with { export from S };
--+ extend List (S: Type) : Agg S == add;
--+ extend Array (S: BasicType) : Agg S == add;
--+
--+ -- This function takes two type constructors as arguments and
--+ -- produces a new function to swap aggregate data structure layers.
--+
--+ swap(X:Ag,Y:Ag)(S:BasicType)(x:X Y S):Y X S == [[s for s in y] for y in x]
--+
--+ al: Array List I := array(list(i+j-1 for i in 1..3) for j in 1..3)
--+ la: List Array I := swap(Array,List)(I)(al)
--+
--+ print<<"This is an array of lists: "<<newline<<al<<newline<<newline
--+ print<<"This is a list of arrays: "<<newline<<la<<newline
--> testcomp
--> testrun

#include "aslib.as"
#pile

I  ==> SingleInteger;
Ag ==> (S: BasicType) -> LinearAggregate S with { export from S };

Agg(S: Type): Category == with { export from S };
extend List (S: Type) : Agg S == add;
extend Array (S: BasicType) : Agg S == add;

-- This function takes two type constructors as arguments and
-- produces a new function to swap aggregate data structure layers.

swap(X:Ag,Y:Ag)(S:BasicType)(x:X Y S):Y X S == [[s for s in y] for y in x]

al: Array List I := array(list(i+j-1 for i in 1..3) for j in 1..3)
la: List Array I := swap(Array,List)(I)(al)

print<<"This is an array of lists: "<<newline<<al<<newline<<newline
print<<"This is a list of arrays: "<<newline<<la<<newline
 
