0

My colleague forwarded me some code as below. I want to understand how symbol | operates. I have a rough idea that it is looping through NutritionData Tuple and storing unique values of food into string Foods. But is there something that I am missing? I searched for | online but wasnt able to find anything.

tuple FoodNutrition
{
    key string food;
    key string nutrient;
    float amountPerServing;
};


{FoodNutrition} NutritionData = ...;

{string} Foods = {nd.food | nd in NutritionData};
{string} Nutrients = {nd.nutrient | nd in NutritionData};
millimoose
  • 39,073
  • 9
  • 82
  • 134
user2543622
  • 5,760
  • 25
  • 91
  • 159
  • Resource recommendations are off-topic for SO. Since the rest of your question seems legitimate I just nuked the intro paragraph. – millimoose Sep 09 '13 at 22:16
  • Also, if you have a rough idea, why not verify it by running this code? – millimoose Sep 09 '13 at 22:18
  • Last but not least you might want to ask your colleague for a link to the reference for the language above, I can't really find it in the ILOG docs either. – millimoose Sep 09 '13 at 22:22
  • any idea where can i put "resource recommendation" questions? – user2543622 Sep 09 '13 at 22:27
  • i ran the code and thats how i realize that it stores only UNIQUE values. but would like to hear from experts on this site...also not sure what "{string} Foods" defines...does it define a string array? – user2543622 Sep 09 '13 at 22:28
  • Going by the sad state of the tag page for [tag:ilog], I'd say it's more likely you'll find a suitable expert at your office. Going by the notation, I'm **wildly guessing** that `{string}` is a set of strings, and the syntax you're asking about and what it does is very similar to [set-builder notation](https://en.wikipedia.org/wiki/Set-builder_notation) from mathemathics. (The unique values would be implied by the fact it's a set.) – millimoose Sep 09 '13 at 22:35

0 Answers0