Runtime evaluation: Difference between revisions
Content added Content deleted
(Added JavaScript example) |
(eliminate unneeded parenthesis from J "evaluate with argument" example, clean up description) |
||
Line 228: | Line 228: | ||
<lang j>". 'a =: +/ 1 2 3' NB. execute a string to sum 1, 2 and 3 and assign to noun a</lang> |
<lang j>". 'a =: +/ 1 2 3' NB. execute a string to sum 1, 2 and 3 and assign to noun a</lang> |
||
Only expressions are allowed as arguments for <code>".</code> |
Only J expressions are allowed in strings used as as arguments for <code>".</code> (control words and blocks of expressions are not allowed). |
||
Alterntively, you can use the conjunction [http://www.jsoftware.com/help/dictionary/d310n.htm <code>:</code>] (''Explicit Definition'') to create various kinds of functions and evaluate them. Arguments have names, such as "y", which are specified by the language definition. For example: |
|||
<lang j> |
<lang j>monad :'+/y' 1 2 3</lang> |
||
⚫ | |||
⚫ | |||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
<lang lua>f = loadstring(s) -- load a string as a function. Returns a function. |
<lang lua>f = loadstring(s) -- load a string as a function. Returns a function. |