Article Preview
Buy Now
COLUMN
SetClass
Manipulating sets of strings
Issue: 18.5 (September/October 2020)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 13,868
Starting Page Number: 90
Article Number: 18506
Resource File(s):
project18506.zip Updated: 2020-08-31 22:37:40
Related Link(s): None
Excerpt of article text...
Recently I received an email from "Paul," who had a question about working with sets. In part he wrote:
Let's say I'm looking for five-character words from a list of five-character words with the condition that each of the five letters are restricted to their own set of candidate letters. So the first letter could only be a T, R, P, or M. The second letter could only be a R, K, P, or B, etc. Any words selected from the list would satisfy the condition that the letter in each position of the word is contained in the set of letters for that position. This requires the ability to create a set of letters or numbers and later be able to add or subtract from that set. Then determine if a "candidate" matches the letters/numbers in the set.
I can see doing this with arrays but I wondered if there were "set functions" that would be more efficient in creating/editing the sets and making comparisons. Like the next step would be to compare two sets and return only select letters/numbers common to both sets.
...End of Excerpt. Please purchase the magazine to read the full article.