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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:45:43+00:00 2026-06-10T06:45:43+00:00

I have a 2×3 array a =. 2 3 $ 2 3 a 2

  • 0

I have a 2×3 array

a =. 2 3 $  2 3
   a
2 3 2
3 2 3

And I want to add all the elements together using +/ to get 15.

So

+/a
5 5 5

Hmmm. This is clearly adding columns. I know that +/ rank is _ _ _ (i.e. infinity) and a is rank 2. I can’t translate this into imagining why it adds columns, unfortunately. (I am reading “J for C Programmers”)

So just for fun I did:

+/"1 a
7 8

So now it’s adding rows. Clearly I changed the rank of +/ to 1, which is less then 2 (the rank of a) which means… I don’t know. Why am I now adding rows by switching form infinity to 1?

What about

+/"0 a
2 3 2
3 2 3

So now we are just adding single cells with nothing so we get an array equal to the original a. Again I don’t know why, although I can just about muddle through an argument to get here: verb rank is less than a (the noun) rank, so we use this value, which is zero, so we add 0-cells, ie. we add each cell in turn individually.

And once more for luck:

+/"2 a
5 5 5

And I’m adding columns again. I don’t know the mechanism which is choosing which rows/columns/cells get added as the verb rank is changed. We’re adding columns but form my point of view, we could just as easily be adding rows.

I would like this explained if possible. As I said I’m reading some literature but I’m still finding it tough.

  • 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-10T06:45:45+00:00Added an answer on June 10, 2026 at 6:45 am

    When you have an n-array, you can access each nesting “level” using the appropriate rank.

    Ranks/shapes of a NOUN

    First you have atoms (rank 0):

    a =: 1
    

    their shape ($a) is empty.

    Then you have lists (rank 1), which are just some atoms put together:

    b =: a,a,a
    b =: 3 # a
    b =: 3 $ a
    

    their shape ($b) is the length of the list.

    $b
    3
    

    Then, tables (rank 2): lists put together (stiched or otherwise):

    c =: b,.b,.b
    

    their shape is a 2 item list: rows, columns.

    $c
    3 3
    

    Then, up to rank-n array (rank n).

    Rank of a VERB

    The rank of a verb is a somewhat different story. It’s the rank on which the verb will apply. So, when you box-0 (<"0) a noun, you always box the atoms of this noun, when you box-1 (<"1), you always box the lists of the noun, etc. Eg:

     ]n =: 2 3 4 $ i.24
     0  1  2  3
     4  5  6  7
     8  9 10 11
    
    12 13 14 15
    16 17 18 19
    20 21 22 23
    

    0-rank:

    <"0 n
    ┌──┬──┬──┬──┐
    │0 │1 │2 │3 │
    ├──┼──┼──┼──┤
    │4 │5 │6 │7 │
    ├──┼──┼──┼──┤
    │8 │9 │10│11│
    └──┴──┴──┴──┘
    
    ┌──┬──┬──┬──┐
    │12│13│14│15│
    ├──┼──┼──┼──┤
    │16│17│18│19│
    ├──┼──┼──┼──┤
    │20│21│22│23│
    └──┴──┴──┴──┘
    

    1-rank:

      <"1 n
    ┌───────────┬───────────┬───────────┐
    │0 1 2 3    │4 5 6 7    │8 9 10 11  │
    ├───────────┼───────────┼───────────┤
    │12 13 14 15│16 17 18 19│20 21 22 23│
    └───────────┴───────────┴───────────┘
    

    2-rank:

     <"2 n
    ┌─────────┬───────────┐
    │0 1  2  3│12 13 14 15│
    │4 5  6  7│16 17 18 19│
    │8 9 10 11│20 21 22 23│
    └─────────┴───────────┘
    

    3 rank:

     <"3 n
    ┌───────────┐
    │ 0  1  2  3│
    │ 4  5  6  7│
    │ 8  9 10 11│
    │           │
    │12 13 14 15│
    │16 17 18 19│
    │20 21 22 23│
    └───────────┘
    

    In this example, ranks higher than 3 are the same as 3.

    You can also use negative ranks, btw, which count backwards from the highest rank.

    You can also mix the ranks.

    Summing

    You can see now, how changing the rank of +/, changes the result of the summation. For example, +/"1 sums every rank-1 list:

        <"1 n
    ┌───────────┬───────────┬───────────┐
    │0 1 2 3    │4 5 6 7    │8 9 10 11  │
    ├───────────┼───────────┼───────────┤
    │12 13 14 15│16 17 18 19│20 21 22 23│
    └───────────┴───────────┴───────────┘
       +/"1 n
     6 22 38
    54 70 86
    

    To sum a rank-n array you have to perform n +/s:

    (+/^:3) n
    276
    +/+/+/ n
    276
    

    or you can ravel (,) the array before summing:

    +/,n
    276
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a php question. I have an array of arrays: Array ( [1]
I have a php array like this: [ ['url_id' => 2191238, 'time_spent' => 41],
I have a TV named Kategorie and I want a list of all resources
Actually i have a shopping cart and i want to add a delete an
I have an array and I need to truncate this array down to only
I have two arrays which I want to join together. I want to preserve
I have an array that store data. If I subtract two arrays I get
I have an array char[] Select = {'A','B','C','D','E','F','G','H','I','J'} and each element in this array
I have an array in php like this : Array ( [0] => Array
Have dict like: mydict= {'a':[],'b':[],'c':[],'d':[]} list like: log = [['a',917],['b', 312],['c',303],['d',212],['a',215],['b',212].['c',213],['d',202]] How do i

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.