Skip to content

Commit 5d3189f

Browse files
committed
added a new Functional.
1 parent 9722c23 commit 5d3189f

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

lib/std/kxfunctional.kx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,27 @@ _function _functional_enumerator(e) {
114114
};
115115
}
116116

117-
Functional.enumerable = Functional.Enumerator.create = _functional_enumerator;
117+
Functional.methodMissing = _function(_instance, method, ...a) {
118+
Functional[method] = _function(...args) {
119+
return _function(obj) {
120+
return obj[method](...args);
121+
};
122+
};
123+
return Functional[method](...a);
124+
};
125+
126+
// The methods in Array such as `map` have to be assigned to this object
127+
// because Array.map will have been called directly instead of this.map
128+
// and methodMissing will not be called.
129+
Array.keySet(Array).filter({ => Array[_1].isFunction }).each { &(method)
130+
Functional[method] = _function(...args) {
131+
return _function(obj) {
132+
return obj[method](...args);
133+
};
134+
};
135+
};
136+
137+
Functional.enumerable
138+
= Functional.Enumerator.create
139+
= _functional_enumerator
140+
;

lib/std/kxstartup.kx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ var Xml, Net;
2222
Net = _import('kxnet');
2323
SQLite = _import('kxsqlite');
2424
Debugger = _import('kxdebugger');
25+
using kxsysutil;
26+
using kxstring;
27+
using kxarray;
28+
using kxbinary;
29+
using kxnumeric;
2530
using kxisolate;
2631
using kxexception;
2732
using kxsqlite;
2833
using kxxml;
2934
using kxnet;
3035
using kxenumerable;
3136
using kxfunctional;
32-
using kxsysutil;
33-
using kxstring;
34-
using kxarray;
35-
using kxbinary;
36-
using kxnumeric;
3737
using kxfile;
3838
using kxgetopt;
3939
Zip.create = File._zipCreate;

0 commit comments

Comments
 (0)