Hello, I know in some languages, such as java it is possible to create a unique variable type. What I mean by that, is you can create a variable type with a name of your choice, and it can contain different data types already defined. An example: you could create a variable type named foo, and in it, have it place two other variable types, a Boolean variable, and an int. Then anytime from then on in your code, if you create a variable of type foo, it will have in it a Boolean and a int.

The reason I am looking for this, is I am working on solving the queens problem, and my current algorithm, requires I create a two-dimensional array of the above described variable type foo. The Boolean to represent if a queen is present in a square, and the int to represent if a square is threatened by a queen. I however after looking through both perldocs and doing several different Google searches, have come up with no results that help resolve my predicament. I was hoping someone would be able to point me in the correct direction if this is indeed possible, or to be informed that this is not possible, so I may begin to contemplate an alternative.

I also ask for no help in solving the queens problem specifically, I am viewing this as a intellectual challenge, and receiving help in solving the actual problem I feel would defeat the purpose. Instead, the place where I have hit the roadblock, in this case, the creation of a new variable type. Any help is appreciated.


In reply to Creating a unique variable type by tfredett

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.