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
and arrays again
16 posts
• Page 1 of 2 • 1, 2
and arrays again
Let say that there are two arrays:
1
2
3
4
a
b
c
d
And I'd like to get:
1 - a
2 - b
3 - c
4 - d
So it wold mean two inputs for two arrays, and custom separator " - " for formatting. How to make it in ruby? How to avoid an error, if two arrays are different in size?
1
2
3
4
a
b
c
d
And I'd like to get:
1 - a
2 - b
3 - c
4 - d
So it wold mean two inputs for two arrays, and custom separator " - " for formatting. How to make it in ruby? How to avoid an error, if two arrays are different in size?
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: and arrays again
This ones been fun tying to work out as well tester. A bit tricky though.
I did a version that works great, accounts for errors, but is string output,
not array like you need...but In the meantime, still might help...
I can see how the array output can be done...fun challenge....
I did a version that works great, accounts for errors, but is string output,
not array like you need...but In the meantime, still might help...
I can see how the array output can be done...fun challenge....
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: and arrays again
Question?
Is the '-' anything more than formatting ? If not, you show a 2D array that would then be 'the' data ... and for display purposes you could handle alignment, spacing, '-', etc, all from GUI control [even PRIMS].
Just trying to understand the need.
Is the '-' anything more than formatting ? If not, you show a 2D array that would then be 'the' data ... and for display purposes you could handle alignment, spacing, '-', etc, all from GUI control [even PRIMS].
Just trying to understand the need.
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: and arrays again
@tester:
but you need to fix the arrays before with trogs fix_array_size methode
- Code: Select all
@c= []
0.upto @a.length-1 do |i|
@c[i] = (@a[i].to_s)+"-"+(@b[i].to_s)
end
output @c
but you need to fix the arrays before with trogs fix_array_size methode
Last edited by Nubeat7 on Sun Nov 03, 2013 1:31 am, edited 1 time in total.
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: and arrays again
look at testers post again...his needs are very clear...
at the moment , tying to map em both together via loop....
EDIT:
Just saw your post..
Thanks nubeat..will have a go...
at the moment , tying to map em both together via loop....
EDIT:
Just saw your post..
Thanks nubeat..will have a go...
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: and arrays again
Green is not dead...
If it wasn't for the white-space these few primitives would do the trick nicely.
If it wasn't for the white-space these few primitives would do the trick nicely.
- Attachments
-
- closeNoCigar.fsm
- (407 Bytes) Downloaded 871 times
- strangeChild
- Posts: 47
- Joined: Sat Apr 27, 2013 8:04 pm
Re: and arrays again
tester wrote:How to make it in ruby? How to avoid an error, if two arrays are different in size?
Depends which you prefer...
- Default value adding to the "short" array.
- Take away surplus from the "long" array.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: and arrays again
This was as far as i got..
...and result...
..
nice circuit...
Thanks for the reminder of how much i miss working in green...
- Code: Select all
def event i,v
if i == 0 then
x = 0
data = Array.new
for i in 1..@a1.length do
data[x] = i = @a1.map.to_s{|x| x}+("-")+ @a2.map.to_s{|x| x}
x += 1
output 0,data
end
end
end
...and result...
- Code: Select all
#<Enumerator:0x3abce3c>-#<Enumerator:0x3abcd60>
#<Enumerator:0x3abccac>-#<Enumerator:0x3abcb80>
#<Enumerator:0x3abcb30>-#<Enumerator:0x3abcae0>
#<Enumerator:0x3abca90>-#<Enumerator:0x3abca18>
#<Enumerator:0x3abc978>-#<Enumerator:0x3abc8d8>
..
strangeChild wrote:Green is not dead...
nice circuit...
Thanks for the reminder of how much i miss working in green...
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: and arrays again
In greenery I'm doing it like this (see attachement).
I prefer to recalculate the "pool" each time it changes. I could generate one larger, once - and use "string array split", I'm aware of that, but I would have to remember about that limitation too. I'm using this one, because it's easier to adapt, depending on where it is used, and it has no limitation (less to remember - less to worry about). On the other hand - it's slower, or it adds some slowdowns when it's among others.
Now - if the pool is dynamic in size, large, formatting changes "on-the-fly" per click for some reason (don't ask me "why" - that's the part of my movie, where I'm predicting "possible scenarios"), and it's clicked often, then this one adds it's own slowdown to the whole project.
It is used for combinig display and for saving. Not for loading (in terms of processing), because items have associated indexes used separately.
*
So my original question was regarding general simplification. Combine array1 and array2, and place between them a mark with whitespaces (these are a nghtmare sometimes). Add mark with witespaces always after array1, and always before array2, while array1 and array2 may have different amounts of elements.
*
I know I'm doing it in reversed order, but just wanted to post some example. Now I will read and check what you wrote above.
I prefer to recalculate the "pool" each time it changes. I could generate one larger, once - and use "string array split", I'm aware of that, but I would have to remember about that limitation too. I'm using this one, because it's easier to adapt, depending on where it is used, and it has no limitation (less to remember - less to worry about). On the other hand - it's slower, or it adds some slowdowns when it's among others.
Now - if the pool is dynamic in size, large, formatting changes "on-the-fly" per click for some reason (don't ask me "why" - that's the part of my movie, where I'm predicting "possible scenarios"), and it's clicked often, then this one adds it's own slowdown to the whole project.
It is used for combinig display and for saving. Not for loading (in terms of processing), because items have associated indexes used separately.
*
So my original question was regarding general simplification. Combine array1 and array2, and place between them a mark with whitespaces (these are a nghtmare sometimes). Add mark with witespaces always after array1, and always before array2, while array1 and array2 may have different amounts of elements.
*
I know I'm doing it in reversed order, but just wanted to post some example. Now I will read and check what you wrote above.
- Attachments
-
- greenery.fsm
- (552 Bytes) Downloaded 878 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: and arrays again
Nubeat7 wrote:@tester:
- Code: Select all
@c= []
0.upto @a.length-1 do |i|
@c[i] = (@a[i].to_s)+"-"+(@b[i].to_s)
end
output @c
but you need to fix the arrays before with trogs fix_array_size methode
This one works reasonably fine, thanks. First array defines formatting and output size, second is just added and trimmed if it's larger. Actually this trimming might be useful too. White spaces are simply to add (" - " works).
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
16 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 78 guests