

To_String ( Flattened )) end end Flatten_A_List

Append ( List, null ) declare Flattened : constant Int_List. With Ada.Text_IO with Nestable_Lists procedure Flatten_A_List is package Int_List is new Nestable_Lists ( Element_Type => Integer, To_String => Integer'Image ) List : Int_List. To_String ( Result ) end To_String end Nestable_Lists Next end loop return Result end Flatten function New_List ( E : Element_Type ) return List is begin return new Node '( Kind => Data_Node, Data => E, Next => null ) end New_List function New_List ( N : List ) return List is begin return new Node '( Kind => List_Node, Sublist => N, Next => null ) end New_List function To_String ( L : List ) return String is Current : List := L Result : Ada. Next end loop end case Current := Current. Sublist ) while Temp /= null loop Append ( Result, Temp. Data ) when List_Node => Temp := Flatten ( Current. Kind is when Data_Node => Append ( Result, Current. Next, N ) end if end Append function Flatten ( L : List ) return List is Result : List Current : List := L Temp : List begin while Current /= null loop case Current. Next, E ) end if end Append procedure Append ( L : in out List N : List ) is begin if L = null then L := new Node ( Kind => List_Node ) L. With package body Nestable_Lists is procedure Append ( L : in out List E : Element_Type ) is begin if L = null then L := new Node ( Kind => Data_Node ) L. For a matrix of matrices, ArrayFlatten yields a matrix whose elements are in the same order as in MatrixForm.ArrayFlatten can be used to form block matrices from arrays of blocks.ArrayFlatten requires that the blocks it flattens have dimensions that fit together.
