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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:52:50+00:00 2026-06-13T05:52:50+00:00

Im trying to slice a matrix so that I can end up with to

  • 0

Im trying to slice a matrix so that I can end up with to arrays.
So given the following matrix [[1,2],[3,4],[102,5]] is there a way to slice it so that I end up with [1,3,102] and [2,4,5] ?

Maybe its not a slice but something else?
Thanks

  • 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-13T05:52:51+00:00Added an answer on June 13, 2026 at 5:52 am

    Try using the Array.reduce(...) method, since functional programming is cool!

    function splitMatrix(matrix) {
      return matrix.reduce(function(acc, x) {
        acc[0].push(x[0]);
        acc[1].push(x[1]);
        return acc;
      }, [[],[]]);
    }
    
    splitMatrix([[1,2],[3,4],[102,5]]); // => [[1,3,102], [2,4,5]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to create an extension that could slice any array-like class (since
I am trying to implement slice functionality for a class I am making that
I'm trying to make a function that duplicates an array of arrays. I tried
I'm trying to slice a numpy array using a slice that is predefined in
I am trying to delete both a matrix in mathematica. An inelegant way of
I'm trying to write a script that slice a layer into small peaces. It
I am trying to slice a tuple, removing the last two items. I tried
I am new to Python. Here's what I am trying to do: Slice a
I am trying to deserialize this JSON array into my android project. [{Name:Ban,Price:1},{Name:Banana,Price:1},{Name:chicken,Price:14},{Name:pizza,Price:16},{Name:slice,Price:1}] I
Eventually I'm trying to create a timed slide show that fades images in and

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.