Runtime evaluation: Difference between revisions

No edit summary
Line 12:
===Using a String to represent code===
<lang lisp>(eval (read-from-string "(+ 4 5)")) ; Evaluate the program (+ 4 5)</lang>
 
=={{header|Groovy}}==
This program evaluates the Groovy program solution to the "[[Yuletide Holiday]]" task:
<lang Groovy>
new GroovyShell().evaluate '''
inFormat = new java.text.SimpleDateFormat("yyyy-MM-dd")
checkFormat = new java.text.SimpleDateFormat("EEE")
result = []
(2008..2121).each {
Date date = inFormat.parse("${it}-12-25")
if (checkFormat.format(date) == "Sun") result.add it
}
print result
'''
</lang>
 
Output:
<pre>[2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118]</pre>
Anonymous user