functional programming in Synergy/DE

Posted by HippieHunter Thu, 18 Dec 2008 17:46:00 GMT

 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.Collections
namespace 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

  1. Casino 1249878273 Casino 1249878273
    Casino 1249878273

Comments

Leave a comment