Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4064594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:52:31+00:00 2026-05-20T15:52:31+00:00

I have lots of data like this type1, type2, type3 aax, ert, ddd asx,

  • 0

I have lots of data like this

type1, type2, type3
aax, ert, ddd
asx, eer, kkk
xkk, fff, lll
xxj, vtt, lle
...

and I would really like to be able to “map” between them, so I can go from

type1 -> type2
type1 -> type3
type2 -> type1
type3 -> type1

Example:

type1_to_type2(aax) should return ert
type1_to_type3(asx) should return kkk
type2_to_type3(fff) should return lll
type3_to_type1(lle) should return xxj

What data structure should be used for the data?

And how would such functions look like?

Update: All data is unique.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:52:32+00:00Added an answer on May 20, 2026 at 3:52 pm

    A version that actually implements the ‘type1_to_type2’ etc… functions.

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    my $data;
    while (<DATA>) {
      chomp;
      push @$data, [ split ];
    }
    
    sub typeX_to_typeY {
      my ($x, $y, $str) = @_;
    
      foreach (@$data) {
        if ($_->[$x - 1] eq $str) {
          return $_->[$y - 1];
        }
      }
    
      return;
    }
    
    sub type1_to_type2 { typeX_to_typeY(1, 2, @_) }
    sub type1_to_type3 { typeX_to_typeY(1, 3, @_) }
    sub type2_to_type1 { typeX_to_typeY(2, 1, @_) }
    sub type2_to_type3 { typeX_to_typeY(2, 3, @_) }
    sub type3_to_type1 { typeX_to_typeY(3, 1, @_) }
    sub type3_to_type2 { typeX_to_typeY(3, 2, @_) }
    
    # tests
    use Test::More tests => 4;
    
    is(type1_to_type2('aax'), 'ert');
    is(type1_to_type3('asx'), 'kkk');
    is(type2_to_type3('fff'), 'lll');
    is(type3_to_type1('lle'), 'xxj');
    
    __DATA__
    aax ert ddd
    asx eer kkk
    xkk fff lll
    xxj vtt lle
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a setup that looks like this. class Checker { // member data
In my code I have often situations like this: public void MyMethod(string data) {
Basically, I have lots of differently typed structs like this: typedef struct { char
I have a huge text file with lots of lines like: asdasdasdaasdasd_DATA_3424223423423423 gsgsdgsgs_DATA_6846343636 .....
I have lots and lots of data in various structures. Are there any better
I have lots of tables with statistical data (environment related) and wondering if there
I have a CSV data file with rows that may have lots of columns
I have a file containing lots of data put in a form similar to
I have a python script which outputs lots of data, sample is as below.
I have a htlm table with lots of data the user might want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.