I have another question.

There is a procedure
    
    
    proc fold*[T, S](arr: seq[T], init: S, op: proc(acc: S, v: T): S): S =
      for x in arr:
        init = op(init, x)
      return init
    

How to implement in Nim this function (Javascript): 
    
    
    function applyAllSync(funcs, onAllDone) {
        return fold(funcs, (function(onDoneNothing) {
            return onDoneNothing;
        }), (function(doBefore, func) {
            return (function(onDone) {
                return doBefore((function() {
                    return func(onDone);
                }));
            });
        }))(onAllDone)();
    };
    

Reply via email to