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
min/max filtering (array)
18 posts
• Page 2 of 2 • 1, 2
Re: min/max filtering (array)
Tronic wrote:array = [-1,0.0,90,50,100,150,200]
min = 0.0 ;
max = 100 ;
(array.map {|v| (min..max) === v ? v : nil }).compact
smart! already met the "case equality operator" few times, but never knew where/how to use..
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: min/max filtering (array)
billv wrote:I still can't get a result from this...
- Code: Select all
def event i,v
if i == 0 then
minVal = 0.5
maxVal = 1
a = @txt.map{|item|item*maxVal-minVal+minVal}
output 0,a
end
end
watch this thread, trog explains the correct methode there..
viewtopic.php?f=3&t=1760
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: min/max filtering (array)
I see I opened a headache maker.
Posting schematized ("green prims" compatible so to speak) idea provided by Tronic, in case someone with my (equall-or-less)skills looks for such thing.
Seems to work fine, and looks elegant. Thanks!
Posting schematized ("green prims" compatible so to speak) idea provided by Tronic, in case someone with my (equall-or-less)skills looks for such thing.
Seems to work fine, and looks elegant. Thanks!
- Attachments
-
- in-min-max-range.fsm
- (449 Bytes) Downloaded 779 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: min/max filtering (array)
i think a combination of tronics version and mine would be the shortest and fastest
i`m @ work, so not tested
- Code: Select all
output @yourarray.keep_if{|x|(min..max) === x}
i`m @ work, so not tested
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: min/max filtering (array)
Nubeat7 wrote:i think a combination of tronics version and mine would be the shortest and fastest
- Code: Select all
output @yourarray.keep_if{|x|(min..max) === x}
i`m @ work, so not tested
This break the result of array if the next value not match the min/max range.
- Tronic
- Posts: 539
- Joined: Wed Dec 21, 2011 12:59 pm
Re: min/max filtering (array)
Tronic wrote:Nubeat7 wrote:i think a combination of tronics version and mine would be the shortest and fastest
- Code: Select all
output @yourarray.keep_if{|x|(min..max) === x}
i`m @ work, so not tested
This break the result of array if the next value not match the min/max range.
hmm strange i tried it here:
http://www.compileonline.com/execute_ruby_online.php
- Code: Select all
array = [5,1,3,4,1,6,7,8,9]
array.keep_if{|x|(2..7) === x}
puts array;
and it puts:
5
3
4
6
7
so it shoul be right?
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: min/max filtering (array)
Yes work
sorry, mistake in my testing.
sorry, mistake in my testing.
- Tronic
- Posts: 539
- Joined: Wed Dec 21, 2011 12:59 pm
Re: min/max filtering (array)
Nubeat7 wrote:watch this thread, trog explains the correct methode there..
...seems he saw similar issue...all good....thanks
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
18 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: Google [Bot] and 98 guests