Add reduce function on Sequence
This commit is contained in:
@@ -64,6 +64,16 @@ static const char* libSource =
|
||||
" }\n"
|
||||
" return true\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" reduce(acc, f) {\n"
|
||||
" for (element in this) {\n"
|
||||
" acc = f.call(acc, element)\n"
|
||||
" }\n"
|
||||
" return acc\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" reduce(f) { this[1..-1].reduce(this[0], f) }\n"
|
||||
"\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"class List is Sequence {\n"
|
||||
|
||||
Reference in New Issue
Block a user