Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: function to get the dimenstion of Tuple/Record #734

Open
CervEdin opened this issue Oct 2, 2023 · 2 comments
Open

Feature request: function to get the dimenstion of Tuple/Record #734

CervEdin opened this issue Oct 2, 2023 · 2 comments

Comments

@CervEdin
Copy link

CervEdin commented Oct 2, 2023

I've done a quick look to see if there's a MiniZinc function that can get the dimension of a Record/Tuple but haven't been able to find anything in the standard library. I'm guessing there is no such function.

It would be really neat to have one!

Something like this

type r = par record( int: x, int: y);
int  :  r_size = length(r); % 2
@Dekker1
Copy link
Member

Dekker1 commented Oct 18, 2023

I'm afraid that the type of the argument of the length function requested is currently not expressible in the MiniZinc language. It might be something we could think about in the future. (We are thinking about what (type of) generic operations on records and tuples might need to be added).

Could you tell us what you would like to use this information for?

@CervEdin
Copy link
Author

The specific case I though of occurred when I was transforming an array of tuples/records to an array of arrays.

I did it something like this

type xy = tuple(int, int);
par xy: t = (1,2);
array[int, int] of int: arr2 = [
  [ t.1, t.2 ][i]
  | i in 1..lenght(t)
];

but hardcoding the length.

I was struck that it may be a useful function, even though one can't access tuples via their index, like in python (I guess?).

Doesn't strike me as an extremely worthwhile function, but perhaps useful enough to warrant consideration in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants