Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6835455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:14:04+00:00 2026-05-26T23:14:04+00:00

I have many constant arrays that do not all have the same number of

  • 0

I have many constant arrays that do not all have the same number of elements.

To store these arrays, I have declared an array type large enough to store (or reference?) every element of the largest of these arrays:

type
  TElements = array [1 .. 1024] of Single;

Each of these TElements arrays are logically associated with one other TElements array that does have the same number of elements.

So to pair up these equally-sized arrays, I have declared a record type as:

type
  TPair = record
    n : Integer; // number of elements in both TElements arrays
    x : ^TElements;
    y : ^TElements;
  end;

I am then defining constant TPair records containing the constant TElements array pairs:

const

  ElementsA1 : array [1 .. 3] of Single = (0.0, 1.0,  2.0);
  ElementsA2 : array [1 .. 3] of Single = (0.0, 10.0, 100.0);
  ElementsA  : TPair =
  (
    n : 3;
    x : @ElementsA1;
    y : @ElementsA2;
  );

  ElementsB1 : array [1 .. 4] of Single = (0.0, 1.0,  2.0,   3.0);
  ElementsB2 : array [1 .. 4] of Single = (0.0, 10.0, 100.0, 1000.0);
  ElementsB  : TPair =
  (
    n : 4;
    x : @ElementsB1;
    y : @ElementsB2;
  );  

This seems like an inefficient way to reference the array data (maybe not, I dunno).

I would like to maintain a single constant data type (a “pair” data type) that contains two constant arrays.

Within each “pair”, both arrays are guaranteed to have the same number of elements.

However, it can not be guaranteed that the number of array elements in one “pair” will equal the number of array elements in any other “pair”.

Is there a way to declare a constant “pair” data type so that the contained array sizes are determined by the constant array definition?

Ideally, I would like to get rid of the TElements type and the awkward pointers. Something like this would be cool if it would compile:

type
  TPair = record
    x : array of Single; 
    y : array of Single; 
  end;

const

  ElementsA : TPair =
  (
    x : (0.0, 1.0,  2.0);
    y : (0.0, 10.0, 100.0);
  );

  ElementsB : TPair =
  (
    x : (0.0, 1.0,  2.0,   3.0);
    y : (0.0, 10.0, 100.0, 1000.0);
  );

But I guess since the arrays are declared as dynamic arrays, it doesn’t want to allocate memory for them before runtime?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:14:05+00:00Added an answer on May 26, 2026 at 11:14 pm

    Is there a way to declare a constant “pair” data type so that the contained array sizes are determined by the constant array definition?

    No, sadly this is not possible. You have to declare the size of your array inside the square brackets.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many sites that use the same root category of the Main Site.
I have roughly 420,000 elements that I need to store easily in a Set
I've noticed many (all?) PHP constants have a single-letter prefix, like E_NOTICE , T_STRING
I have many emails coming in from different sources. they all have attachments, many
I have many jobs that have a step to send 1 specific email out
We have many projects that use a common base of shared components (dlls). Currently
I have many different branches/checkouts of the same project code on my development machine.
I have many constant variables for example: Const Total_US_Price = 100 However, in my
I have a structure that contains an arrays of another structure, it looks something
I have a file that has many #define statements such as - #ifndef UTILITY_H

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.