Forum > Beginners

Single deminision arrays(Solved)

<< < (3/4) > >>

MarkMLl:
Also note that declarations such as


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  South:array[-1..1] of Integer = (10, 32, 41); 
generally work as expected.

MarkMLl

SymbolicFrank:
@JLWest: did you check out sets? That might be what you're looking for. The elements can have a numeric value and there are functions to translate between that value and the name. You can have at most 255 elements in a set, but that won't be a problem in this case.

JLWest:
No, I never considered sets. I have a array of records.

winni:
Hi!

Remember that you can avoid the computing of the index if you choose the right range of an array:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---LastCenturyInfo : array[1901..2000] of string; 
Winni

Thaddy:

--- Quote from: JLWest on June 20, 2022, 07:12:17 pm ---No, I never considered sets. I have a array of records.

--- End quote ---
That would be ill informed for a card game (for lack of an abusive term) because for a card game you can use include/exclude, so the set will represent the cards that are still in the deck or already played. If you write a card game, sets are the way to go.
E.g. Poker can be written in less than 100 lines using sets. Bridge a bit more, but that is just handling logic, so does not count to your problem.
An array of records can be handled with e.g. the sets in rtl-generics.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version