Page 1 of 2

ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 6:05 pm
by tester
How to make ifthenelse for arrays in ruby?

-> Input array
-> equals
-> conditions array
-> things to send to output

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 6:10 pm
by Tronic

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 6:13 pm
by Tronic

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 6:13 pm
by tester
...arrays...

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 6:15 pm
by Tronic

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 6:19 pm
by Tronic

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 6:22 pm
by tester
I just would like to simplify this.

Basically there will be few of such units, each for different comparator. This is for splitting a list of strings according to numeric parameter placed within these strings.

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 6:28 pm
by Tronic
can you post a logical example of what you want?

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 7:10 pm
by TheOm
You could use group_by.

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 8:53 pm
by tester
Hi @TheOm.

Your solution still refers to ranges. I'd like to compare the input array to single element (what I posted above was unmodified module, that operates on ranges). Or rather...

@Tronic.

Simple case scenario. Let say that I have an array:

a
a
b
a
c
b
c

Concept:
Produce arrays of indexes that refer to specific values.

indexes @a
0
1
3

indexes @b
2
5

indexes @c
4
6

indexes @N
...
...

*

I'm still defining the concept, but I hope I made this one clear this time. :-)