6 |
import gzz.*; |
import gzz.*; |
7 |
import gzz.potion.*; |
import gzz.potion.*; |
8 |
|
|
9 |
public class Step implements Function { |
public class Step extends AbstractHead implements Function { |
10 |
|
|
11 |
public List evaluate(List[] params, Map context) { |
public Step() { |
12 |
|
super(new Object[] { |
13 |
|
"The cell ", Types.COUNT, " steps ", Types.DIR, " of ",Types.CELL, |
14 |
|
}); |
15 |
|
} |
16 |
|
|
17 |
|
public List evaluate(List[] params, Map context) { |
18 |
|
|
19 |
List result = new ArrayList(); |
List result = new ArrayList(); |
20 |
|
|
21 |
for(Iterator i = params[0].iterator(); i.hasNext();) { |
for(Iterator i = params[0].iterator(); i.hasNext();) { |
22 |
Integer n = (Integer)i.next(); |
Integer n = (Integer)i.next(); |
23 |
|
|
24 |
for(Iterator j= params[1].iterator(); j.hasNext();) { |
for(Iterator j= params[1].iterator(); j.hasNext();) { |
25 |
Direction dir = (Direction)j.next(); |
Direction dir = (Direction)j.next(); |
26 |
|
|
27 |
for(Iterator k = params[2].iterator(); k.hasNext();) { |
for(Iterator k = params[2].iterator(); k.hasNext();) { |
28 |
Cell c = (Cell)k.next(); |
Cell c = (Cell)k.next(); |
29 |
|
|
30 |
if(dir.dir >= 0) |
if(dir.dir >= 0) |
31 |
result.add(c.s(dir.dim, n.intValue())); |
result.add(c.s(dir.dim, n.intValue())); |
32 |
else |
else |
33 |
result.add(c.s(dir.dim, -n.intValue())); |
result.add(c.s(dir.dim, -n.intValue())); |
|
} |
|
|
} |
|
34 |
} |
} |
35 |
return result; |
} |
36 |
} |
} |
37 |
|
return result; |
38 |
|
} |
39 |
|
|
|
public String getString(Expression[] params, Map context) { |
|
|
String s = params[0].getString(context); |
|
|
String t = params[1].getString(context); |
|
|
String u = params[2].getString(context); |
|
|
return "the cell "+s+" steps "+t+" of "+u ; |
|
|
} |
|
|
|
|
|
public void render(Expression[] params,Map context, HChain into) { |
|
|
} |
|
|
|
|
|
public Type[] getParams() { |
|
|
return null; |
|
|
} |
|
40 |
} |
} |