Getting started with Script.apex
Evaluating with Context
Pass the context in and we can evaluate using the variables inside.
Map context = new Map{
'list' => new List{ 'a' },
'map' => new Map{ 'name' => 'b'}
};
Object result = ScriptEngine.getInstance().eval('list[0] + map.name', context);