001
002
003 package lrs.visitor;
004
005 import lrs.*;
006
007 public class LRSSum implements IAlgo{
008 public static LRSSum Singleton = new LRSSum();
009
010 private LRSSum() { }
011
012 public Object emptyCase(LRStruct host, Object... param) {
013 return 0;
014 }
015
016 public Object nonEmptyCase(LRStruct host, Object... param) {
017 return (Integer) host.getFirst()+ (Integer)host.getRest().execute(this);
018 }
019 }