javascript-simple2.ecl 395 B

123456789101112131415161718192021
  1. import Javascript;
  2. /*
  3. This example illustrates and tests the use of embedded JavaScript.
  4. In this example the javascript that is embedded is more complex, including a definition of a function
  5. */
  6. string anagram(string word) := EMBED(Javascript)
  7. function anagram(word)
  8. {
  9. if (word == 'cat')
  10. return 'act';
  11. else
  12. return word;
  13. }
  14. anagram(word)
  15. ENDEMBED;
  16. anagram('dog');
  17. anagram('cat');