Defining a bag Multiset with elements and multiplicity pairs In Ada
I have to meet a specification which says that I have to write a bag type which is a record with discriminant , which is the maximum capacity of the bag in the record I have to put an array that contains element and multiplicity pairs , I have written some code and updated it as well
type TArray is array (Integer range <>) of Elem,Multi;
type Bag (Max : Positive) is record
Data : TArray (1 .. Max);
Pointer : Natural := 0;
end record;
The code has been updated please check and suggest
ada type-declaration
add a comment |
I have to meet a specification which says that I have to write a bag type which is a record with discriminant , which is the maximum capacity of the bag in the record I have to put an array that contains element and multiplicity pairs , I have written some code and updated it as well
type TArray is array (Integer range <>) of Elem,Multi;
type Bag (Max : Positive) is record
Data : TArray (1 .. Max);
Pointer : Natural := 0;
end record;
The code has been updated please check and suggest
ada type-declaration
1
I've edited your question, so the source text is syntax high-lighted. You may want to take a look at how I did it. (Easier than looking up the manual. ;-)
– Jacob Sparre Andersen
Nov 14 '18 at 9:55
1
Your array type looks incomplete, if it both should contain both elements and multiplicities.
– Jacob Sparre Andersen
Nov 14 '18 at 10:10
1
If you’re going to post code you should really try compiling it! You need an array of a record type, where the record type contains an element and a multiplicity
– Simon Wright
Nov 14 '18 at 10:48
1
I beg your pardon, but where is the question / compilation error / execution exception ?
– LoneWanderer
Nov 18 '18 at 3:22
add a comment |
I have to meet a specification which says that I have to write a bag type which is a record with discriminant , which is the maximum capacity of the bag in the record I have to put an array that contains element and multiplicity pairs , I have written some code and updated it as well
type TArray is array (Integer range <>) of Elem,Multi;
type Bag (Max : Positive) is record
Data : TArray (1 .. Max);
Pointer : Natural := 0;
end record;
The code has been updated please check and suggest
ada type-declaration
I have to meet a specification which says that I have to write a bag type which is a record with discriminant , which is the maximum capacity of the bag in the record I have to put an array that contains element and multiplicity pairs , I have written some code and updated it as well
type TArray is array (Integer range <>) of Elem,Multi;
type Bag (Max : Positive) is record
Data : TArray (1 .. Max);
Pointer : Natural := 0;
end record;
The code has been updated please check and suggest
ada type-declaration
ada type-declaration
edited Nov 14 '18 at 10:46
csc tikonapark
asked Nov 14 '18 at 9:14
csc tikonaparkcsc tikonapark
12
12
1
I've edited your question, so the source text is syntax high-lighted. You may want to take a look at how I did it. (Easier than looking up the manual. ;-)
– Jacob Sparre Andersen
Nov 14 '18 at 9:55
1
Your array type looks incomplete, if it both should contain both elements and multiplicities.
– Jacob Sparre Andersen
Nov 14 '18 at 10:10
1
If you’re going to post code you should really try compiling it! You need an array of a record type, where the record type contains an element and a multiplicity
– Simon Wright
Nov 14 '18 at 10:48
1
I beg your pardon, but where is the question / compilation error / execution exception ?
– LoneWanderer
Nov 18 '18 at 3:22
add a comment |
1
I've edited your question, so the source text is syntax high-lighted. You may want to take a look at how I did it. (Easier than looking up the manual. ;-)
– Jacob Sparre Andersen
Nov 14 '18 at 9:55
1
Your array type looks incomplete, if it both should contain both elements and multiplicities.
– Jacob Sparre Andersen
Nov 14 '18 at 10:10
1
If you’re going to post code you should really try compiling it! You need an array of a record type, where the record type contains an element and a multiplicity
– Simon Wright
Nov 14 '18 at 10:48
1
I beg your pardon, but where is the question / compilation error / execution exception ?
– LoneWanderer
Nov 18 '18 at 3:22
1
1
I've edited your question, so the source text is syntax high-lighted. You may want to take a look at how I did it. (Easier than looking up the manual. ;-)
– Jacob Sparre Andersen
Nov 14 '18 at 9:55
I've edited your question, so the source text is syntax high-lighted. You may want to take a look at how I did it. (Easier than looking up the manual. ;-)
– Jacob Sparre Andersen
Nov 14 '18 at 9:55
1
1
Your array type looks incomplete, if it both should contain both elements and multiplicities.
– Jacob Sparre Andersen
Nov 14 '18 at 10:10
Your array type looks incomplete, if it both should contain both elements and multiplicities.
– Jacob Sparre Andersen
Nov 14 '18 at 10:10
1
1
If you’re going to post code you should really try compiling it! You need an array of a record type, where the record type contains an element and a multiplicity
– Simon Wright
Nov 14 '18 at 10:48
If you’re going to post code you should really try compiling it! You need an array of a record type, where the record type contains an element and a multiplicity
– Simon Wright
Nov 14 '18 at 10:48
1
1
I beg your pardon, but where is the question / compilation error / execution exception ?
– LoneWanderer
Nov 18 '18 at 3:22
I beg your pardon, but where is the question / compilation error / execution exception ?
– LoneWanderer
Nov 18 '18 at 3:22
add a comment |
1 Answer
1
active
oldest
votes
The answer is quite simple : if you don't have any error messages at compilation phase, it's ok.
Well according to what you described, your code looks good. I have a question about it.
Do you plan to have negative indexes on your type TArray ? If not, why don't you use the same type as your discriminant ?
The only thing is that you'll have only half the values using Positive instead of Integer but in your record, you anyway already start at 1 and thus have the same range as Positive.
Just compiling successfully doesn’t indicate correctness!
– Simon Wright
Nov 14 '18 at 10:49
Of course not but regarding the information contained in the question, it's a first step :)
– Frédéric Praca
Nov 14 '18 at 10:51
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296587%2fdefining-a-bag-multiset-with-elements-and-multiplicity-pairs-in-ada%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The answer is quite simple : if you don't have any error messages at compilation phase, it's ok.
Well according to what you described, your code looks good. I have a question about it.
Do you plan to have negative indexes on your type TArray ? If not, why don't you use the same type as your discriminant ?
The only thing is that you'll have only half the values using Positive instead of Integer but in your record, you anyway already start at 1 and thus have the same range as Positive.
Just compiling successfully doesn’t indicate correctness!
– Simon Wright
Nov 14 '18 at 10:49
Of course not but regarding the information contained in the question, it's a first step :)
– Frédéric Praca
Nov 14 '18 at 10:51
add a comment |
The answer is quite simple : if you don't have any error messages at compilation phase, it's ok.
Well according to what you described, your code looks good. I have a question about it.
Do you plan to have negative indexes on your type TArray ? If not, why don't you use the same type as your discriminant ?
The only thing is that you'll have only half the values using Positive instead of Integer but in your record, you anyway already start at 1 and thus have the same range as Positive.
Just compiling successfully doesn’t indicate correctness!
– Simon Wright
Nov 14 '18 at 10:49
Of course not but regarding the information contained in the question, it's a first step :)
– Frédéric Praca
Nov 14 '18 at 10:51
add a comment |
The answer is quite simple : if you don't have any error messages at compilation phase, it's ok.
Well according to what you described, your code looks good. I have a question about it.
Do you plan to have negative indexes on your type TArray ? If not, why don't you use the same type as your discriminant ?
The only thing is that you'll have only half the values using Positive instead of Integer but in your record, you anyway already start at 1 and thus have the same range as Positive.
The answer is quite simple : if you don't have any error messages at compilation phase, it's ok.
Well according to what you described, your code looks good. I have a question about it.
Do you plan to have negative indexes on your type TArray ? If not, why don't you use the same type as your discriminant ?
The only thing is that you'll have only half the values using Positive instead of Integer but in your record, you anyway already start at 1 and thus have the same range as Positive.
answered Nov 14 '18 at 10:06
Frédéric PracaFrédéric Praca
544516
544516
Just compiling successfully doesn’t indicate correctness!
– Simon Wright
Nov 14 '18 at 10:49
Of course not but regarding the information contained in the question, it's a first step :)
– Frédéric Praca
Nov 14 '18 at 10:51
add a comment |
Just compiling successfully doesn’t indicate correctness!
– Simon Wright
Nov 14 '18 at 10:49
Of course not but regarding the information contained in the question, it's a first step :)
– Frédéric Praca
Nov 14 '18 at 10:51
Just compiling successfully doesn’t indicate correctness!
– Simon Wright
Nov 14 '18 at 10:49
Just compiling successfully doesn’t indicate correctness!
– Simon Wright
Nov 14 '18 at 10:49
Of course not but regarding the information contained in the question, it's a first step :)
– Frédéric Praca
Nov 14 '18 at 10:51
Of course not but regarding the information contained in the question, it's a first step :)
– Frédéric Praca
Nov 14 '18 at 10:51
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296587%2fdefining-a-bag-multiset-with-elements-and-multiplicity-pairs-in-ada%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I've edited your question, so the source text is syntax high-lighted. You may want to take a look at how I did it. (Easier than looking up the manual. ;-)
– Jacob Sparre Andersen
Nov 14 '18 at 9:55
1
Your array type looks incomplete, if it both should contain both elements and multiplicities.
– Jacob Sparre Andersen
Nov 14 '18 at 10:10
1
If you’re going to post code you should really try compiling it! You need an array of a record type, where the record type contains an element and a multiplicity
– Simon Wright
Nov 14 '18 at 10:48
1
I beg your pardon, but where is the question / compilation error / execution exception ?
– LoneWanderer
Nov 18 '18 at 3:22