I use this:
on visualizzamatrix mat
#this visualize a bidimensional matrix like A x B
#rows
put the keys of mat into temp
sort lines of trow ascending numeric by word 1 of each #keys are random sometime
put the last line of temp into rows
#columns
put the keys of mat[1] into temp
sort lines of temp ascending numeric by word 1 of each #keys are random sometime
put the last line of temp into cols
# let's creat a simple text file
put empty into tmat
repeat with i = 1 to rows
repeat with j = 1 to cols
put mat[j] & "" after tmat
end repeat
put return after tmat
end repeat
answer tmat
end visualizzamatrix
Is it ok for you?
How to retrieve a column array from a 2-D array?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: How to retrieve a column array from a 2-D array?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: How to retrieve a column array from a 2-D array?
I still don't get it how I can retrieve a ROW from the 2D array. Any help there? How can we edit the function for GetArrayColumn to create a function GetArrayRow? Rows do not have names -;)
-
- VIP Livecode Opensource Backer
- Posts: 9579
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to retrieve a column array from a 2-D array?
Hi.
Old thread.
Arrays in LC are not really built the way you are asking. That is, if I actually understand what you are asking. So let's say you have the following dataSet:
Craig
Old thread.
Arrays in LC are not really built the way you are asking. That is, if I actually understand what you are asking. So let's say you have the following dataSet:
In plain English, assuming we had this in some form of array, what do you want out of, say, row 2? Is it:1,dog,friend
2,cat,foe
3,bird,nuisance
4,duck,dinner
??dog
cat
bird
duck
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9579
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: How to retrieve a column array from a 2-D array?
Looking back over the thread, I see this by Sri (breakpoint by me):
At the breakpoint, you have "built" an array where elements has been assigned to certain "locations" for each key. Perhaps you can say which elements would comprise the "row" that you are trying to extract?
Craig
Code: Select all
on mouseUp
put "blue" into a[1][1]
put "green" into a[2][1]
put "yellow" into a[3][1]
put "red" into a[4][1]
put "lemon" into a[1][2]
put "orange" into a[2][2]
put "peach" into a[3][2]
put "pineapple" into a[4][2]
breakpoint
end mouseUp
Craig