ifthenelse for arrays in ruby?

For general discussion related FlowStone
TheOm
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: ifthenelse for arrays in ruby?

Post by TheOm »

What do you mean by ranges? It works for strings too:
Attachments
Schematic1_new.fsm
(594 Bytes) Downloaded 971 times
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: ifthenelse for arrays in ruby?

Post by tester »

Thanks!

By ranges - let say that I'm not a good rubyist. :mrgreen:
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: ifthenelse for arrays in ruby?

Post 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?
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: ifthenelse for arrays in ruby?

Post by Tronic »

you mean this?
Attachments
battle_tester_vs_ruby.fsm
(602 Bytes) Downloaded 1005 times
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: ifthenelse for arrays in ruby?

Post by tester »

Yes, thanks.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
RJHollins
Posts: 1573
Joined: Thu Mar 08, 2012 7:58 pm

Re: ifthenelse for arrays in ruby?

Post by RJHollins »

Tronic wrote:you mean this?

haven't checked the fsm ... but the file title gave a chuckle
:lol:
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: ifthenelse for arrays in ruby?

Post 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:).
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: ifthenelse for arrays in ruby?

Post 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?
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
TheOm
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: ifthenelse for arrays in ruby?

Post by TheOm »

Combine your condition arrays into a Hash.
Then map the input array to the output using that Hash.
Attachments
hash.fsm
(459 Bytes) Downloaded 990 times
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: ifthenelse for arrays in ruby?

Post by tester »

Thank you!
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Post Reply