1. Looking up a person's name, given personnel number
- Posted by Swifty Jun 07, 2012
- 1122 views
I have a file where each line contains a personnel number, and a name. In this context, a "number" can contain upper-case letters as well. So, one line might be:
ABC123 Steve Swift
How should I store this data such that I can deduce the name, if all I know is that Persnum='ABC123' ?
I'm not asking for the mechanism whereby I read the file, presumably that is simple, it is the actual data storage in memory that interests me. I think that I'm asking for a "hash" mechanism, but I was off sick the day they taught about hashes in my schooldays "Computer Science" class.
Please excuse me if I've ridden roughshod over Euphoria terms here. I'm a rank beginner.
2. Re: Looking up a person's name, given personnel number
- Posted by mattlewis (admin) Jun 07, 2012
- 1131 views
I have a file where each line contains a personnel number, and a name. In this context, a "number" can contain upper-case letters as well. So, one line might be:
ABC123 Steve Swift
How should I store this data such that I can deduce the name, if all I know is that Persnum='ABC123' ?
I'm not asking for the mechanism whereby I read the file, presumably that is simple, it is the actual data storage in memory that interests me. I think that I'm asking for a "hash" mechanism, but I was off sick the day they taught about hashes in my schooldays "Computer Science" class.
Take a look at the standard library implementation of maps. It uses euphoria's built in hash functionality.
Matt
3. Re: Looking up a person's name, given personnel number
- Posted by Swifty Jun 07, 2012
- 1097 views
I have a file where each line contains a personnel number, and a name. In this context, a "number" can contain upper-case letters as well. So, one line might be:
ABC123 Steve Swift
How should I store this data such that I can deduce the name, if all I know is that Persnum='ABC123' ?
I'm not asking for the mechanism whereby I read the file, presumably that is simple, it is the actual data storage in memory that interests me. I think that I'm asking for a "hash" mechanism, but I was off sick the day they taught about hashes in my schooldays "Computer Science" class.
Take a look at the standard library implementation of maps. It uses euphoria's built in hash functionality
Thanks!