Skip to content

Commit

Permalink
added a new Functional.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kray-G committed Mar 5, 2021
1 parent 9722c23 commit 5d3189f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
25 changes: 24 additions & 1 deletion lib/std/kxfunctional.kx
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,27 @@ _function _functional_enumerator(e) {
};
}

Functional.enumerable = Functional.Enumerator.create = _functional_enumerator;
Functional.methodMissing = _function(_instance, method, ...a) {
Functional[method] = _function(...args) {
return _function(obj) {
return obj[method](...args);
};
};
return Functional[method](...a);
};

// The methods in Array such as `map` have to be assigned to this object
// because Array.map will have been called directly instead of this.map
// and methodMissing will not be called.
Array.keySet(Array).filter({ => Array[_1].isFunction }).each { &(method)
Functional[method] = _function(...args) {
return _function(obj) {
return obj[method](...args);
};
};
};

Functional.enumerable
= Functional.Enumerator.create
= _functional_enumerator
;
10 changes: 5 additions & 5 deletions lib/std/kxstartup.kx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ var Xml, Net;
Net = _import('kxnet');
SQLite = _import('kxsqlite');
Debugger = _import('kxdebugger');
using kxsysutil;
using kxstring;
using kxarray;
using kxbinary;
using kxnumeric;
using kxisolate;
using kxexception;
using kxsqlite;
using kxxml;
using kxnet;
using kxenumerable;
using kxfunctional;
using kxsysutil;
using kxstring;
using kxarray;
using kxbinary;
using kxnumeric;
using kxfile;
using kxgetopt;
Zip.create = File._zipCreate;
Expand Down

0 comments on commit 5d3189f

Please sign in to comment.