python-simple2.ecl 382 B

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