Page 2 of 2

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 9:27 pm
by TheOm
What do you mean by ranges? It works for strings too:

Re: ifthenelse for arrays in ruby?

Posted: Fri Jul 18, 2014 9:46 pm
by tester
Thanks!

By ranges - let say that I'm not a good rubyist. :mrgreen:

Re: ifthenelse for arrays in ruby?

Posted: Sat Jul 19, 2014 12:33 am
by tester
Small problem. If I change the input type from "string array" into "int array" - ruby module no longer works (empty ouptuts). Can this be fixed, so that there is no need to use text primitive between nodes?

Re: ifthenelse for arrays in ruby?

Posted: Sat Jul 19, 2014 1:26 am
by Tronic
you mean this?

Re: ifthenelse for arrays in ruby?

Posted: Sat Jul 19, 2014 1:56 am
by tester
Yes, thanks.

Re: ifthenelse for arrays in ruby?

Posted: Sat Jul 19, 2014 2:04 am
by RJHollins
Tronic wrote:you mean this?

haven't checked the fsm ... but the file title gave a chuckle
:lol:

Re: ifthenelse for arrays in ruby?

Posted: Sat Jul 19, 2014 2:35 am
by tester
It took me two minutes to realize the difference. Quotation marks. :-)

I'm in the middle of heavy brainstorming. Creating a cookbook according to TCM - yet another unusual application of FS. (yep, I hear these voices - definately with x64 cooking would be 2x faster :mrgreen:).

Re: ifthenelse for arrays in ruby?

Posted: Tue Jul 29, 2014 11:58 pm
by tester
I have one more thing.
I'd like to convert one bigger array according to rules stored in two smaller arrays. Like this.

input array:
el1
el2
el3
el1
el3

contitions arrays ("=" separated to make it more readable; can be in two independent text files or like this):

el1=element1
el2=element2
el3=somethingelse
el4=andsomethingelsemore

output would be then like this:

element1
element2
element3
element1
element3

How?

Re: ifthenelse for arrays in ruby?

Posted: Wed Jul 30, 2014 12:43 am
by TheOm
Combine your condition arrays into a Hash.
Then map the input array to the output using that Hash.

Re: ifthenelse for arrays in ruby?

Posted: Wed Jul 30, 2014 5:15 pm
by tester
Thank you!