Standard library: Strings¶
Concatenation¶
Goal: implement functions to concatenate an array of unbounded strings.
Steps:
Implement the
Str_Concat
package.
Implement the
Concat
function forUnbounded_String
.Implement the
Concat
function forString
.
Requirements:
The first
Concat
function receives an unconstrained array of unbounded strings and returns the concatenation of those strings as an unbounded string.
The second
Concat
function has the same parameters, but returns a standard string (String
type).Both
Concat
functions have the following parameters:
An unconstrained array of
Unbounded_String
strings (Unbounded_Strings
type).
Trim_Str
, a Boolean parameter indicating whether each unbounded string must be trimmed.
Add_Whitespace
, a Boolean parameter indicating whether a whitespace shall be added between each unbounded string and the next one.
No whitespace shall be added after the last string of the array.
Remarks:
You can use the
Trim
function from theAda.Strings.Unbounded
package.
List of events¶
Goal: create a system to manage a list of events.
Steps:
Implement the
Events
package.
Declare the
Event_Item
subtype.Implement the
Events.Lists
package.
Adapt the
Add
procedure.Adapt the
Display
procedure.
Requirements:
The
Event_Item
type (from theEvents
package) contains the description of an event.
This description is declared as a subtype of unbounded string.
Procedure
Add
adds an event into the list of events for a specific date.
The declaration of
E
needs to be adapted to use unbounded strings.Procedure
Display
must display all events for each date (ordered by date) using the following format:
The arguments to
Put_Line
need to be adapted to use unbounded strings.
Remarks:
We use the lab on the list of events from the previous chapter (Standard library: Dates & Times) as a starting point.