Yes it is possible to do the basics of functional programming in Synergy. It is missing some of the conveniences of C++ or ML but still it works. sometime in the future I will explain how this is useful to the average user.
import System.Collectionsnamespace functor ;;; <summary> ;;; The main entry point for the application. ;;; </summary> main record al, @ArrayList ii, int proc al = new ArrayList() for ii from 0 thru 100 begin data iii, @int iii = (@int)ii al.add(iii) end open(1, o, "tt:") for_each.Call(al, new MyFunctor()) endmain class for_each public static method Call, void al, @ArrayList func, @SimpleIntFunctor endparams record ii, int proc for ii from 0 thru al.Count - 1 begin func.Call((int)al[ii]) end endmethod endclass abstract class SimpleIntFunctor public abstract method Call, void i, int proc endmethod endclass class MyFunctor extends SimpleIntFunctor public override method Call, void i, int proc writes(1, %string(i)) endmethod endclass endnamespace
Trackbacks
Use the following link to trackback from your own site:
http://www.archverse.com/typo/trackbacks?article_id=9
-
Casino 1249878273