marty 2.4.7 → 2.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile.dummy +8 -5
- data/Gemfile.lock +1 -1
- data/README.md +8 -0
- data/app/assets/javascripts/marty/application.js +1 -0
- data/app/assets/javascripts/marty/codemirror/codemirror.js +9730 -0
- data/app/{components/marty/script_form/client → assets/javascripts/marty/codemirror}/mode/delorean/delorean.js +0 -0
- data/app/assets/javascripts/marty/codemirror/mode/javascript/javascript.js +900 -0
- data/app/assets/javascripts/marty/codemirror/mode/python/python.js +399 -0
- data/app/{components/marty/script_form/client → assets/javascripts/marty/codemirror}/mode/ruby/ruby.js +135 -34
- data/app/{components/marty/script_form/client/Ext.ux.form.field.CodeMirror.js → assets/javascripts/marty/extjs/extensions/marty.js} +87 -6
- data/app/assets/stylesheets/marty/application.css +1 -13
- data/app/assets/stylesheets/marty/codemirror/codemirror.css +346 -0
- data/app/{components/marty/script_form/client → assets/stylesheets/marty/codemirror}/delorean.css +0 -0
- data/app/components/marty/auth_app/client/auth_app.js +82 -80
- data/app/components/marty/data_grid_view.rb +1 -54
- data/app/components/marty/data_grid_view/client/data_grid_view.js +49 -0
- data/app/components/marty/form.rb +1 -5
- data/app/components/marty/form/client/form.js +5 -0
- data/app/components/marty/grid.rb +1 -146
- data/app/components/marty/grid/client/grid.js +146 -0
- data/app/components/marty/import_view.rb +1 -32
- data/app/components/marty/import_view/client/import_view.js +32 -0
- data/app/components/marty/live_search_grid_panel.rb +1 -21
- data/app/components/marty/live_search_grid_panel/client/live_search_grid_panel.js +27 -0
- data/app/components/marty/main_auth_app.rb +4 -145
- data/app/components/marty/main_auth_app/client/main_auth_app.js +124 -0
- data/app/components/marty/mcfly_grid_panel.rb +1 -17
- data/app/components/marty/mcfly_grid_panel/client/mcfly_grid_panel.js +37 -0
- data/app/components/marty/new_posting_form.rb +1 -6
- data/app/components/marty/new_posting_form/client/new_posting_form.js +6 -0
- data/app/components/marty/panel.rb +1 -5
- data/app/components/marty/panel/client/panel.js +5 -0
- data/app/components/marty/posting_grid.rb +4 -55
- data/app/components/marty/posting_grid/client/posting_grid.js +50 -0
- data/app/components/marty/promise_view.rb +2 -75
- data/app/components/marty/promise_view/client/promise_view.css +12 -9
- data/app/components/marty/promise_view/client/promise_view.js +57 -0
- data/app/components/marty/report_form.rb +3 -69
- data/app/components/marty/report_form/client/report_form.js +78 -0
- data/app/components/marty/report_select.rb +1 -45
- data/app/components/marty/report_select/client/report_select.js +50 -0
- data/app/components/marty/reporting.rb +1 -8
- data/app/components/marty/reporting/client/reporting.js +8 -0
- data/app/components/marty/script_form.rb +2 -63
- data/app/components/marty/script_form/client/script_form.js +44 -0
- data/app/components/marty/script_tester.rb +1 -7
- data/app/components/marty/script_tester/client/script_tester.js +7 -0
- data/app/components/marty/scripting.rb +1 -55
- data/app/components/marty/scripting/client/scripting.js +62 -0
- data/app/components/marty/simple_app/client/simple_app.js +21 -13
- data/app/models/marty/promise.rb +22 -1
- data/app/views/layouts/marty/application.html.erb +8 -6
- data/docker-compose.dummy.yml +2 -0
- data/lib/marty/monkey.rb +0 -16
- data/lib/marty/version.rb +1 -1
- data/spec/dummy/config/initializers/assets.rb +1 -0
- data/spec/features/reporting_spec.rb +1 -0
- data/spec/features/scripting_spec.rb +4 -4
- data/spec/spec_helper.rb +1 -0
- data/spec/support/chromedriver.rb +5 -1
- data/spec/support/shared_connection_db_helpers.rb +42 -2
- metadata +29 -168
- data/app/assets/images/marty/.gitkeep +0 -0
- data/app/components/marty/mcfly_grid_panel/client/dup_in_form.js +0 -20
- data/app/components/marty/script_form/client/codemirror.css +0 -172
- data/app/components/marty/script_form/client/codemirror.js +0 -3130
- data/app/components/marty/script_form/client/mode/clike/clike.js +0 -284
- data/app/components/marty/script_form/client/mode/clike/index.html +0 -102
- data/app/components/marty/script_form/client/mode/clike/scala.html +0 -766
- data/app/components/marty/script_form/client/mode/clojure/clojure.js +0 -206
- data/app/components/marty/script_form/client/mode/clojure/index.html +0 -67
- data/app/components/marty/script_form/client/mode/coffeescript/LICENSE +0 -22
- data/app/components/marty/script_form/client/mode/coffeescript/coffeescript.js +0 -346
- data/app/components/marty/script_form/client/mode/coffeescript/index.html +0 -728
- data/app/components/marty/script_form/client/mode/commonlisp/commonlisp.js +0 -101
- data/app/components/marty/script_form/client/mode/commonlisp/index.html +0 -165
- data/app/components/marty/script_form/client/mode/css/css.js +0 -448
- data/app/components/marty/script_form/client/mode/css/index.html +0 -58
- data/app/components/marty/script_form/client/mode/css/test.js +0 -501
- data/app/components/marty/script_form/client/mode/diff/diff.js +0 -32
- data/app/components/marty/script_form/client/mode/diff/index.html +0 -105
- data/app/components/marty/script_form/client/mode/ecl/ecl.js +0 -203
- data/app/components/marty/script_form/client/mode/ecl/index.html +0 -42
- data/app/components/marty/script_form/client/mode/erlang/erlang.js +0 -463
- data/app/components/marty/script_form/client/mode/erlang/index.html +0 -63
- data/app/components/marty/script_form/client/mode/gfm/gfm.js +0 -150
- data/app/components/marty/script_form/client/mode/gfm/index.html +0 -48
- data/app/components/marty/script_form/client/mode/go/go.js +0 -170
- data/app/components/marty/script_form/client/mode/go/index.html +0 -73
- data/app/components/marty/script_form/client/mode/groovy/groovy.js +0 -210
- data/app/components/marty/script_form/client/mode/groovy/index.html +0 -72
- data/app/components/marty/script_form/client/mode/haskell/haskell.js +0 -242
- data/app/components/marty/script_form/client/mode/haskell/index.html +0 -61
- data/app/components/marty/script_form/client/mode/haxe/haxe.js +0 -429
- data/app/components/marty/script_form/client/mode/haxe/index.html +0 -91
- data/app/components/marty/script_form/client/mode/htmlembedded/htmlembedded.js +0 -72
- data/app/components/marty/script_form/client/mode/htmlembedded/index.html +0 -50
- data/app/components/marty/script_form/client/mode/htmlmixed/htmlmixed.js +0 -84
- data/app/components/marty/script_form/client/mode/htmlmixed/index.html +0 -52
- data/app/components/marty/script_form/client/mode/javascript/index.html +0 -78
- data/app/components/marty/script_form/client/mode/javascript/javascript.js +0 -361
- data/app/components/marty/script_form/client/mode/jinja2/index.html +0 -38
- data/app/components/marty/script_form/client/mode/jinja2/jinja2.js +0 -42
- data/app/components/marty/script_form/client/mode/less/index.html +0 -740
- data/app/components/marty/script_form/client/mode/less/less.js +0 -266
- data/app/components/marty/script_form/client/mode/lua/index.html +0 -73
- data/app/components/marty/script_form/client/mode/lua/lua.js +0 -140
- data/app/components/marty/script_form/client/mode/markdown/index.html +0 -343
- data/app/components/marty/script_form/client/mode/markdown/markdown.js +0 -382
- data/app/components/marty/script_form/client/mode/markdown/test.js +0 -1084
- data/app/components/marty/script_form/client/mode/mysql/index.html +0 -42
- data/app/components/marty/script_form/client/mode/mysql/mysql.js +0 -186
- data/app/components/marty/script_form/client/mode/ntriples/index.html +0 -33
- data/app/components/marty/script_form/client/mode/ntriples/ntriples.js +0 -172
- data/app/components/marty/script_form/client/mode/ocaml/index.html +0 -130
- data/app/components/marty/script_form/client/mode/ocaml/ocaml.js +0 -114
- data/app/components/marty/script_form/client/mode/pascal/LICENSE +0 -7
- data/app/components/marty/script_form/client/mode/pascal/index.html +0 -49
- data/app/components/marty/script_form/client/mode/pascal/pascal.js +0 -94
- data/app/components/marty/script_form/client/mode/perl/LICENSE +0 -19
- data/app/components/marty/script_form/client/mode/perl/index.html +0 -63
- data/app/components/marty/script_form/client/mode/perl/perl.js +0 -816
- data/app/components/marty/script_form/client/mode/php/index.html +0 -49
- data/app/components/marty/script_form/client/mode/php/php.js +0 -148
- data/app/components/marty/script_form/client/mode/pig/index.html +0 -43
- data/app/components/marty/script_form/client/mode/pig/pig.js +0 -172
- data/app/components/marty/script_form/client/mode/plsql/index.html +0 -63
- data/app/components/marty/script_form/client/mode/plsql/plsql.js +0 -217
- data/app/components/marty/script_form/client/mode/properties/index.html +0 -41
- data/app/components/marty/script_form/client/mode/properties/properties.js +0 -63
- data/app/components/marty/script_form/client/mode/python/LICENSE.txt +0 -21
- data/app/components/marty/script_form/client/mode/python/index.html +0 -123
- data/app/components/marty/script_form/client/mode/python/python.js +0 -338
- data/app/components/marty/script_form/client/mode/r/LICENSE +0 -24
- data/app/components/marty/script_form/client/mode/r/index.html +0 -74
- data/app/components/marty/script_form/client/mode/r/r.js +0 -141
- data/app/components/marty/script_form/client/mode/rpm/changes/changes.js +0 -19
- data/app/components/marty/script_form/client/mode/rpm/changes/index.html +0 -54
- data/app/components/marty/script_form/client/mode/rpm/spec/index.html +0 -100
- data/app/components/marty/script_form/client/mode/rpm/spec/spec.css +0 -5
- data/app/components/marty/script_form/client/mode/rpm/spec/spec.js +0 -66
- data/app/components/marty/script_form/client/mode/rst/index.html +0 -526
- data/app/components/marty/script_form/client/mode/rst/rst.js +0 -326
- data/app/components/marty/script_form/client/mode/ruby/LICENSE +0 -24
- data/app/components/marty/script_form/client/mode/ruby/index.html +0 -172
- data/app/components/marty/script_form/client/mode/rust/index.html +0 -49
- data/app/components/marty/script_form/client/mode/rust/rust.js +0 -432
- data/app/components/marty/script_form/client/mode/scheme/index.html +0 -65
- data/app/components/marty/script_form/client/mode/scheme/scheme.js +0 -230
- data/app/components/marty/script_form/client/mode/shell/index.html +0 -50
- data/app/components/marty/script_form/client/mode/shell/shell.js +0 -118
- data/app/components/marty/script_form/client/mode/sieve/LICENSE +0 -23
- data/app/components/marty/script_form/client/mode/sieve/index.html +0 -81
- data/app/components/marty/script_form/client/mode/sieve/sieve.js +0 -156
- data/app/components/marty/script_form/client/mode/smalltalk/index.html +0 -56
- data/app/components/marty/script_form/client/mode/smalltalk/smalltalk.js +0 -139
- data/app/components/marty/script_form/client/mode/smarty/index.html +0 -83
- data/app/components/marty/script_form/client/mode/smarty/smarty.js +0 -148
- data/app/components/marty/script_form/client/mode/sparql/index.html +0 -41
- data/app/components/marty/script_form/client/mode/sparql/sparql.js +0 -143
- data/app/components/marty/script_form/client/mode/stex/index.html +0 -98
- data/app/components/marty/script_form/client/mode/stex/stex.js +0 -182
- data/app/components/marty/script_form/client/mode/stex/test.js +0 -343
- data/app/components/marty/script_form/client/mode/tiddlywiki/index.html +0 -141
- data/app/components/marty/script_form/client/mode/tiddlywiki/tiddlywiki.css +0 -14
- data/app/components/marty/script_form/client/mode/tiddlywiki/tiddlywiki.js +0 -384
- data/app/components/marty/script_form/client/mode/tiki/index.html +0 -83
- data/app/components/marty/script_form/client/mode/tiki/tiki.css +0 -26
- data/app/components/marty/script_form/client/mode/tiki/tiki.js +0 -309
- data/app/components/marty/script_form/client/mode/vb/LICENSE.txt +0 -21
- data/app/components/marty/script_form/client/mode/vb/index.html +0 -89
- data/app/components/marty/script_form/client/mode/vb/vb.js +0 -260
- data/app/components/marty/script_form/client/mode/vbscript/index.html +0 -43
- data/app/components/marty/script_form/client/mode/vbscript/vbscript.js +0 -26
- data/app/components/marty/script_form/client/mode/velocity/index.html +0 -104
- data/app/components/marty/script_form/client/mode/velocity/velocity.js +0 -146
- data/app/components/marty/script_form/client/mode/verilog/index.html +0 -211
- data/app/components/marty/script_form/client/mode/verilog/verilog.js +0 -194
- data/app/components/marty/script_form/client/mode/xml/index.html +0 -45
- data/app/components/marty/script_form/client/mode/xml/xml.js +0 -318
- data/app/components/marty/script_form/client/mode/xquery/LICENSE +0 -20
- data/app/components/marty/script_form/client/mode/xquery/index.html +0 -223
- data/app/components/marty/script_form/client/mode/xquery/test/index.html +0 -27
- data/app/components/marty/script_form/client/mode/xquery/test/testBase.js +0 -42
- data/app/components/marty/script_form/client/mode/xquery/test/testEmptySequenceKeyword.js +0 -16
- data/app/components/marty/script_form/client/mode/xquery/test/testMultiAttr.js +0 -16
- data/app/components/marty/script_form/client/mode/xquery/test/testNamespaces.js +0 -91
- data/app/components/marty/script_form/client/mode/xquery/test/testProcessingInstructions.js +0 -16
- data/app/components/marty/script_form/client/mode/xquery/test/testQuotes.js +0 -19
- data/app/components/marty/script_form/client/mode/xquery/xquery.js +0 -451
- data/app/components/marty/script_form/client/mode/yaml/index.html +0 -68
- data/app/components/marty/script_form/client/mode/yaml/yaml.js +0 -95
- data/app/components/marty/script_form/client/theme/ambiance.css +0 -81
- data/app/components/marty/script_form/client/theme/blackboard.css +0 -25
- data/app/components/marty/script_form/client/theme/cobalt.css +0 -18
- data/app/components/marty/script_form/client/theme/eclipse.css +0 -25
- data/app/components/marty/script_form/client/theme/elegant.css +0 -10
- data/app/components/marty/script_form/client/theme/erlang-dark.css +0 -21
- data/app/components/marty/script_form/client/theme/lesser-dark.css +0 -44
- data/app/components/marty/script_form/client/theme/monokai.css +0 -28
- data/app/components/marty/script_form/client/theme/neat.css +0 -9
- data/app/components/marty/script_form/client/theme/night.css +0 -21
- data/app/components/marty/script_form/client/theme/rubyblue.css +0 -21
- data/app/components/marty/script_form/client/theme/vibrant-ink.css +0 -27
- data/app/components/marty/script_form/client/theme/xq-dark.css +0 -46
- data/app/components/marty/script_form/client/util/closetag.js +0 -164
- data/app/components/marty/script_form/client/util/dialog.css +0 -27
- data/app/components/marty/script_form/client/util/dialog.js +0 -70
- data/app/components/marty/script_form/client/util/foldcode.js +0 -196
- data/app/components/marty/script_form/client/util/formatting.js +0 -193
- data/app/components/marty/script_form/client/util/javascript-hint.js +0 -134
- data/app/components/marty/script_form/client/util/loadmode.js +0 -51
- data/app/components/marty/script_form/client/util/match-highlighter.js +0 -44
- data/app/components/marty/script_form/client/util/multiplex.js +0 -77
- data/app/components/marty/script_form/client/util/overlay.js +0 -54
- data/app/components/marty/script_form/client/util/pig-hint.js +0 -123
- data/app/components/marty/script_form/client/util/runmode-standalone.js +0 -90
- data/app/components/marty/script_form/client/util/runmode.js +0 -53
- data/app/components/marty/script_form/client/util/search.js +0 -118
- data/app/components/marty/script_form/client/util/searchcursor.js +0 -119
- data/app/components/marty/script_form/client/util/simple-hint.css +0 -16
- data/app/components/marty/script_form/client/util/simple-hint.js +0 -97
- data/app/components/marty/script_form/client/util/xml-hint.js +0 -137
- data/lib/marty/javascript/grid_view_in_form.js +0 -81
@@ -1,284 +0,0 @@
|
|
1
|
-
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
2
|
-
var indentUnit = config.indentUnit,
|
3
|
-
keywords = parserConfig.keywords || {},
|
4
|
-
builtin = parserConfig.builtin || {},
|
5
|
-
blockKeywords = parserConfig.blockKeywords || {},
|
6
|
-
atoms = parserConfig.atoms || {},
|
7
|
-
hooks = parserConfig.hooks || {},
|
8
|
-
multiLineStrings = parserConfig.multiLineStrings;
|
9
|
-
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
10
|
-
|
11
|
-
var curPunc;
|
12
|
-
|
13
|
-
function tokenBase(stream, state) {
|
14
|
-
var ch = stream.next();
|
15
|
-
if (hooks[ch]) {
|
16
|
-
var result = hooks[ch](stream, state);
|
17
|
-
if (result !== false) return result;
|
18
|
-
}
|
19
|
-
if (ch == '"' || ch == "'") {
|
20
|
-
state.tokenize = tokenString(ch);
|
21
|
-
return state.tokenize(stream, state);
|
22
|
-
}
|
23
|
-
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
24
|
-
curPunc = ch;
|
25
|
-
return null;
|
26
|
-
}
|
27
|
-
if (/\d/.test(ch)) {
|
28
|
-
stream.eatWhile(/[\w\.]/);
|
29
|
-
return "number";
|
30
|
-
}
|
31
|
-
if (ch == "/") {
|
32
|
-
if (stream.eat("*")) {
|
33
|
-
state.tokenize = tokenComment;
|
34
|
-
return tokenComment(stream, state);
|
35
|
-
}
|
36
|
-
if (stream.eat("/")) {
|
37
|
-
stream.skipToEnd();
|
38
|
-
return "comment";
|
39
|
-
}
|
40
|
-
}
|
41
|
-
if (isOperatorChar.test(ch)) {
|
42
|
-
stream.eatWhile(isOperatorChar);
|
43
|
-
return "operator";
|
44
|
-
}
|
45
|
-
stream.eatWhile(/[\w\$_]/);
|
46
|
-
var cur = stream.current();
|
47
|
-
if (keywords.propertyIsEnumerable(cur)) {
|
48
|
-
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
49
|
-
return "keyword";
|
50
|
-
}
|
51
|
-
if (builtin.propertyIsEnumerable(cur)) {
|
52
|
-
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
53
|
-
return "builtin";
|
54
|
-
}
|
55
|
-
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
56
|
-
return "variable";
|
57
|
-
}
|
58
|
-
|
59
|
-
function tokenString(quote) {
|
60
|
-
return function(stream, state) {
|
61
|
-
var escaped = false, next, end = false;
|
62
|
-
while ((next = stream.next()) != null) {
|
63
|
-
if (next == quote && !escaped) {end = true; break;}
|
64
|
-
escaped = !escaped && next == "\\";
|
65
|
-
}
|
66
|
-
if (end || !(escaped || multiLineStrings))
|
67
|
-
state.tokenize = null;
|
68
|
-
return "string";
|
69
|
-
};
|
70
|
-
}
|
71
|
-
|
72
|
-
function tokenComment(stream, state) {
|
73
|
-
var maybeEnd = false, ch;
|
74
|
-
while (ch = stream.next()) {
|
75
|
-
if (ch == "/" && maybeEnd) {
|
76
|
-
state.tokenize = null;
|
77
|
-
break;
|
78
|
-
}
|
79
|
-
maybeEnd = (ch == "*");
|
80
|
-
}
|
81
|
-
return "comment";
|
82
|
-
}
|
83
|
-
|
84
|
-
function Context(indented, column, type, align, prev) {
|
85
|
-
this.indented = indented;
|
86
|
-
this.column = column;
|
87
|
-
this.type = type;
|
88
|
-
this.align = align;
|
89
|
-
this.prev = prev;
|
90
|
-
}
|
91
|
-
function pushContext(state, col, type) {
|
92
|
-
return state.context = new Context(state.indented, col, type, null, state.context);
|
93
|
-
}
|
94
|
-
function popContext(state) {
|
95
|
-
var t = state.context.type;
|
96
|
-
if (t == ")" || t == "]" || t == "}")
|
97
|
-
state.indented = state.context.indented;
|
98
|
-
return state.context = state.context.prev;
|
99
|
-
}
|
100
|
-
|
101
|
-
// Interface
|
102
|
-
|
103
|
-
return {
|
104
|
-
startState: function(basecolumn) {
|
105
|
-
return {
|
106
|
-
tokenize: null,
|
107
|
-
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
108
|
-
indented: 0,
|
109
|
-
startOfLine: true
|
110
|
-
};
|
111
|
-
},
|
112
|
-
|
113
|
-
token: function(stream, state) {
|
114
|
-
var ctx = state.context;
|
115
|
-
if (stream.sol()) {
|
116
|
-
if (ctx.align == null) ctx.align = false;
|
117
|
-
state.indented = stream.indentation();
|
118
|
-
state.startOfLine = true;
|
119
|
-
}
|
120
|
-
if (stream.eatSpace()) return null;
|
121
|
-
curPunc = null;
|
122
|
-
var style = (state.tokenize || tokenBase)(stream, state);
|
123
|
-
if (style == "comment" || style == "meta") return style;
|
124
|
-
if (ctx.align == null) ctx.align = true;
|
125
|
-
|
126
|
-
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
127
|
-
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
128
|
-
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
129
|
-
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
130
|
-
else if (curPunc == "}") {
|
131
|
-
while (ctx.type == "statement") ctx = popContext(state);
|
132
|
-
if (ctx.type == "}") ctx = popContext(state);
|
133
|
-
while (ctx.type == "statement") ctx = popContext(state);
|
134
|
-
}
|
135
|
-
else if (curPunc == ctx.type) popContext(state);
|
136
|
-
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
137
|
-
pushContext(state, stream.column(), "statement");
|
138
|
-
state.startOfLine = false;
|
139
|
-
return style;
|
140
|
-
},
|
141
|
-
|
142
|
-
indent: function(state, textAfter) {
|
143
|
-
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
144
|
-
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
145
|
-
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
146
|
-
var closing = firstChar == ctx.type;
|
147
|
-
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
148
|
-
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
149
|
-
else return ctx.indented + (closing ? 0 : indentUnit);
|
150
|
-
},
|
151
|
-
|
152
|
-
electricChars: "{}"
|
153
|
-
};
|
154
|
-
});
|
155
|
-
|
156
|
-
(function() {
|
157
|
-
function words(str) {
|
158
|
-
var obj = {}, words = str.split(" ");
|
159
|
-
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
160
|
-
return obj;
|
161
|
-
}
|
162
|
-
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
|
163
|
-
"double static else struct entry switch extern typedef float union for unsigned " +
|
164
|
-
"goto while enum void const signed volatile";
|
165
|
-
|
166
|
-
function cppHook(stream, state) {
|
167
|
-
if (!state.startOfLine) return false;
|
168
|
-
stream.skipToEnd();
|
169
|
-
return "meta";
|
170
|
-
}
|
171
|
-
|
172
|
-
// C#-style strings where "" escapes a quote.
|
173
|
-
function tokenAtString(stream, state) {
|
174
|
-
var next;
|
175
|
-
while ((next = stream.next()) != null) {
|
176
|
-
if (next == '"' && !stream.eat('"')) {
|
177
|
-
state.tokenize = null;
|
178
|
-
break;
|
179
|
-
}
|
180
|
-
}
|
181
|
-
return "string";
|
182
|
-
}
|
183
|
-
|
184
|
-
function mimes(ms, mode) {
|
185
|
-
for (var i = 0; i < ms.length; ++i) CodeMirror.defineMIME(ms[i], mode);
|
186
|
-
}
|
187
|
-
|
188
|
-
mimes(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
189
|
-
name: "clike",
|
190
|
-
keywords: words(cKeywords),
|
191
|
-
blockKeywords: words("case do else for if switch while struct"),
|
192
|
-
atoms: words("null"),
|
193
|
-
hooks: {"#": cppHook}
|
194
|
-
});
|
195
|
-
mimes(["text/x-c++src", "text/x-c++hdr"], {
|
196
|
-
name: "clike",
|
197
|
-
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
|
198
|
-
"static_cast typeid catch operator template typename class friend private " +
|
199
|
-
"this using const_cast inline public throw virtual delete mutable protected " +
|
200
|
-
"wchar_t"),
|
201
|
-
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
202
|
-
atoms: words("true false null"),
|
203
|
-
hooks: {"#": cppHook}
|
204
|
-
});
|
205
|
-
CodeMirror.defineMIME("text/x-java", {
|
206
|
-
name: "clike",
|
207
|
-
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
|
208
|
-
"do double else enum extends final finally float for goto if implements import " +
|
209
|
-
"instanceof int interface long native new package private protected public " +
|
210
|
-
"return short static strictfp super switch synchronized this throw throws transient " +
|
211
|
-
"try void volatile while"),
|
212
|
-
blockKeywords: words("catch class do else finally for if switch try while"),
|
213
|
-
atoms: words("true false null"),
|
214
|
-
hooks: {
|
215
|
-
"@": function(stream, state) {
|
216
|
-
stream.eatWhile(/[\w\$_]/);
|
217
|
-
return "meta";
|
218
|
-
}
|
219
|
-
}
|
220
|
-
});
|
221
|
-
CodeMirror.defineMIME("text/x-csharp", {
|
222
|
-
name: "clike",
|
223
|
-
keywords: words("abstract as base break case catch checked class const continue" +
|
224
|
-
" default delegate do else enum event explicit extern finally fixed for" +
|
225
|
-
" foreach goto if implicit in interface internal is lock namespace new" +
|
226
|
-
" operator out override params private protected public readonly ref return sealed" +
|
227
|
-
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
|
228
|
-
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
|
229
|
-
" global group into join let orderby partial remove select set value var yield"),
|
230
|
-
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
231
|
-
builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
|
232
|
-
" Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
|
233
|
-
" UInt64 bool byte char decimal double short int long object" +
|
234
|
-
" sbyte float string ushort uint ulong"),
|
235
|
-
atoms: words("true false null"),
|
236
|
-
hooks: {
|
237
|
-
"@": function(stream, state) {
|
238
|
-
if (stream.eat('"')) {
|
239
|
-
state.tokenize = tokenAtString;
|
240
|
-
return tokenAtString(stream, state);
|
241
|
-
}
|
242
|
-
stream.eatWhile(/[\w\$_]/);
|
243
|
-
return "meta";
|
244
|
-
}
|
245
|
-
}
|
246
|
-
});
|
247
|
-
CodeMirror.defineMIME("text/x-scala", {
|
248
|
-
name: "clike",
|
249
|
-
keywords: words(
|
250
|
-
|
251
|
-
/* scala */
|
252
|
-
"abstract case catch class def do else extends false final finally for forSome if " +
|
253
|
-
"implicit import lazy match new null object override package private protected return " +
|
254
|
-
"sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
|
255
|
-
"<% >: # @ " +
|
256
|
-
|
257
|
-
/* package scala */
|
258
|
-
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
259
|
-
"readChar readInt readLong readFloat readDouble " +
|
260
|
-
|
261
|
-
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
262
|
-
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
|
263
|
-
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
264
|
-
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
265
|
-
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
|
266
|
-
|
267
|
-
/* package java.lang */
|
268
|
-
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
269
|
-
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
270
|
-
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
271
|
-
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
272
|
-
|
273
|
-
|
274
|
-
),
|
275
|
-
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
276
|
-
atoms: words("true false null"),
|
277
|
-
hooks: {
|
278
|
-
"@": function(stream, state) {
|
279
|
-
stream.eatWhile(/[\w\$_]/);
|
280
|
-
return "meta";
|
281
|
-
}
|
282
|
-
}
|
283
|
-
});
|
284
|
-
}());
|
@@ -1,102 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<title>CodeMirror: C-like mode</title>
|
6
|
-
<link rel="stylesheet" href="../../lib/codemirror.css">
|
7
|
-
<script src="../../lib/codemirror.js"></script>
|
8
|
-
<script src="clike.js"></script>
|
9
|
-
<link rel="stylesheet" href="../../doc/docs.css">
|
10
|
-
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
11
|
-
</head>
|
12
|
-
<body>
|
13
|
-
<h1>CodeMirror: C-like mode</h1>
|
14
|
-
|
15
|
-
<form><textarea id="code" name="code">
|
16
|
-
/* C demo code */
|
17
|
-
|
18
|
-
#include <zmq.h>
|
19
|
-
#include <pthread.h>
|
20
|
-
#include <semaphore.h>
|
21
|
-
#include <time.h>
|
22
|
-
#include <stdio.h>
|
23
|
-
#include <fcntl.h>
|
24
|
-
#include <malloc.h>
|
25
|
-
|
26
|
-
typedef struct {
|
27
|
-
void* arg_socket;
|
28
|
-
zmq_msg_t* arg_msg;
|
29
|
-
char* arg_string;
|
30
|
-
unsigned long arg_len;
|
31
|
-
int arg_int, arg_command;
|
32
|
-
|
33
|
-
int signal_fd;
|
34
|
-
int pad;
|
35
|
-
void* context;
|
36
|
-
sem_t sem;
|
37
|
-
} acl_zmq_context;
|
38
|
-
|
39
|
-
#define p(X) (context->arg_##X)
|
40
|
-
|
41
|
-
void* zmq_thread(void* context_pointer) {
|
42
|
-
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
43
|
-
char ok = 'K', err = 'X';
|
44
|
-
int res;
|
45
|
-
|
46
|
-
while (1) {
|
47
|
-
while ((res = sem_wait(&context->sem)) == EINTR);
|
48
|
-
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
49
|
-
switch(p(command)) {
|
50
|
-
case 0: goto cleanup;
|
51
|
-
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
52
|
-
case 2: p(int) = zmq_close(p(socket)); break;
|
53
|
-
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
54
|
-
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
55
|
-
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
56
|
-
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
57
|
-
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
58
|
-
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
59
|
-
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
60
|
-
}
|
61
|
-
p(command) = errno;
|
62
|
-
write(context->signal_fd, &ok, 1);
|
63
|
-
}
|
64
|
-
cleanup:
|
65
|
-
close(context->signal_fd);
|
66
|
-
free(context_pointer);
|
67
|
-
return 0;
|
68
|
-
}
|
69
|
-
|
70
|
-
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
71
|
-
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
72
|
-
pthread_t thread;
|
73
|
-
|
74
|
-
context->context = zmq_context;
|
75
|
-
context->signal_fd = signal_fd;
|
76
|
-
sem_init(&context->sem, 1, 0);
|
77
|
-
pthread_create(&thread, 0, &zmq_thread, context);
|
78
|
-
pthread_detach(thread);
|
79
|
-
return context;
|
80
|
-
}
|
81
|
-
</textarea></form>
|
82
|
-
|
83
|
-
<script>
|
84
|
-
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
85
|
-
lineNumbers: true,
|
86
|
-
matchBrackets: true,
|
87
|
-
mode: "text/x-csrc"
|
88
|
-
});
|
89
|
-
</script>
|
90
|
-
|
91
|
-
<p>Simple mode that tries to handle C-like languages as well as it
|
92
|
-
can. Takes two configuration parameters: <code>keywords</code>, an
|
93
|
-
object whose property names are the keywords in the language,
|
94
|
-
and <code>useCPP</code>, which determines whether C preprocessor
|
95
|
-
directives are recognized.</p>
|
96
|
-
|
97
|
-
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
98
|
-
(C code), <code>text/x-c++src</code> (C++
|
99
|
-
code), <code>text/x-java</code> (Java
|
100
|
-
code), <code>text/x-csharp</code> (C#).</p>
|
101
|
-
</body>
|
102
|
-
</html>
|
@@ -1,766 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<title>CodeMirror: C-like mode</title>
|
6
|
-
<link rel="stylesheet" href="../../lib/codemirror.css">
|
7
|
-
<link rel="stylesheet" href="../../theme/ambiance.css">
|
8
|
-
<script src="../../lib/codemirror.js"></script>
|
9
|
-
<script src="clike.js"></script>
|
10
|
-
<link rel="stylesheet" href="../../doc/docs.css">
|
11
|
-
<style>
|
12
|
-
body
|
13
|
-
{
|
14
|
-
margin: 0;
|
15
|
-
padding: 0;
|
16
|
-
max-width:inherit;
|
17
|
-
height: 100%;
|
18
|
-
}
|
19
|
-
html, form, .CodeMirror, .CodeMirror-scroll
|
20
|
-
{
|
21
|
-
height: 100%;
|
22
|
-
}
|
23
|
-
</style>
|
24
|
-
</head>
|
25
|
-
<body>
|
26
|
-
<form>
|
27
|
-
<textarea id="code" name="code">
|
28
|
-
|
29
|
-
/* __ *\
|
30
|
-
** ________ ___ / / ___ Scala API **
|
31
|
-
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
|
32
|
-
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
33
|
-
** /____/\___/_/ |_/____/_/ | | **
|
34
|
-
** |/ **
|
35
|
-
\* */
|
36
|
-
|
37
|
-
package scala.collection
|
38
|
-
|
39
|
-
import generic._
|
40
|
-
import mutable.{ Builder, ListBuffer }
|
41
|
-
import annotation.{tailrec, migration, bridge}
|
42
|
-
import annotation.unchecked.{ uncheckedVariance => uV }
|
43
|
-
import parallel.ParIterable
|
44
|
-
|
45
|
-
/** A template trait for traversable collections of type `Traversable[A]`.
|
46
|
-
*
|
47
|
-
* $traversableInfo
|
48
|
-
* @define mutability
|
49
|
-
* @define traversableInfo
|
50
|
-
* This is a base trait of all kinds of $mutability Scala collections. It
|
51
|
-
* implements the behavior common to all collections, in terms of a method
|
52
|
-
* `foreach` with signature:
|
53
|
-
* {{{
|
54
|
-
* def foreach[U](f: Elem => U): Unit
|
55
|
-
* }}}
|
56
|
-
* Collection classes mixing in this trait provide a concrete
|
57
|
-
* `foreach` method which traverses all the
|
58
|
-
* elements contained in the collection, applying a given function to each.
|
59
|
-
* They also need to provide a method `newBuilder`
|
60
|
-
* which creates a builder for collections of the same kind.
|
61
|
-
*
|
62
|
-
* A traversable class might or might not have two properties: strictness
|
63
|
-
* and orderedness. Neither is represented as a type.
|
64
|
-
*
|
65
|
-
* The instances of a strict collection class have all their elements
|
66
|
-
* computed before they can be used as values. By contrast, instances of
|
67
|
-
* a non-strict collection class may defer computation of some of their
|
68
|
-
* elements until after the instance is available as a value.
|
69
|
-
* A typical example of a non-strict collection class is a
|
70
|
-
* <a href="../immutable/Stream.html" target="ContentFrame">
|
71
|
-
* `scala.collection.immutable.Stream`</a>.
|
72
|
-
* A more general class of examples are `TraversableViews`.
|
73
|
-
*
|
74
|
-
* If a collection is an instance of an ordered collection class, traversing
|
75
|
-
* its elements with `foreach` will always visit elements in the
|
76
|
-
* same order, even for different runs of the program. If the class is not
|
77
|
-
* ordered, `foreach` can visit elements in different orders for
|
78
|
-
* different runs (but it will keep the same order in the same run).'
|
79
|
-
*
|
80
|
-
* A typical example of a collection class which is not ordered is a
|
81
|
-
* `HashMap` of objects. The traversal order for hash maps will
|
82
|
-
* depend on the hash codes of its elements, and these hash codes might
|
83
|
-
* differ from one run to the next. By contrast, a `LinkedHashMap`
|
84
|
-
* is ordered because it's `foreach` method visits elements in the
|
85
|
-
* order they were inserted into the `HashMap`.
|
86
|
-
*
|
87
|
-
* @author Martin Odersky
|
88
|
-
* @version 2.8
|
89
|
-
* @since 2.8
|
90
|
-
* @tparam A the element type of the collection
|
91
|
-
* @tparam Repr the type of the actual collection containing the elements.
|
92
|
-
*
|
93
|
-
* @define Coll Traversable
|
94
|
-
* @define coll traversable collection
|
95
|
-
*/
|
96
|
-
trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
|
97
|
-
with FilterMonadic[A, Repr]
|
98
|
-
with TraversableOnce[A]
|
99
|
-
with GenTraversableLike[A, Repr]
|
100
|
-
with Parallelizable[A, ParIterable[A]]
|
101
|
-
{
|
102
|
-
self =>
|
103
|
-
|
104
|
-
import Traversable.breaks._
|
105
|
-
|
106
|
-
/** The type implementing this traversable */
|
107
|
-
protected type Self = Repr
|
108
|
-
|
109
|
-
/** The collection of type $coll underlying this `TraversableLike` object.
|
110
|
-
* By default this is implemented as the `TraversableLike` object itself,
|
111
|
-
* but this can be overridden.
|
112
|
-
*/
|
113
|
-
def repr: Repr = this.asInstanceOf[Repr]
|
114
|
-
|
115
|
-
/** The underlying collection seen as an instance of `$Coll`.
|
116
|
-
* By default this is implemented as the current collection object itself,
|
117
|
-
* but this can be overridden.
|
118
|
-
*/
|
119
|
-
protected[this] def thisCollection: Traversable[A] = this.asInstanceOf[Traversable[A]]
|
120
|
-
|
121
|
-
/** A conversion from collections of type `Repr` to `$Coll` objects.
|
122
|
-
* By default this is implemented as just a cast, but this can be overridden.
|
123
|
-
*/
|
124
|
-
protected[this] def toCollection(repr: Repr): Traversable[A] = repr.asInstanceOf[Traversable[A]]
|
125
|
-
|
126
|
-
/** Creates a new builder for this collection type.
|
127
|
-
*/
|
128
|
-
protected[this] def newBuilder: Builder[A, Repr]
|
129
|
-
|
130
|
-
protected[this] def parCombiner = ParIterable.newCombiner[A]
|
131
|
-
|
132
|
-
/** Applies a function `f` to all elements of this $coll.
|
133
|
-
*
|
134
|
-
* Note: this method underlies the implementation of most other bulk operations.
|
135
|
-
* It's important to implement this method in an efficient way.
|
136
|
-
*
|
137
|
-
*
|
138
|
-
* @param f the function that is applied for its side-effect to every element.
|
139
|
-
* The result of function `f` is discarded.
|
140
|
-
*
|
141
|
-
* @tparam U the type parameter describing the result of function `f`.
|
142
|
-
* This result will always be ignored. Typically `U` is `Unit`,
|
143
|
-
* but this is not necessary.
|
144
|
-
*
|
145
|
-
* @usecase def foreach(f: A => Unit): Unit
|
146
|
-
*/
|
147
|
-
def foreach[U](f: A => U): Unit
|
148
|
-
|
149
|
-
/** Tests whether this $coll is empty.
|
150
|
-
*
|
151
|
-
* @return `true` if the $coll contain no elements, `false` otherwise.
|
152
|
-
*/
|
153
|
-
def isEmpty: Boolean = {
|
154
|
-
var result = true
|
155
|
-
breakable {
|
156
|
-
for (x <- this) {
|
157
|
-
result = false
|
158
|
-
break
|
159
|
-
}
|
160
|
-
}
|
161
|
-
result
|
162
|
-
}
|
163
|
-
|
164
|
-
/** Tests whether this $coll is known to have a finite size.
|
165
|
-
* All strict collections are known to have finite size. For a non-strict collection
|
166
|
-
* such as `Stream`, the predicate returns `true` if all elements have been computed.
|
167
|
-
* It returns `false` if the stream is not yet evaluated to the end.
|
168
|
-
*
|
169
|
-
* Note: many collection methods will not work on collections of infinite sizes.
|
170
|
-
*
|
171
|
-
* @return `true` if this collection is known to have finite size, `false` otherwise.
|
172
|
-
*/
|
173
|
-
def hasDefiniteSize = true
|
174
|
-
|
175
|
-
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
176
|
-
val b = bf(repr)
|
177
|
-
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.seq.size)
|
178
|
-
b ++= thisCollection
|
179
|
-
b ++= that.seq
|
180
|
-
b.result
|
181
|
-
}
|
182
|
-
|
183
|
-
@bridge
|
184
|
-
def ++[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
185
|
-
++(that: GenTraversableOnce[B])(bf)
|
186
|
-
|
187
|
-
/** Concatenates this $coll with the elements of a traversable collection.
|
188
|
-
* It differs from ++ in that the right operand determines the type of the
|
189
|
-
* resulting collection rather than the left one.
|
190
|
-
*
|
191
|
-
* @param that the traversable to append.
|
192
|
-
* @tparam B the element type of the returned collection.
|
193
|
-
* @tparam That $thatinfo
|
194
|
-
* @param bf $bfinfo
|
195
|
-
* @return a new collection of type `That` which contains all elements
|
196
|
-
* of this $coll followed by all elements of `that`.
|
197
|
-
*
|
198
|
-
* @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
|
199
|
-
*
|
200
|
-
* @return a new $coll which contains all elements of this $coll
|
201
|
-
* followed by all elements of `that`.
|
202
|
-
*/
|
203
|
-
def ++:[B >: A, That](that: TraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
204
|
-
val b = bf(repr)
|
205
|
-
if (that.isInstanceOf[IndexedSeqLike[_, _]]) b.sizeHint(this, that.size)
|
206
|
-
b ++= that
|
207
|
-
b ++= thisCollection
|
208
|
-
b.result
|
209
|
-
}
|
210
|
-
|
211
|
-
/** This overload exists because: for the implementation of ++: we should reuse
|
212
|
-
* that of ++ because many collections override it with more efficient versions.
|
213
|
-
* Since TraversableOnce has no '++' method, we have to implement that directly,
|
214
|
-
* but Traversable and down can use the overload.
|
215
|
-
*/
|
216
|
-
def ++:[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Repr, B, That]): That =
|
217
|
-
(that ++ seq)(breakOut)
|
218
|
-
|
219
|
-
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
220
|
-
val b = bf(repr)
|
221
|
-
b.sizeHint(this)
|
222
|
-
for (x <- this) b += f(x)
|
223
|
-
b.result
|
224
|
-
}
|
225
|
-
|
226
|
-
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
227
|
-
val b = bf(repr)
|
228
|
-
for (x <- this) b ++= f(x).seq
|
229
|
-
b.result
|
230
|
-
}
|
231
|
-
|
232
|
-
/** Selects all elements of this $coll which satisfy a predicate.
|
233
|
-
*
|
234
|
-
* @param p the predicate used to test elements.
|
235
|
-
* @return a new $coll consisting of all elements of this $coll that satisfy the given
|
236
|
-
* predicate `p`. The order of the elements is preserved.
|
237
|
-
*/
|
238
|
-
def filter(p: A => Boolean): Repr = {
|
239
|
-
val b = newBuilder
|
240
|
-
for (x <- this)
|
241
|
-
if (p(x)) b += x
|
242
|
-
b.result
|
243
|
-
}
|
244
|
-
|
245
|
-
/** Selects all elements of this $coll which do not satisfy a predicate.
|
246
|
-
*
|
247
|
-
* @param p the predicate used to test elements.
|
248
|
-
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given
|
249
|
-
* predicate `p`. The order of the elements is preserved.
|
250
|
-
*/
|
251
|
-
def filterNot(p: A => Boolean): Repr = filter(!p(_))
|
252
|
-
|
253
|
-
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
254
|
-
val b = bf(repr)
|
255
|
-
for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
|
256
|
-
b.result
|
257
|
-
}
|
258
|
-
|
259
|
-
/** Builds a new collection by applying an option-valued function to all
|
260
|
-
* elements of this $coll on which the function is defined.
|
261
|
-
*
|
262
|
-
* @param f the option-valued function which filters and maps the $coll.
|
263
|
-
* @tparam B the element type of the returned collection.
|
264
|
-
* @tparam That $thatinfo
|
265
|
-
* @param bf $bfinfo
|
266
|
-
* @return a new collection of type `That` resulting from applying the option-valued function
|
267
|
-
* `f` to each element and collecting all defined results.
|
268
|
-
* The order of the elements is preserved.
|
269
|
-
*
|
270
|
-
* @usecase def filterMap[B](f: A => Option[B]): $Coll[B]
|
271
|
-
*
|
272
|
-
* @param pf the partial function which filters and maps the $coll.
|
273
|
-
* @return a new $coll resulting from applying the given option-valued function
|
274
|
-
* `f` to each element and collecting all defined results.
|
275
|
-
* The order of the elements is preserved.
|
276
|
-
def filterMap[B, That](f: A => Option[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
277
|
-
val b = bf(repr)
|
278
|
-
for (x <- this)
|
279
|
-
f(x) match {
|
280
|
-
case Some(y) => b += y
|
281
|
-
case _ =>
|
282
|
-
}
|
283
|
-
b.result
|
284
|
-
}
|
285
|
-
*/
|
286
|
-
|
287
|
-
/** Partitions this $coll in two ${coll}s according to a predicate.
|
288
|
-
*
|
289
|
-
* @param p the predicate on which to partition.
|
290
|
-
* @return a pair of ${coll}s: the first $coll consists of all elements that
|
291
|
-
* satisfy the predicate `p` and the second $coll consists of all elements
|
292
|
-
* that don't. The relative order of the elements in the resulting ${coll}s
|
293
|
-
* is the same as in the original $coll.
|
294
|
-
*/
|
295
|
-
def partition(p: A => Boolean): (Repr, Repr) = {
|
296
|
-
val l, r = newBuilder
|
297
|
-
for (x <- this) (if (p(x)) l else r) += x
|
298
|
-
(l.result, r.result)
|
299
|
-
}
|
300
|
-
|
301
|
-
def groupBy[K](f: A => K): immutable.Map[K, Repr] = {
|
302
|
-
val m = mutable.Map.empty[K, Builder[A, Repr]]
|
303
|
-
for (elem <- this) {
|
304
|
-
val key = f(elem)
|
305
|
-
val bldr = m.getOrElseUpdate(key, newBuilder)
|
306
|
-
bldr += elem
|
307
|
-
}
|
308
|
-
val b = immutable.Map.newBuilder[K, Repr]
|
309
|
-
for ((k, v) <- m)
|
310
|
-
b += ((k, v.result))
|
311
|
-
|
312
|
-
b.result
|
313
|
-
}
|
314
|
-
|
315
|
-
/** Tests whether a predicate holds for all elements of this $coll.
|
316
|
-
*
|
317
|
-
* $mayNotTerminateInf
|
318
|
-
*
|
319
|
-
* @param p the predicate used to test elements.
|
320
|
-
* @return `true` if the given predicate `p` holds for all elements
|
321
|
-
* of this $coll, otherwise `false`.
|
322
|
-
*/
|
323
|
-
def forall(p: A => Boolean): Boolean = {
|
324
|
-
var result = true
|
325
|
-
breakable {
|
326
|
-
for (x <- this)
|
327
|
-
if (!p(x)) { result = false; break }
|
328
|
-
}
|
329
|
-
result
|
330
|
-
}
|
331
|
-
|
332
|
-
/** Tests whether a predicate holds for some of the elements of this $coll.
|
333
|
-
*
|
334
|
-
* $mayNotTerminateInf
|
335
|
-
*
|
336
|
-
* @param p the predicate used to test elements.
|
337
|
-
* @return `true` if the given predicate `p` holds for some of the
|
338
|
-
* elements of this $coll, otherwise `false`.
|
339
|
-
*/
|
340
|
-
def exists(p: A => Boolean): Boolean = {
|
341
|
-
var result = false
|
342
|
-
breakable {
|
343
|
-
for (x <- this)
|
344
|
-
if (p(x)) { result = true; break }
|
345
|
-
}
|
346
|
-
result
|
347
|
-
}
|
348
|
-
|
349
|
-
/** Finds the first element of the $coll satisfying a predicate, if any.
|
350
|
-
*
|
351
|
-
* $mayNotTerminateInf
|
352
|
-
* $orderDependent
|
353
|
-
*
|
354
|
-
* @param p the predicate used to test elements.
|
355
|
-
* @return an option value containing the first element in the $coll
|
356
|
-
* that satisfies `p`, or `None` if none exists.
|
357
|
-
*/
|
358
|
-
def find(p: A => Boolean): Option[A] = {
|
359
|
-
var result: Option[A] = None
|
360
|
-
breakable {
|
361
|
-
for (x <- this)
|
362
|
-
if (p(x)) { result = Some(x); break }
|
363
|
-
}
|
364
|
-
result
|
365
|
-
}
|
366
|
-
|
367
|
-
def scan[B >: A, That](z: B)(op: (B, B) => B)(implicit cbf: CanBuildFrom[Repr, B, That]): That = scanLeft(z)(op)
|
368
|
-
|
369
|
-
def scanLeft[B, That](z: B)(op: (B, A) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
370
|
-
val b = bf(repr)
|
371
|
-
b.sizeHint(this, 1)
|
372
|
-
var acc = z
|
373
|
-
b += acc
|
374
|
-
for (x <- this) { acc = op(acc, x); b += acc }
|
375
|
-
b.result
|
376
|
-
}
|
377
|
-
|
378
|
-
@migration(2, 9,
|
379
|
-
"This scanRight definition has changed in 2.9.\n" +
|
380
|
-
"The previous behavior can be reproduced with scanRight.reverse."
|
381
|
-
)
|
382
|
-
def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
383
|
-
var scanned = List(z)
|
384
|
-
var acc = z
|
385
|
-
for (x <- reversed) {
|
386
|
-
acc = op(x, acc)
|
387
|
-
scanned ::= acc
|
388
|
-
}
|
389
|
-
val b = bf(repr)
|
390
|
-
for (elem <- scanned) b += elem
|
391
|
-
b.result
|
392
|
-
}
|
393
|
-
|
394
|
-
/** Selects the first element of this $coll.
|
395
|
-
* $orderDependent
|
396
|
-
* @return the first element of this $coll.
|
397
|
-
* @throws `NoSuchElementException` if the $coll is empty.
|
398
|
-
*/
|
399
|
-
def head: A = {
|
400
|
-
var result: () => A = () => throw new NoSuchElementException
|
401
|
-
breakable {
|
402
|
-
for (x <- this) {
|
403
|
-
result = () => x
|
404
|
-
break
|
405
|
-
}
|
406
|
-
}
|
407
|
-
result()
|
408
|
-
}
|
409
|
-
|
410
|
-
/** Optionally selects the first element.
|
411
|
-
* $orderDependent
|
412
|
-
* @return the first element of this $coll if it is nonempty, `None` if it is empty.
|
413
|
-
*/
|
414
|
-
def headOption: Option[A] = if (isEmpty) None else Some(head)
|
415
|
-
|
416
|
-
/** Selects all elements except the first.
|
417
|
-
* $orderDependent
|
418
|
-
* @return a $coll consisting of all elements of this $coll
|
419
|
-
* except the first one.
|
420
|
-
* @throws `UnsupportedOperationException` if the $coll is empty.
|
421
|
-
*/
|
422
|
-
override def tail: Repr = {
|
423
|
-
if (isEmpty) throw new UnsupportedOperationException("empty.tail")
|
424
|
-
drop(1)
|
425
|
-
}
|
426
|
-
|
427
|
-
/** Selects the last element.
|
428
|
-
* $orderDependent
|
429
|
-
* @return The last element of this $coll.
|
430
|
-
* @throws NoSuchElementException If the $coll is empty.
|
431
|
-
*/
|
432
|
-
def last: A = {
|
433
|
-
var lst = head
|
434
|
-
for (x <- this)
|
435
|
-
lst = x
|
436
|
-
lst
|
437
|
-
}
|
438
|
-
|
439
|
-
/** Optionally selects the last element.
|
440
|
-
* $orderDependent
|
441
|
-
* @return the last element of this $coll$ if it is nonempty, `None` if it is empty.
|
442
|
-
*/
|
443
|
-
def lastOption: Option[A] = if (isEmpty) None else Some(last)
|
444
|
-
|
445
|
-
/** Selects all elements except the last.
|
446
|
-
* $orderDependent
|
447
|
-
* @return a $coll consisting of all elements of this $coll
|
448
|
-
* except the last one.
|
449
|
-
* @throws `UnsupportedOperationException` if the $coll is empty.
|
450
|
-
*/
|
451
|
-
def init: Repr = {
|
452
|
-
if (isEmpty) throw new UnsupportedOperationException("empty.init")
|
453
|
-
var lst = head
|
454
|
-
var follow = false
|
455
|
-
val b = newBuilder
|
456
|
-
b.sizeHint(this, -1)
|
457
|
-
for (x <- this.seq) {
|
458
|
-
if (follow) b += lst
|
459
|
-
else follow = true
|
460
|
-
lst = x
|
461
|
-
}
|
462
|
-
b.result
|
463
|
-
}
|
464
|
-
|
465
|
-
def take(n: Int): Repr = slice(0, n)
|
466
|
-
|
467
|
-
def drop(n: Int): Repr =
|
468
|
-
if (n <= 0) {
|
469
|
-
val b = newBuilder
|
470
|
-
b.sizeHint(this)
|
471
|
-
b ++= thisCollection result
|
472
|
-
}
|
473
|
-
else sliceWithKnownDelta(n, Int.MaxValue, -n)
|
474
|
-
|
475
|
-
def slice(from: Int, until: Int): Repr = sliceWithKnownBound(math.max(from, 0), until)
|
476
|
-
|
477
|
-
// Precondition: from >= 0, until > 0, builder already configured for building.
|
478
|
-
private[this] def sliceInternal(from: Int, until: Int, b: Builder[A, Repr]): Repr = {
|
479
|
-
var i = 0
|
480
|
-
breakable {
|
481
|
-
for (x <- this.seq) {
|
482
|
-
if (i >= from) b += x
|
483
|
-
i += 1
|
484
|
-
if (i >= until) break
|
485
|
-
}
|
486
|
-
}
|
487
|
-
b.result
|
488
|
-
}
|
489
|
-
// Precondition: from >= 0
|
490
|
-
private[scala] def sliceWithKnownDelta(from: Int, until: Int, delta: Int): Repr = {
|
491
|
-
val b = newBuilder
|
492
|
-
if (until <= from) b.result
|
493
|
-
else {
|
494
|
-
b.sizeHint(this, delta)
|
495
|
-
sliceInternal(from, until, b)
|
496
|
-
}
|
497
|
-
}
|
498
|
-
// Precondition: from >= 0
|
499
|
-
private[scala] def sliceWithKnownBound(from: Int, until: Int): Repr = {
|
500
|
-
val b = newBuilder
|
501
|
-
if (until <= from) b.result
|
502
|
-
else {
|
503
|
-
b.sizeHintBounded(until - from, this)
|
504
|
-
sliceInternal(from, until, b)
|
505
|
-
}
|
506
|
-
}
|
507
|
-
|
508
|
-
def takeWhile(p: A => Boolean): Repr = {
|
509
|
-
val b = newBuilder
|
510
|
-
breakable {
|
511
|
-
for (x <- this) {
|
512
|
-
if (!p(x)) break
|
513
|
-
b += x
|
514
|
-
}
|
515
|
-
}
|
516
|
-
b.result
|
517
|
-
}
|
518
|
-
|
519
|
-
def dropWhile(p: A => Boolean): Repr = {
|
520
|
-
val b = newBuilder
|
521
|
-
var go = false
|
522
|
-
for (x <- this) {
|
523
|
-
if (!p(x)) go = true
|
524
|
-
if (go) b += x
|
525
|
-
}
|
526
|
-
b.result
|
527
|
-
}
|
528
|
-
|
529
|
-
def span(p: A => Boolean): (Repr, Repr) = {
|
530
|
-
val l, r = newBuilder
|
531
|
-
var toLeft = true
|
532
|
-
for (x <- this) {
|
533
|
-
toLeft = toLeft && p(x)
|
534
|
-
(if (toLeft) l else r) += x
|
535
|
-
}
|
536
|
-
(l.result, r.result)
|
537
|
-
}
|
538
|
-
|
539
|
-
def splitAt(n: Int): (Repr, Repr) = {
|
540
|
-
val l, r = newBuilder
|
541
|
-
l.sizeHintBounded(n, this)
|
542
|
-
if (n >= 0) r.sizeHint(this, -n)
|
543
|
-
var i = 0
|
544
|
-
for (x <- this) {
|
545
|
-
(if (i < n) l else r) += x
|
546
|
-
i += 1
|
547
|
-
}
|
548
|
-
(l.result, r.result)
|
549
|
-
}
|
550
|
-
|
551
|
-
/** Iterates over the tails of this $coll. The first value will be this
|
552
|
-
* $coll and the final one will be an empty $coll, with the intervening
|
553
|
-
* values the results of successive applications of `tail`.
|
554
|
-
*
|
555
|
-
* @return an iterator over all the tails of this $coll
|
556
|
-
* @example `List(1,2,3).tails = Iterator(List(1,2,3), List(2,3), List(3), Nil)`
|
557
|
-
*/
|
558
|
-
def tails: Iterator[Repr] = iterateUntilEmpty(_.tail)
|
559
|
-
|
560
|
-
/** Iterates over the inits of this $coll. The first value will be this
|
561
|
-
* $coll and the final one will be an empty $coll, with the intervening
|
562
|
-
* values the results of successive applications of `init`.
|
563
|
-
*
|
564
|
-
* @return an iterator over all the inits of this $coll
|
565
|
-
* @example `List(1,2,3).inits = Iterator(List(1,2,3), List(1,2), List(1), Nil)`
|
566
|
-
*/
|
567
|
-
def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
|
568
|
-
|
569
|
-
/** Copies elements of this $coll to an array.
|
570
|
-
* Fills the given array `xs` with at most `len` elements of
|
571
|
-
* this $coll, starting at position `start`.
|
572
|
-
* Copying will stop once either the end of the current $coll is reached,
|
573
|
-
* or the end of the array is reached, or `len` elements have been copied.
|
574
|
-
*
|
575
|
-
* $willNotTerminateInf
|
576
|
-
*
|
577
|
-
* @param xs the array to fill.
|
578
|
-
* @param start the starting index.
|
579
|
-
* @param len the maximal number of elements to copy.
|
580
|
-
* @tparam B the type of the elements of the array.
|
581
|
-
*
|
582
|
-
*
|
583
|
-
* @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
|
584
|
-
*/
|
585
|
-
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
|
586
|
-
var i = start
|
587
|
-
val end = (start + len) min xs.length
|
588
|
-
breakable {
|
589
|
-
for (x <- this) {
|
590
|
-
if (i >= end) break
|
591
|
-
xs(i) = x
|
592
|
-
i += 1
|
593
|
-
}
|
594
|
-
}
|
595
|
-
}
|
596
|
-
|
597
|
-
def toTraversable: Traversable[A] = thisCollection
|
598
|
-
def toIterator: Iterator[A] = toStream.iterator
|
599
|
-
def toStream: Stream[A] = toBuffer.toStream
|
600
|
-
|
601
|
-
/** Converts this $coll to a string.
|
602
|
-
*
|
603
|
-
* @return a string representation of this collection. By default this
|
604
|
-
* string consists of the `stringPrefix` of this $coll,
|
605
|
-
* followed by all elements separated by commas and enclosed in parentheses.
|
606
|
-
*/
|
607
|
-
override def toString = mkString(stringPrefix + "(", ", ", ")")
|
608
|
-
|
609
|
-
/** Defines the prefix of this object's `toString` representation.
|
610
|
-
*
|
611
|
-
* @return a string representation which starts the result of `toString`
|
612
|
-
* applied to this $coll. By default the string prefix is the
|
613
|
-
* simple name of the collection class $coll.
|
614
|
-
*/
|
615
|
-
def stringPrefix : String = {
|
616
|
-
var string = repr.asInstanceOf[AnyRef].getClass.getName
|
617
|
-
val idx1 = string.lastIndexOf('.' : Int)
|
618
|
-
if (idx1 != -1) string = string.substring(idx1 + 1)
|
619
|
-
val idx2 = string.indexOf('$')
|
620
|
-
if (idx2 != -1) string = string.substring(0, idx2)
|
621
|
-
string
|
622
|
-
}
|
623
|
-
|
624
|
-
/** Creates a non-strict view of this $coll.
|
625
|
-
*
|
626
|
-
* @return a non-strict view of this $coll.
|
627
|
-
*/
|
628
|
-
def view = new TraversableView[A, Repr] {
|
629
|
-
protected lazy val underlying = self.repr
|
630
|
-
override def foreach[U](f: A => U) = self foreach f
|
631
|
-
}
|
632
|
-
|
633
|
-
/** Creates a non-strict view of a slice of this $coll.
|
634
|
-
*
|
635
|
-
* Note: the difference between `view` and `slice` is that `view` produces
|
636
|
-
* a view of the current $coll, whereas `slice` produces a new $coll.
|
637
|
-
*
|
638
|
-
* Note: `view(from, to)` is equivalent to `view.slice(from, to)`
|
639
|
-
* $orderDependent
|
640
|
-
*
|
641
|
-
* @param from the index of the first element of the view
|
642
|
-
* @param until the index of the element following the view
|
643
|
-
* @return a non-strict view of a slice of this $coll, starting at index `from`
|
644
|
-
* and extending up to (but not including) index `until`.
|
645
|
-
*/
|
646
|
-
def view(from: Int, until: Int): TraversableView[A, Repr] = view.slice(from, until)
|
647
|
-
|
648
|
-
/** Creates a non-strict filter of this $coll.
|
649
|
-
*
|
650
|
-
* Note: the difference between `c filter p` and `c withFilter p` is that
|
651
|
-
* the former creates a new collection, whereas the latter only
|
652
|
-
* restricts the domain of subsequent `map`, `flatMap`, `foreach`,
|
653
|
-
* and `withFilter` operations.
|
654
|
-
* $orderDependent
|
655
|
-
*
|
656
|
-
* @param p the predicate used to test elements.
|
657
|
-
* @return an object of class `WithFilter`, which supports
|
658
|
-
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
659
|
-
* All these operations apply to those elements of this $coll which
|
660
|
-
* satisfy the predicate `p`.
|
661
|
-
*/
|
662
|
-
def withFilter(p: A => Boolean): FilterMonadic[A, Repr] = new WithFilter(p)
|
663
|
-
|
664
|
-
/** A class supporting filtered operations. Instances of this class are
|
665
|
-
* returned by method `withFilter`.
|
666
|
-
*/
|
667
|
-
class WithFilter(p: A => Boolean) extends FilterMonadic[A, Repr] {
|
668
|
-
|
669
|
-
/** Builds a new collection by applying a function to all elements of the
|
670
|
-
* outer $coll containing this `WithFilter` instance that satisfy predicate `p`.
|
671
|
-
*
|
672
|
-
* @param f the function to apply to each element.
|
673
|
-
* @tparam B the element type of the returned collection.
|
674
|
-
* @tparam That $thatinfo
|
675
|
-
* @param bf $bfinfo
|
676
|
-
* @return a new collection of type `That` resulting from applying
|
677
|
-
* the given function `f` to each element of the outer $coll
|
678
|
-
* that satisfies predicate `p` and collecting the results.
|
679
|
-
*
|
680
|
-
* @usecase def map[B](f: A => B): $Coll[B]
|
681
|
-
*
|
682
|
-
* @return a new $coll resulting from applying the given function
|
683
|
-
* `f` to each element of the outer $coll that satisfies
|
684
|
-
* predicate `p` and collecting the results.
|
685
|
-
*/
|
686
|
-
def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
687
|
-
val b = bf(repr)
|
688
|
-
for (x <- self)
|
689
|
-
if (p(x)) b += f(x)
|
690
|
-
b.result
|
691
|
-
}
|
692
|
-
|
693
|
-
/** Builds a new collection by applying a function to all elements of the
|
694
|
-
* outer $coll containing this `WithFilter` instance that satisfy
|
695
|
-
* predicate `p` and concatenating the results.
|
696
|
-
*
|
697
|
-
* @param f the function to apply to each element.
|
698
|
-
* @tparam B the element type of the returned collection.
|
699
|
-
* @tparam That $thatinfo
|
700
|
-
* @param bf $bfinfo
|
701
|
-
* @return a new collection of type `That` resulting from applying
|
702
|
-
* the given collection-valued function `f` to each element
|
703
|
-
* of the outer $coll that satisfies predicate `p` and
|
704
|
-
* concatenating the results.
|
705
|
-
*
|
706
|
-
* @usecase def flatMap[B](f: A => TraversableOnce[B]): $Coll[B]
|
707
|
-
*
|
708
|
-
* @return a new $coll resulting from applying the given collection-valued function
|
709
|
-
* `f` to each element of the outer $coll that satisfies predicate `p` and concatenating the results.
|
710
|
-
*/
|
711
|
-
def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
|
712
|
-
val b = bf(repr)
|
713
|
-
for (x <- self)
|
714
|
-
if (p(x)) b ++= f(x).seq
|
715
|
-
b.result
|
716
|
-
}
|
717
|
-
|
718
|
-
/** Applies a function `f` to all elements of the outer $coll containing
|
719
|
-
* this `WithFilter` instance that satisfy predicate `p`.
|
720
|
-
*
|
721
|
-
* @param f the function that is applied for its side-effect to every element.
|
722
|
-
* The result of function `f` is discarded.
|
723
|
-
*
|
724
|
-
* @tparam U the type parameter describing the result of function `f`.
|
725
|
-
* This result will always be ignored. Typically `U` is `Unit`,
|
726
|
-
* but this is not necessary.
|
727
|
-
*
|
728
|
-
* @usecase def foreach(f: A => Unit): Unit
|
729
|
-
*/
|
730
|
-
def foreach[U](f: A => U): Unit =
|
731
|
-
for (x <- self)
|
732
|
-
if (p(x)) f(x)
|
733
|
-
|
734
|
-
/** Further refines the filter for this $coll.
|
735
|
-
*
|
736
|
-
* @param q the predicate used to test elements.
|
737
|
-
* @return an object of class `WithFilter`, which supports
|
738
|
-
* `map`, `flatMap`, `foreach`, and `withFilter` operations.
|
739
|
-
* All these operations apply to those elements of this $coll which
|
740
|
-
* satisfy the predicate `q` in addition to the predicate `p`.
|
741
|
-
*/
|
742
|
-
def withFilter(q: A => Boolean): WithFilter =
|
743
|
-
new WithFilter(x => p(x) && q(x))
|
744
|
-
}
|
745
|
-
|
746
|
-
// A helper for tails and inits.
|
747
|
-
private def iterateUntilEmpty(f: Traversable[A @uV] => Traversable[A @uV]): Iterator[Repr] = {
|
748
|
-
val it = Iterator.iterate(thisCollection)(f) takeWhile (x => !x.isEmpty)
|
749
|
-
it ++ Iterator(Nil) map (newBuilder ++= _ result)
|
750
|
-
}
|
751
|
-
}
|
752
|
-
|
753
|
-
|
754
|
-
</textarea>
|
755
|
-
</form>
|
756
|
-
|
757
|
-
<script>
|
758
|
-
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
759
|
-
lineNumbers: true,
|
760
|
-
matchBrackets: true,
|
761
|
-
theme: "ambiance",
|
762
|
-
mode: "text/x-scala"
|
763
|
-
});
|
764
|
-
</script>
|
765
|
-
</body>
|
766
|
-
</html>
|