custom operators

Jun 26, 2009 at 8:25 PM

I need to be able to do the following:

input: "MAX(4,MIN(5,6)) for 4 MIN(10,12) for 2"

output: "5 5 5 5 10 10"

where "for" indicates repeat the result of the expression for number of times indicated by the value on the right.

I know I can add custom functions like MIN and MAX but "for" in here is acting more like operator. Can I add that too? "for" is just one of the many keywords I would need to add.

Thanks for your help.

 

 

 

Coordinator
Jun 27, 2009 at 7:39 AM

You can't define operator, though you can create a for(x, t) function which would concatenate t, x times. Functions can take paramters in NCalc. There are some example in the documentation.

Coordinator
Jun 27, 2009 at 7:40 AM

Just to complete the answer, you would then be able to do something like this: for(4, MAX(4, MIN(5,6)) + for(2, MIN(10,12).

Jun 27, 2009 at 2:00 PM

thank you for your reply. I understand I will be able add "for" as function like you mention but the format is already set and I cannot change it.