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 9120963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:44:58+00:00 2026-06-17T05:44:58+00:00

Essentially I have the task of writing two methods: a zip method that turns

  • 0

Essentially I have the task of writing two methods: a zip method that turns a generic tuple containing two lists of generic objections into a list of tuples made up of elements of the aforementioned lists, and an unzip method that does the same thing in the other direction. I.e.:

({1, "banana", true}{asgard, 5.21e, "stupidhomework"})
=> unzip
{(1, asgard)("banana",5.21e)(true,"stupidhomework")}
=> zip
({1, "banana", true}{asgard, 5.21e, "stupidhomework"})

Further complicating this: the list is a simply linked immutable generic list with the structure

List<T>
public final T       head;
public final List<T> tail;

…And the tuples are equally generic; both elements of the tuple can be literally anything:

public class Tuple<A, B> {
public final A a;
public final B b;

So here’s my problem: I have no idea how to get at elements a second layer down. For example, normally, I’d just do this-

   public static<A, B extends List> List unzip(Tuple<A, B> ListenTuple){
        List TupelnListe = new List(new Tuple(ListenTuple.a.head, ListenTuple.b.head));

-To get at the elements I need, two layers down. Unfortuantely, because Tuple is generic, it doesn’t know that ListenTuple.a has to be a List, and therefore has a head. The analogous problem arises in zip with getting at a and b from the tuple. Oh, and I’m not allowed to typecast for some stupid arbitrary reason, although I’m not sure how that would help me.

…Basically, can anyone give me a pointer on how to get this started? They basically threw us into generics in class this week, and nobody gets it. Any assistance would be much appreciated.

  • 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-06-17T05:45:00+00:00Added an answer on June 17, 2026 at 5:45 am

    Would this work?

    public static<A, B> List zip(Tuple<List<A>, List<B>> ListenTuple){
    

    So that A and B are the elements of the list and a, b are now lists.

    I am more familiar with C++ so am not sure if the differences prevent this somehow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So essentially I have two tables, containing URLS and TAGS, with a has-and-belongs-to-many relationship
Essentially I have a script which acts as a task wrapper and emails a
Essentially I have a method of a class called killProgram, which is intended to
I have two essentially separate applications for configuring two pieces of hardware sold by
so essentially I have the task to learn matlab decently well in the next
I have written a windows service in C# that essentially listens for commands on
I have an org-mode task list that I keep in version control. I would
I have a task: To make a database model with essentially 'student' and 'group'.
I am currently trying to find a solution to this task. Essentially I have
I have a package that sends out two emails whenever a control flow element

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.