If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
two things array/ruby related
43 posts
• Page 2 of 5 • 1, 2, 3, 4, 5
Re: two things array/ruby related
RJHollins wrote:not to distract from the OP ... and thanks for the examples TROG ...
but I've been trying to figure out how to change the output of the RUBY box from the proper ARRAY display:["1", "a", "X"]
to one that is 'clean' .... 1 a X
or
1
a
X
I'm thinking the array is extracted into a string format. But I more familliar using PRIMS and still easily confused with RUBY. [need more practise ]
Thanks for info!
use stringarray output for the second example and .join(',') for the first one
you also could add .gsub(/\,/,"") to also remove the commas
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: two things array/ruby related
.gsub(/\,/,"")
that's the one I keep forgetting about ...
I actually need to write this on paper to remember it .... and my name
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: two things array/ruby related
or you put this site in your favourites http://ruby-doc.org/core-2.0.0/String.h ... hod-i-gsub
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: two things array/ruby related
Thanks for the input Trog...
I got first example ok....but the 'nesting' one is killing me all morning...
The nesting example data for 3 arrays is structured like this....
["1/2/3", "a/b/c", "X/Y/Z"]
If i input 1 array it is structured like this
["1","2","3"]...
how can i make this method work using "real" inputs...?
and i can't seem to re-define the split....
should i be re-structuring the arrays(join,insert..ect,ect) till I get
a line of text that looks like ["1/2/3", "a/b/c", "X/Y/Z"]...?
Or is another method???
So it's currently...
my_array = ["1/2/3", "a/b/c", "X/Y/Z"]
I want to basicly...
my_array = [@a1, @a2, @a3]
somehow.. ..and get result..
I got first example ok....but the 'nesting' one is killing me all morning...
The nesting example data for 3 arrays is structured like this....
["1/2/3", "a/b/c", "X/Y/Z"]
If i input 1 array it is structured like this
["1","2","3"]...
how can i make this method work using "real" inputs...?
and i can't seem to re-define the split....
should i be re-structuring the arrays(join,insert..ect,ect) till I get
a line of text that looks like ["1/2/3", "a/b/c", "X/Y/Z"]...?
Or is another method???
So it's currently...
my_array = ["1/2/3", "a/b/c", "X/Y/Z"]
I want to basicly...
my_array = [@a1, @a2, @a3]
somehow.. ..and get result..
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: two things array/ruby related
I found the issue i had...
If arrays are not the same size exception is raised....
This works fine ifarrays are same size....
If arrays are not the same size exception is raised....
This works fine ifarrays are same size....
- Code: Select all
a = [@a]+[@b]
b = a.transpose
column = b[0]
output 0,column
BV MUSIC SYDNEY AUSTRALIA..Songwriting and Software development
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
Headquartershttps://www.bvmusicsydneyaustralia.com/
Spotifyhttps://open.spotify.com/artist/7JO8QM40mVmHb7pAwKPJi0
Donatationhttps://www.paypal.com/donate/?hosted_button_id=HEUR8R7K8GZ4L
- billv
- Posts: 1157
- Joined: Tue Aug 31, 2010 3:34 pm
- Location: Australia
Re: two things array/ruby related
I'm starting to understand less and less from these chats...
Module examples are more helpful.
Let me clarify. "Get rows at list of indexes" will look like this I suppose, yes? And rows must not contain commas as a separators in order to work correctly, yes?
BTW, I see that in ruby you can use inputs by @names. What about named outputs?
Module examples are more helpful.
Let me clarify. "Get rows at list of indexes" will look like this I suppose, yes? And rows must not contain commas as a separators in order to work correctly, yes?
BTW, I see that in ruby you can use inputs by @names. What about named outputs?
- Attachments
-
- get-rows.fsm
- (453 Bytes) Downloaded 807 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: two things array/ruby related
trogluddite wrote:You're on the right track - but you need an array where each row is itself an array - i.e. nested array structure. So the string for each row will need converting to array form...
- Code: Select all
my_array = ["1/2/3", "a/b/c", "X/Y/Z"]
# Convert rows into sub-arrays
nested_array = my_array.map do |row|
row.split('/')
end
# You now have a nested array...
# [ ["1","2","3"], ["a","b","c"], ["X","Y","Z"] ]
# Now transpose so that columns become rows and vice versa
transposed_array = nested_array.transpose
# transposed array will now be
# [ ["1","a","X"], ["2","b","Y"], ["3","c","Z"] ]
# Get a column
column = transposed_array[0] #=> ["1", "a", "X"}
I don't get that one. Could you upload it as a module with text connected on input?
- Attachments
-
- get-columns.fsm
- (674 Bytes) Downloaded 817 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: two things array/ruby related
Okay, I managed that one, I guess.
Two things that are bothering me:
1) ruby window tend to show errors even if there are no errors (some sort of refreshing issue).
2) I see, that I tend to use names that are reserved for something.
Two things that are bothering me:
1) ruby window tend to show errors even if there are no errors (some sort of refreshing issue).
2) I see, that I tend to use names that are reserved for something.
- Attachments
-
- get-columns.fsm
- (520 Bytes) Downloaded 834 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: two things array/ruby related
tester wrote:
BTW, I see that in ruby you can use inputs by @names. What about named outputs?
- Code: Select all
output 'myOutputName', value
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: two things array/ruby related
One thing regarding "get column" module. How to fill the array with nils, so that it will not produce an error, if some rows have less values?
Like this:
aaa/111/v/5
bbb/222/b/6
ccc/n
Third row is shorter by 2 items, thus it should end like this:
ccc/n//
Like this:
aaa/111/v/5
bbb/222/b/6
ccc/n
Third row is shorter by 2 items, thus it should end like this:
ccc/n//
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
43 posts
• Page 2 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 25 guests