This is to help people like me who can't remember how to get the column list of a 2 dimensional matrix
Every now and then, I need to get all the items in a column in a matrix and I spend from 5 to 15 minutes trying to remember the syntax - I think this could do with an explicit block in the list utilities library
I think it would especially be helpful to young learners - the more complicated stuff on page 20 of the manual would still be there for anyone who needs to do more
This is what I came up with today (which obviously could do with improvement)
We can't use blocks from the APL library in the List Utilities library... I would just do
MAP (ITEM 1 OF _) OVER the-list.
So as to not pollute a galaxy far, far away I'd like to return to this topic in the forum
The way I look at it is - we have the
block for fetching an item in a list
And when the list is a 2D matrix - it returns a row from the matrix.
All good - all well - simple to understand
BUT, if we want to extract a column from a matrix we have to use
which is explained in the manual but is not intuitive syntax- well not to me anyway
So my original request was to have an addition to the List library (so as not to clutter up the standard blocks) that looks like this
Now there has been some discussion on this on Github but it doesn't look as if a simple column reporter block is going to be part of Snap! primitives so I'm re-requesting that it be included in the List library
This request comes about from my recent experiences in the Advent of Code puzzles - a lot of which require 2D (or even 3 and 4D matrix operations)
Although extracting 1 column using map isn't too bad - I think an explicit column reporter comes into i's own when more than 1 column is required
I'll rest my case at this point
I'm not against COLUMN in the library, but you say
and COLUMN won't help for that. What you want is something like
where the first input is an item number or list of item numbers, the second is which dimension (1=row, 2=column, etc.), and the last one is the data.
Jens and I have had a flurry of emails in the past couple of days about how to handle multi-dimensional arrays. Give us a while to work it out.
Don't let my 3D/4D comment detract from my simple request
just use hyperblocks,
returns the 2nd and 3rd columns of the list.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.