mll 2.4.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +20 -15
- data/Gemfile.lock +5 -2
- data/README.md +2 -172
- data/Rakefile +14 -22
- data/TODO.md +169 -0
- data/core_ext.rb +3 -0
- data/lib/mll.rb +14 -1
- data/mll.gemspec +1 -1
- data/spec/_spec.rb +31 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eaa6d43148b9cdf889647a63e9e8661629d776c
|
4
|
+
data.tar.gz: 53ad8127bbbc75b201bf98c316042281fdb97390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 622ac74b5373d2ef998ac01d1f834aeba929ae7a368a5f49b5ca1143ec07ce9dfaf8143486539859d7f79e4931c94e930828d6c3eeea518f36d2b26b9c6f77c4
|
7
|
+
data.tar.gz: c84783d82d35568dc977fe689483c173afaa9d3159053454796f1a9b06cc80cdb3d89259fd875af4677755e9de43961d7ba87ae1cf4b0f4e7ff0b0f5f590c084
|
data/.travis.yml
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- 2.0.0
|
6
|
+
- 2.0.0-p451 # OS X 10.9.4
|
7
|
+
- 2.1.0
|
8
|
+
- 2.1.2
|
9
|
+
- 2.1.3
|
10
|
+
- "2.1"
|
11
|
+
- 2.2.0
|
12
|
+
- "2.2"
|
13
|
+
- ruby-head
|
14
|
+
- jruby-19mode
|
15
|
+
- jruby-head
|
16
|
+
- rbx
|
17
|
+
- rbx-2
|
18
|
+
# jdk:
|
19
|
+
# - openjdk7
|
20
|
+
# - oraclejdk7
|
21
|
+
# - oraclejdk8
|
22
|
+
# - openjdk6
|
18
23
|
os:
|
19
24
|
- linux
|
20
25
|
- osx
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mll (2.
|
4
|
+
mll (2.5.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -25,6 +25,9 @@ PLATFORMS
|
|
25
25
|
ruby
|
26
26
|
|
27
27
|
DEPENDENCIES
|
28
|
-
bundler (~> 1.
|
28
|
+
bundler (~> 1.12.0)
|
29
29
|
mll!
|
30
30
|
rspec (~> 3.3.0)
|
31
|
+
|
32
|
+
BUNDLED WITH
|
33
|
+
1.12.3
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
# MLL (Mathematica Language Library)
|
1
|
+
# MLL (Wolfram Mathematica Language Library)
|
2
2
|
|
3
|
+
[![Join the chat at https://gitter.im/Nakilon/mll](https://badges.gitter.im/Nakilon/mll.svg)](https://gitter.im/Nakilon/mll?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
3
4
|
[![Gem Version](https://badge.fury.io/rb/mll.svg)](http://badge.fury.io/rb/mll)
|
4
5
|
[![Build Status](https://travis-ci.org/Nakilon/mll.svg)](https://travis-ci.org/Nakilon/mll)
|
5
6
|
|
@@ -120,174 +121,3 @@ or
|
|
120
121
|
or
|
121
122
|
|
122
123
|
rake # to implicitly run 'rake todo'
|
123
|
-
|
124
|
-
### TODO (this section is filled automatically by `rake todo` task -- do not remove)
|
125
|
-
|
126
|
-
#### lib/mll.rb
|
127
|
-
|
128
|
-
```
|
129
|
-
module MLL
|
130
|
-
class << self
|
131
|
-
def dimensions
|
132
|
-
lambda do |list, limit = nil|
|
133
|
-
enumerator = Enumerator.new do |e|
|
134
|
-
while list.all?{ |i| i.respond_to? :each } &&
|
135
|
-
# TODO refactor into depth-first yielding
|
136
|
-
def nest_while
|
137
|
-
# TODO finish me
|
138
|
-
def fold_list
|
139
|
-
lambda do |x, list, f = nil|
|
140
|
-
# TODO use Ruby#inject ?
|
141
|
-
def map
|
142
|
-
# TODO validate depths
|
143
|
-
# TODO break on passing all depths
|
144
|
-
def table
|
145
|
-
lambda do |f, *args|
|
146
|
-
[].tap do |result|
|
147
|
-
}]].tap do |stack|
|
148
|
-
stack.each do |ai, ri|
|
149
|
-
# TODO try to make #table lazy (Enumerator instead of Array)
|
150
|
-
def grid
|
151
|
-
lambda do |table, **options|
|
152
|
-
# TODO negative spacings?
|
153
|
-
# TODO smth with this #.all?
|
154
|
-
# TODO https://reference.wolfram.com/language/ref/Alignment.html
|
155
|
-
def riffle
|
156
|
-
lambda do |*args|
|
157
|
-
case args.size
|
158
|
-
when 3
|
159
|
-
Enumerator.new do |e|
|
160
|
-
args[0].each_with_index do |x, i|
|
161
|
-
# TODO make it not destructive
|
162
|
-
# TODO not sure if we need any other kind of Listability except of #range[[Array]]
|
163
|
-
# TODO #power[]
|
164
|
-
```
|
165
|
-
|
166
|
-
#### spec/_spec.rb
|
167
|
-
|
168
|
-
```
|
169
|
-
# TODO move Properties & Relations to some separate contexts maybe
|
170
|
-
# TODO @fraggedICE wishes using Rational -- would also allow implementing more examples
|
171
|
-
# TODO elegantly get rid of repetitive type checks
|
172
|
-
# TODO ? let(:fake_lambda){ ->(*args){fail} }
|
173
|
-
# TODO rewrite all Lazy#to_a into Lazy#force (it's not recursive and not documented)
|
174
|
-
# TODO maybe make indexes count from 0 not 1
|
175
|
-
# TODO merge similar examples
|
176
|
-
# TODO deprecate tests that would obviously fail another tests
|
177
|
-
# TODO check if we check for ArgumentError without being sure we raise it
|
178
|
-
describe MLL do
|
179
|
-
describe "List Manipulation" do
|
180
|
-
describe "Constructing Lists" do
|
181
|
-
describe "#table" do
|
182
|
-
describe "Scope:" do
|
183
|
-
# TODO: "Make a triangular array:"
|
184
|
-
describe "#range" do
|
185
|
-
# TODO take from docs more examples that involve other functions
|
186
|
-
describe "Rearranging & Restructuring Lists" do
|
187
|
-
describe "#riffle" do
|
188
|
-
describe "Scope:" do
|
189
|
-
example "intersperse two lists" do
|
190
|
-
# TODO check how it works for list2.size == list1.size + 1 in Mathematica
|
191
|
-
describe "Applying Functions to Lists" do
|
192
|
-
describe "#fold_list" do
|
193
|
-
describe "Applications:" do
|
194
|
-
# TODO maybe move it to README.md
|
195
|
-
describe "#map" do
|
196
|
-
# TODO we'll need less nested mappings when we implement stop on depths depletion
|
197
|
-
describe "Details:" do
|
198
|
-
example "levels n1 though n2" do
|
199
|
-
expect(map[[1,[2,[3,[4,[5,6]]]]], [2,4], ->(i){ [i] }].
|
200
|
-
# TODO smth _<>
|
201
|
-
# TODO "Level corresponds to the whole expression"
|
202
|
-
# TODO currying "Map[f][expr] is equivalent to Map[f,expr]"
|
203
|
-
describe "Scope:" do
|
204
|
-
# TODO "Map on all levels, starting at level" ant other about Infinity
|
205
|
-
describe "Properties & Relations:" do
|
206
|
-
# TODO #mapall
|
207
|
-
# TODO #mapthread ?
|
208
|
-
# TODO #mapindexed ?
|
209
|
-
# TODO "negative levels"
|
210
|
-
describe "Elements of Lists" do
|
211
|
-
# TODO #rest
|
212
|
-
# TODO http://reference.wolfram.com/language/guide/RearrangingAndRestructuringLists.html
|
213
|
-
# TODO http://reference.wolfram.com/language/guide/MathematicalAndCountingOperationsOnLists.html
|
214
|
-
describe "Functional Programming" do
|
215
|
-
describe "Iteratively Applying Functions" do
|
216
|
-
# TODO move #nest_list and #fold_list and others here?
|
217
|
-
# TODO examples in README.rb
|
218
|
-
describe "#nest_while" do
|
219
|
-
# TODO examples to README.md
|
220
|
-
describe "Details:" do
|
221
|
-
# TODO a lot
|
222
|
-
describe "Scope:" do
|
223
|
-
# TODO "always compare all values generated" do
|
224
|
-
# TODO "compare the last two values generated" do
|
225
|
-
# TODO "start comparisons after 4 iterations, and compare using the 4 last values" do
|
226
|
-
# TODO "start comparisons after 4 iterations, and compare using the 6 last values" do
|
227
|
-
# TODO example "stop after at most 4 iterations, even if the test is still true" do
|
228
|
-
describe "Generalizations & Extensions:" do
|
229
|
-
# TODO "return the last value for which the condition was still true" do
|
230
|
-
describe "Applications:" do
|
231
|
-
# TODO example "find the next twin prime after 888" do
|
232
|
-
describe "Properties & Relations:" do
|
233
|
-
# TODO "#nest_while can be expressed in terms of a while loop" do
|
234
|
-
describe "Numerical Data" do
|
235
|
-
describe "#mean" do
|
236
|
-
# TODO examples to README.md
|
237
|
-
describe "Grids & Tables" do
|
238
|
-
describe "#grid" do
|
239
|
-
describe "Details:" do
|
240
|
-
# TODO SpanFromLeft SpanFromAbove SpanFromBoth
|
241
|
-
# TODO The following options can be given
|
242
|
-
# TODO Common settings for Frame
|
243
|
-
# TODO The spec(k) can have the following forms
|
244
|
-
# TODO With ItemSize->Automatic will break elements across multiple lines
|
245
|
-
# TODO "settings can be used for BaselinePosition" do
|
246
|
-
describe "Scope:" do
|
247
|
-
# TODO Draw all the frames in red
|
248
|
-
# TODO Put a frame around the first row and column
|
249
|
-
# TODO Draw different frames with different styles
|
250
|
-
# TODO Put dividers at all horizontal positions
|
251
|
-
# TODO Put dividers at all vertical positions
|
252
|
-
# TODO Put dividers at the third horizontal and second vertical positions
|
253
|
-
# TODO Make the element 4 span the column to its right
|
254
|
-
# TODO Make it span three rows
|
255
|
-
# TODO Span throughout a 2×2 block
|
256
|
-
# TODO Draw the grid with a pink background
|
257
|
-
# TODO Alternating pink and yellow at successive horizontal positions
|
258
|
-
# TODO Alternating pink and yellow at successive vertical positions
|
259
|
-
# TODO Make the grid contents red
|
260
|
-
# TODO "grids can be nested" do
|
261
|
-
describe "Options:" do
|
262
|
-
# TODO "align elements around the center of the grid" do
|
263
|
-
# TODO "align numbers on the decimal point" do
|
264
|
-
# TODO draw the grid with a pink background
|
265
|
-
# TODO Pink and gray backgrounds for the first and second columns
|
266
|
-
# TODO An equivalent syntax
|
267
|
-
# TODO Pink and gray backgrounds for the first and second rows
|
268
|
-
# TODO Alternating pink and gray backgrounds
|
269
|
-
# TODO Alternating backgrounds with yellow superimposed in the first and last positions
|
270
|
-
# TODO Set the background for specific items
|
271
|
-
# TODO Set the background for a subregion of the grid
|
272
|
-
# TODO Draw all interior dividers
|
273
|
-
# TODO Draw a divider at every other horizontal position
|
274
|
-
# TODO Include the final position
|
275
|
-
# TODO Draw dividers with specified styles
|
276
|
-
# TODO "frame specific elements" do
|
277
|
-
# TODO "frame a region" do
|
278
|
-
# TODO "make each item a fixed number of character-widths wide" do
|
279
|
-
# TODO "ItemSize->All makes all items the same size" do
|
280
|
-
# TODO "prevent line-wrapping" do
|
281
|
-
# TODO "set one overall style for grid items" do
|
282
|
-
# TODO "style specific elements" do
|
283
|
-
# TODO "style a region" do
|
284
|
-
# TODO "insert no additional space between rows or columns" do
|
285
|
-
# TODO "specify spacing with numeric values" do
|
286
|
-
# TODO "use different spacings at the first vertical divider" do
|
287
|
-
describe "Properties & Relations:" do
|
288
|
-
# TODO "the elements of a Grid can be extracted with #[]" do
|
289
|
-
describe "Neat examples:" do
|
290
|
-
# TODO "a Sudoku grid" do
|
291
|
-
# TODO http://reference.wolfram.com/language/guide/HandlingArraysOfData.html
|
292
|
-
# TODO http://reference.wolfram.com/language/guide/ComputationWithStructuredDatasets.html
|
293
|
-
```
|
data/Rakefile
CHANGED
@@ -1,34 +1,26 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
task :default => %w{ spec todo }
|
4
|
+
|
2
5
|
require "rspec/core/rake_task"
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
7
|
+
t.verbose = false
|
8
|
+
end
|
3
9
|
|
4
|
-
desc "
|
10
|
+
desc "Generate TODO.md"
|
5
11
|
task :todo do |t|
|
6
|
-
|
7
|
-
File.open("README.md", "r+") do |readme_file|
|
8
|
-
# begin readme_file.gets end until $_[/^## TODO/]
|
9
|
-
readme_file.gets "### TODO"
|
10
|
-
readme_file.gets
|
12
|
+
File.open("TODO.md", "w") do |readme_file|
|
11
13
|
%w{ lib/mll.rb spec/_spec.rb }.each do |file|
|
12
|
-
readme_file.puts "
|
14
|
+
readme_file.puts "#### #{file}\n\n```"
|
13
15
|
stack = []
|
14
16
|
File.foreach(file) do |line|
|
15
17
|
next unless shift = /\S/ =~ line
|
16
|
-
depth = shift / 2
|
17
|
-
stack
|
18
|
-
|
19
|
-
readme_file.puts stack.take(depth + 1).compact
|
20
|
-
stack.clear
|
21
|
-
end
|
18
|
+
next unless (stack[depth = shift / 2] = line)[/^\s*# TODO/]
|
19
|
+
readme_file.puts stack.take(depth + 1).compact
|
20
|
+
stack.clear
|
22
21
|
end
|
23
|
-
readme_file.puts "
|
22
|
+
readme_file.puts "```\n\n"
|
24
23
|
end
|
25
|
-
readme_file.truncate readme_file.pos
|
26
24
|
end
|
27
|
-
puts `md5
|
25
|
+
# puts `md5 TODO.md`
|
28
26
|
end
|
29
|
-
|
30
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
31
|
-
t.verbose = false
|
32
|
-
end
|
33
|
-
|
34
|
-
task :default => %w{ spec todo }
|
data/TODO.md
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
#### lib/mll.rb
|
2
|
+
|
3
|
+
```
|
4
|
+
module MLL
|
5
|
+
class << self
|
6
|
+
def dimensions
|
7
|
+
lambda do |list, limit = nil|
|
8
|
+
enumerator = Enumerator.new do |e|
|
9
|
+
while list.all?{ |i| i.respond_to? :each } &&
|
10
|
+
# TODO refactor into depth-first yielding
|
11
|
+
def nest_while
|
12
|
+
# TODO finish me
|
13
|
+
def fold_list
|
14
|
+
lambda do |x, list, f = nil|
|
15
|
+
# TODO use Ruby#inject ?
|
16
|
+
def map
|
17
|
+
# TODO validate depths
|
18
|
+
# TODO break on passing all depths
|
19
|
+
def table
|
20
|
+
lambda do |f, *args|
|
21
|
+
[].tap do |result|
|
22
|
+
}]].tap do |stack|
|
23
|
+
stack.each do |ai, ri|
|
24
|
+
# TODO try to make #table lazy (Enumerator instead of Array)
|
25
|
+
def grid
|
26
|
+
lambda do |table, **options|
|
27
|
+
# TODO negative spacings?
|
28
|
+
# TODO smth with this #.all?
|
29
|
+
# TODO https://reference.wolfram.com/language/ref/Alignment.html
|
30
|
+
def riffle
|
31
|
+
lambda do |*args|
|
32
|
+
case args.size
|
33
|
+
when 3
|
34
|
+
Enumerator.new do |e|
|
35
|
+
args[0].each_with_index do |x, i|
|
36
|
+
# TODO make it not destructive
|
37
|
+
# TODO not sure if we need any other kind of Listability except of #range[[Array]]
|
38
|
+
# TODO #power[]
|
39
|
+
```
|
40
|
+
|
41
|
+
#### spec/_spec.rb
|
42
|
+
|
43
|
+
```
|
44
|
+
# TODO move Properties & Relations to some separate contexts maybe
|
45
|
+
# TODO @fraggedICE wishes using Rational -- would also allow implementing more examples
|
46
|
+
# TODO elegantly get rid of repetitive type checks
|
47
|
+
# TODO ? let(:fake_lambda){ ->(*args){fail} }
|
48
|
+
# TODO rewrite all Lazy#to_a into Lazy#force (it's not recursive and not documented)
|
49
|
+
# TODO maybe make indexes count from 0 not 1
|
50
|
+
# TODO merge similar examples
|
51
|
+
# TODO deprecate tests that would obviously fail another tests
|
52
|
+
# TODO check if we check for ArgumentError without being sure we raise it
|
53
|
+
describe MLL do
|
54
|
+
describe "List Manipulation" do
|
55
|
+
describe "Constructing Lists" do
|
56
|
+
describe "#table" do
|
57
|
+
describe "Scope:" do
|
58
|
+
# TODO: "Make a triangular array:"
|
59
|
+
describe "#range" do
|
60
|
+
# TODO take from docs more examples that involve other functions
|
61
|
+
describe "Rearranging & Restructuring Lists" do
|
62
|
+
describe "#riffle" do
|
63
|
+
describe "Scope:" do
|
64
|
+
example "intersperse two lists" do
|
65
|
+
# TODO check how it works for list2.size == list1.size + 1 in Mathematica
|
66
|
+
describe "Applying Functions to Lists" do
|
67
|
+
describe "#fold_list" do
|
68
|
+
describe "Applications:" do
|
69
|
+
# TODO maybe move it to README.md
|
70
|
+
describe "#map" do
|
71
|
+
# TODO we'll need less nested mappings when we implement stop on depths depletion
|
72
|
+
describe "Details:" do
|
73
|
+
example "levels n1 though n2" do
|
74
|
+
expect(map[[1,[2,[3,[4,[5,6]]]]], [2,4], ->(i){ [i] }].
|
75
|
+
# TODO smth _<>
|
76
|
+
# TODO "Level corresponds to the whole expression"
|
77
|
+
# TODO currying "Map[f][expr] is equivalent to Map[f,expr]"
|
78
|
+
describe "Scope:" do
|
79
|
+
# TODO "Map on all levels, starting at level" ant other about Infinity
|
80
|
+
describe "Properties & Relations:" do
|
81
|
+
# TODO #mapall
|
82
|
+
# TODO #mapthread ?
|
83
|
+
# TODO #mapindexed ?
|
84
|
+
# TODO "negative levels"
|
85
|
+
describe "Elements of Lists" do
|
86
|
+
# TODO #rest
|
87
|
+
# TODO http://reference.wolfram.com/language/guide/RearrangingAndRestructuringLists.html
|
88
|
+
# TODO http://reference.wolfram.com/language/guide/MathematicalAndCountingOperationsOnLists.html
|
89
|
+
describe "Functional Programming" do
|
90
|
+
describe "Iteratively Applying Functions" do
|
91
|
+
# TODO move #nest_list and #fold_list and others here?
|
92
|
+
# TODO examples in README.rb
|
93
|
+
describe "#nest_while" do
|
94
|
+
# TODO examples to README.md
|
95
|
+
describe "Details:" do
|
96
|
+
# TODO a lot
|
97
|
+
describe "Scope:" do
|
98
|
+
# TODO "always compare all values generated" do
|
99
|
+
# TODO "compare the last two values generated" do
|
100
|
+
# TODO "start comparisons after 4 iterations, and compare using the 4 last values" do
|
101
|
+
# TODO "start comparisons after 4 iterations, and compare using the 6 last values" do
|
102
|
+
# TODO example "stop after at most 4 iterations, even if the test is still true" do
|
103
|
+
describe "Generalizations & Extensions:" do
|
104
|
+
# TODO "return the last value for which the condition was still true" do
|
105
|
+
describe "Applications:" do
|
106
|
+
# TODO example "find the next twin prime after 888" do
|
107
|
+
describe "Properties & Relations:" do
|
108
|
+
# TODO "#nest_while can be expressed in terms of a while loop" do
|
109
|
+
describe "Numerical Data" do
|
110
|
+
describe "#mean" do
|
111
|
+
# TODO examples to README.md
|
112
|
+
describe "Grids & Tables" do
|
113
|
+
describe "#grid" do
|
114
|
+
describe "Details:" do
|
115
|
+
# TODO SpanFromLeft SpanFromAbove SpanFromBoth
|
116
|
+
# TODO The following options can be given
|
117
|
+
# TODO Common settings for Frame
|
118
|
+
# TODO The spec(k) can have the following forms
|
119
|
+
# TODO With ItemSize->Automatic will break elements across multiple lines
|
120
|
+
# TODO "settings can be used for BaselinePosition" do
|
121
|
+
describe "Scope:" do
|
122
|
+
# TODO Draw all the frames in red
|
123
|
+
# TODO Put a frame around the first row and column
|
124
|
+
# TODO Draw different frames with different styles
|
125
|
+
# TODO Put dividers at all horizontal positions
|
126
|
+
# TODO Put dividers at all vertical positions
|
127
|
+
# TODO Put dividers at the third horizontal and second vertical positions
|
128
|
+
# TODO Make the element 4 span the column to its right
|
129
|
+
# TODO Make it span three rows
|
130
|
+
# TODO Span throughout a 2×2 block
|
131
|
+
# TODO Draw the grid with a pink background
|
132
|
+
# TODO Alternating pink and yellow at successive horizontal positions
|
133
|
+
# TODO Alternating pink and yellow at successive vertical positions
|
134
|
+
# TODO Make the grid contents red
|
135
|
+
# TODO "grids can be nested" do
|
136
|
+
describe "Options:" do
|
137
|
+
# TODO "align elements around the center of the grid" do
|
138
|
+
# TODO "align numbers on the decimal point" do
|
139
|
+
# TODO draw the grid with a pink background
|
140
|
+
# TODO Pink and gray backgrounds for the first and second columns
|
141
|
+
# TODO An equivalent syntax
|
142
|
+
# TODO Pink and gray backgrounds for the first and second rows
|
143
|
+
# TODO Alternating pink and gray backgrounds
|
144
|
+
# TODO Alternating backgrounds with yellow superimposed in the first and last positions
|
145
|
+
# TODO Set the background for specific items
|
146
|
+
# TODO Set the background for a subregion of the grid
|
147
|
+
# TODO Draw all interior dividers
|
148
|
+
# TODO Draw a divider at every other horizontal position
|
149
|
+
# TODO Include the final position
|
150
|
+
# TODO Draw dividers with specified styles
|
151
|
+
# TODO "frame specific elements" do
|
152
|
+
# TODO "frame a region" do
|
153
|
+
# TODO "make each item a fixed number of character-widths wide" do
|
154
|
+
# TODO "ItemSize->All makes all items the same size" do
|
155
|
+
# TODO "prevent line-wrapping" do
|
156
|
+
# TODO "set one overall style for grid items" do
|
157
|
+
# TODO "style specific elements" do
|
158
|
+
# TODO "style a region" do
|
159
|
+
# TODO "insert no additional space between rows or columns" do
|
160
|
+
# TODO "specify spacing with numeric values" do
|
161
|
+
# TODO "use different spacings at the first vertical divider" do
|
162
|
+
describe "Properties & Relations:" do
|
163
|
+
# TODO "the elements of a Grid can be extracted with #[]" do
|
164
|
+
describe "Neat examples:" do
|
165
|
+
# TODO "a Sudoku grid" do
|
166
|
+
# TODO http://reference.wolfram.com/language/guide/HandlingArraysOfData.html
|
167
|
+
# TODO http://reference.wolfram.com/language/guide/ComputationWithStructuredDatasets.html
|
168
|
+
```
|
169
|
+
|
data/core_ext.rb
CHANGED
data/lib/mll.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module MLL
|
2
2
|
|
3
|
-
VERSION = "2.
|
3
|
+
VERSION = "2.5.0"
|
4
4
|
|
5
5
|
class << self
|
6
6
|
|
@@ -212,6 +212,19 @@ module MLL
|
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
+
def rest
|
216
|
+
lambda do |list|
|
217
|
+
Enumerator.new do |e|
|
218
|
+
begin
|
219
|
+
enum = list.to_enum.tap &:next
|
220
|
+
loop{ e << enum.next }
|
221
|
+
rescue StopIteration
|
222
|
+
next
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
215
228
|
end
|
216
229
|
|
217
230
|
def self.define_listable_function name, &block
|
data/mll.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.test_files = ["spec/"]
|
14
14
|
# spec.require_paths = ["lib"]
|
15
15
|
|
16
|
-
spec.add_development_dependency "bundler", "~> 1.
|
16
|
+
spec.add_development_dependency "bundler", "~> 1.12.0"
|
17
17
|
# spec.add_development_dependency "rake", "~> 10.0"
|
18
18
|
spec.add_development_dependency "rspec", "~> 3.3.0"
|
19
19
|
|
data/spec/_spec.rb
CHANGED
@@ -822,7 +822,37 @@ describe MLL do
|
|
822
822
|
|
823
823
|
end
|
824
824
|
|
825
|
-
#
|
825
|
+
# https://reference.wolfram.com/language/ref/Rest.html
|
826
|
+
describe "#rest" do
|
827
|
+
|
828
|
+
describe "Basic Examples:" do
|
829
|
+
|
830
|
+
example "???" do
|
831
|
+
expect(rest[[1,2,3,4]]).to be_a Enumerator
|
832
|
+
expect(rest[[1,2,3,4]].to_a).to eq [2,3,4]
|
833
|
+
end
|
834
|
+
|
835
|
+
end
|
836
|
+
|
837
|
+
describe "Applications:" do
|
838
|
+
|
839
|
+
example "nest the operation of finding the rest of a list" do
|
840
|
+
expect(nest_list[[1,2,3,4,5], 3, rest]).to be_a Enumerator
|
841
|
+
expect(nest_list[[1,2,3,4,5], 3, rest].map(&:to_a)).to eq [[1,2,3,4,5], [2,3,4,5], [3,4,5], [4,5]]
|
842
|
+
end
|
843
|
+
|
844
|
+
end
|
845
|
+
|
846
|
+
describe "Properties & Relations:" do
|
847
|
+
|
848
|
+
example "#rest is equivalent to Array#drop(1)" do
|
849
|
+
expect(rest[[1,2,3,4]]).to be_a Enumerator
|
850
|
+
expect(rest[[1,2,3,4]].to_a).to eq [1,2,3,4].drop 1
|
851
|
+
end
|
852
|
+
|
853
|
+
end
|
854
|
+
|
855
|
+
end
|
826
856
|
|
827
857
|
# https://reference.wolfram.com/language/ref/Dimensions.html
|
828
858
|
describe "#dimensions" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.12.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.12.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- Gemfile.lock
|
52
52
|
- README.md
|
53
53
|
- Rakefile
|
54
|
+
- TODO.md
|
54
55
|
- core_ext.rb
|
55
56
|
- lib/mll.rb
|
56
57
|
- mll.gemspec
|