Extracting a sub array from an array

Extracting a sub array from an array

by Rafi Shikler -
Number of replies: 2

Hi all,

I am working with stack and I've created the following array arr:a,b,c],[d,e,f],[g,h,k;

I know how to extract just first elements using maplist(first, arr); or similar expression for the second. but how to get the following array:

sub_arr:a,b],[d,e],[g,h;

The motivation is to use the first two elements in each line for a MCQ and the last one for the creation of graphs for each choice.

Thanks in advance,


Rafi

Average of ratings: -
In reply to Rafi Shikler

Re: Extracting a sub array from an array

by Christopher Sangwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Rafi,

I don't really use arrays.  I just use matrices instead.  Is there something else I should know about arrays (I don't pretend to know everything about Maxima yet...)

Did you checkout Maxima's "submatrix" command?  I find it is very useful to use WxMaxima as a desktop application to play around.

M1:matrix([a,b,c],[d,e,f],[g,h,k]);
M2:submatrix(M1,3);

Chris


In reply to Christopher Sangwin

Re: Extracting a sub array from an array

by Stephan Bach -
I'm often using lists and I'm quite happy with this. If you are working with lists you can use: sublist1: map(lambda([a],[first(a),second(a)]), list1);.
Stephan