nydp 0.4.2 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +44 -0
  3. data/lib/lisp/core-010-precompile.nydp +13 -16
  4. data/lib/lisp/core-012-utils.nydp +3 -2
  5. data/lib/lisp/core-015-documentation.nydp +54 -23
  6. data/lib/lisp/core-017-builtin-dox.nydp +14 -12
  7. data/lib/lisp/core-020-utils.nydp +5 -5
  8. data/lib/lisp/core-030-syntax.nydp +166 -72
  9. data/lib/lisp/core-035-flow-control.nydp +38 -11
  10. data/lib/lisp/core-037-list-utils.nydp +12 -0
  11. data/lib/lisp/core-039-module.nydp +24 -0
  12. data/lib/lisp/core-040-utils.nydp +32 -12
  13. data/lib/lisp/core-041-string-utils.nydp +25 -1
  14. data/lib/lisp/core-042-date-utils.nydp +21 -1
  15. data/lib/lisp/core-043-list-utils.nydp +96 -64
  16. data/lib/lisp/core-070-prefix-list.nydp +1 -1
  17. data/lib/lisp/core-080-pretty-print.nydp +57 -17
  18. data/lib/lisp/core-090-hook.nydp +35 -1
  19. data/lib/lisp/core-100-utils.nydp +82 -2
  20. data/lib/lisp/core-110-hash-utils.nydp +56 -2
  21. data/lib/lisp/core-120-settings.nydp +16 -5
  22. data/lib/lisp/core-130-validations.nydp +51 -0
  23. data/lib/lisp/core-900-benchmarking.nydp +78 -20
  24. data/lib/lisp/tests/accum-examples.nydp +28 -1
  25. data/lib/lisp/tests/aif-examples.nydp +8 -3
  26. data/lib/lisp/tests/andify-examples.nydp +7 -0
  27. data/lib/lisp/tests/at-syntax-examples.nydp +17 -0
  28. data/lib/lisp/tests/best-examples.nydp +9 -0
  29. data/lib/lisp/tests/builtin-tests.nydp +19 -0
  30. data/lib/lisp/tests/case-examples.nydp +14 -0
  31. data/lib/lisp/tests/date-examples.nydp +54 -1
  32. data/lib/lisp/tests/destructuring-examples.nydp +46 -14
  33. data/lib/lisp/tests/detect-examples.nydp +12 -0
  34. data/lib/lisp/tests/dp-examples.nydp +24 -0
  35. data/lib/lisp/tests/each-tests.nydp +5 -0
  36. data/lib/lisp/tests/empty-examples.nydp +1 -1
  37. data/lib/lisp/tests/error-tests.nydp +4 -4
  38. data/lib/lisp/tests/explain-mac-examples.nydp +1 -1
  39. data/lib/lisp/tests/filter-forms-examples.nydp +15 -0
  40. data/lib/lisp/tests/hash-examples.nydp +25 -1
  41. data/lib/lisp/tests/list-grep-examples.nydp +40 -0
  42. data/lib/lisp/tests/list-tests.nydp +58 -1
  43. data/lib/lisp/tests/map-hash-examples.nydp +11 -0
  44. data/lib/lisp/tests/module-examples.nydp +10 -0
  45. data/lib/lisp/tests/multi-assign-examples.nydp +6 -0
  46. data/lib/lisp/tests/parser-tests.nydp +25 -0
  47. data/lib/lisp/tests/pretty-print-tests.nydp +17 -14
  48. data/lib/lisp/tests/set-difference-examples.nydp +8 -0
  49. data/lib/lisp/tests/settings-examples.nydp +17 -1
  50. data/lib/lisp/tests/string-tests.nydp +70 -1
  51. data/lib/lisp/tests/syntax-tests.nydp +5 -1
  52. data/lib/lisp/tests/to-integer-examples.nydp +16 -0
  53. data/lib/lisp/tests/validation-examples.nydp +15 -0
  54. data/lib/nydp.rb +10 -3
  55. data/lib/nydp/assignment.rb +10 -3
  56. data/lib/nydp/builtin.rb +1 -1
  57. data/lib/nydp/builtin/abs.rb +8 -0
  58. data/lib/nydp/builtin/date.rb +15 -1
  59. data/lib/nydp/builtin/error.rb +1 -1
  60. data/lib/nydp/builtin/hash.rb +24 -1
  61. data/lib/nydp/builtin/inspect.rb +1 -1
  62. data/lib/nydp/builtin/plus.rb +10 -2
  63. data/lib/nydp/builtin/random_string.rb +2 -2
  64. data/lib/nydp/builtin/{car.rb → regexp.rb} +2 -2
  65. data/lib/nydp/builtin/ruby_wrap.rb +72 -0
  66. data/lib/nydp/builtin/string_match.rb +2 -2
  67. data/lib/nydp/builtin/string_pad_left.rb +7 -0
  68. data/lib/nydp/builtin/string_pad_right.rb +7 -0
  69. data/lib/nydp/builtin/string_replace.rb +3 -3
  70. data/lib/nydp/builtin/string_split.rb +4 -3
  71. data/lib/nydp/builtin/to_integer.rb +23 -0
  72. data/lib/nydp/builtin/to_string.rb +2 -9
  73. data/lib/nydp/builtin/type_of.rb +9 -6
  74. data/lib/nydp/closure.rb +0 -3
  75. data/lib/nydp/cond.rb +23 -1
  76. data/lib/nydp/context_symbol.rb +14 -6
  77. data/lib/nydp/core.rb +36 -28
  78. data/lib/nydp/core_ext.rb +21 -5
  79. data/lib/nydp/date.rb +26 -18
  80. data/lib/nydp/function_invocation.rb +34 -26
  81. data/lib/nydp/helper.rb +35 -3
  82. data/lib/nydp/interpreted_function.rb +68 -40
  83. data/lib/nydp/literal.rb +1 -1
  84. data/lib/nydp/pair.rb +22 -5
  85. data/lib/nydp/parser.rb +11 -7
  86. data/lib/nydp/string_atom.rb +3 -4
  87. data/lib/nydp/symbol_lookup.rb +7 -7
  88. data/lib/nydp/tokeniser.rb +2 -2
  89. data/lib/nydp/truth.rb +10 -10
  90. data/lib/nydp/version.rb +1 -1
  91. data/lib/nydp/vm.rb +7 -0
  92. data/nydp.gemspec +2 -4
  93. data/spec/date_spec.rb +93 -0
  94. data/spec/embedded_spec.rb +12 -12
  95. data/spec/foreign_hash_spec.rb +14 -2
  96. data/spec/hash_non_hash_behaviour_spec.rb +7 -7
  97. data/spec/hash_spec.rb +24 -2
  98. data/spec/nydp_spec.rb +14 -2
  99. data/spec/pair_spec.rb +3 -1
  100. data/spec/parser_spec.rb +31 -20
  101. data/spec/rand_spec.rb +3 -3
  102. data/spec/spec_helper.rb +10 -1
  103. metadata +24 -37
  104. data/lib/nydp/builtin/cdr.rb +0 -7
  105. data/lib/nydp/builtin/cons.rb +0 -9
data/spec/rand_spec.rb CHANGED
@@ -15,7 +15,7 @@ describe Nydp::Builtin::Rand do
15
15
  numbers = (0..100).map { |i| get_rand }
16
16
  expect(numbers.all? { |n| n >= 0 && n < 1 })
17
17
  avg = numbers.reduce &:+
18
- expect(avg).to be_between 40, 60
18
+ expect(avg).to be_between 40, 60 # with high probability
19
19
  distinct = Set.new numbers
20
20
  expect(distinct.count).to be > 90
21
21
  end
@@ -26,7 +26,7 @@ describe Nydp::Builtin::Rand do
26
26
  numbers = (0..200).map { |i| get_rand 10 }
27
27
  expect(numbers.all? { |n| n >= 0 && n < 10 })
28
28
  avg = numbers.reduce &:+
29
- expect(avg).to be_between 800, 1200
29
+ expect(avg).to be_between 800, 1200 # with high probability
30
30
  distinct = Set.new numbers
31
31
  expect(distinct.count).to eq 10
32
32
  end
@@ -37,7 +37,7 @@ describe Nydp::Builtin::Rand do
37
37
  numbers = (0..200).map { |i| get_rand 10, 20 }
38
38
  expect(numbers.all? { |n| n >= 10 && n < 20 })
39
39
  avg = numbers.reduce &:+
40
- expect(avg).to be_between 2800, 3200
40
+ expect(avg).to be_between 2800, 3200 # with high probability
41
41
  distinct = Set.new numbers
42
42
  expect(distinct.count).to eq 10
43
43
  end
data/spec/spec_helper.rb CHANGED
@@ -37,8 +37,17 @@ class TestThing
37
37
  "(TestThing #{a.inspect} #{b.inspect})"
38
38
  end
39
39
 
40
+ def one_thing x
41
+ x + a
42
+ end
43
+
44
+ def two_things x, y
45
+ x + (y * b)
46
+ end
47
+
40
48
  def _nydp_get name
41
49
  name = name.to_s.to_sym
42
- send(name) if name == :a || name == :b
50
+ return send(name) if name == :a || name == :b
51
+ return method(name) if name == :one_thing || name == :two_things
43
52
  end
44
53
  end
metadata CHANGED
@@ -1,59 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nydp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conan Dalton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-12 00:00:00.000000000 Z
11
+ date: 2021-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.3'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.3'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '10.0'
19
+ version: '12'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '10.0'
26
+ version: '12'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.1'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.1'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec_numbering_formatter
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - ">="
@@ -95,6 +67,7 @@ files:
95
67
  - lib/lisp/core-030-syntax.nydp
96
68
  - lib/lisp/core-035-flow-control.nydp
97
69
  - lib/lisp/core-037-list-utils.nydp
70
+ - lib/lisp/core-039-module.nydp
98
71
  - lib/lisp/core-040-utils.nydp
99
72
  - lib/lisp/core-041-string-utils.nydp
100
73
  - lib/lisp/core-042-date-utils.nydp
@@ -107,18 +80,22 @@ files:
107
80
  - lib/lisp/core-100-utils.nydp
108
81
  - lib/lisp/core-110-hash-utils.nydp
109
82
  - lib/lisp/core-120-settings.nydp
83
+ - lib/lisp/core-130-validations.nydp
110
84
  - lib/lisp/core-900-benchmarking.nydp
111
85
  - lib/lisp/tests/accum-examples.nydp
112
86
  - lib/lisp/tests/add-hook-examples.nydp
113
87
  - lib/lisp/tests/aif-examples.nydp
114
88
  - lib/lisp/tests/all-examples.nydp
115
89
  - lib/lisp/tests/ampersand-syntax-examples.nydp
90
+ - lib/lisp/tests/andify-examples.nydp
116
91
  - lib/lisp/tests/any-examples.nydp
92
+ - lib/lisp/tests/at-syntax-examples.nydp
117
93
  - lib/lisp/tests/auto-hash-examples.nydp
118
94
  - lib/lisp/tests/best-examples.nydp
119
95
  - lib/lisp/tests/boot-tests.nydp
120
96
  - lib/lisp/tests/builtin-tests.nydp
121
97
  - lib/lisp/tests/car-examples.nydp
98
+ - lib/lisp/tests/case-examples.nydp
122
99
  - lib/lisp/tests/cdr-set-examples.nydp
123
100
  - lib/lisp/tests/collect-tests.nydp
124
101
  - lib/lisp/tests/cons-examples.nydp
@@ -130,6 +107,7 @@ files:
130
107
  - lib/lisp/tests/detect-examples.nydp
131
108
  - lib/lisp/tests/dot-syntax-examples.nydp
132
109
  - lib/lisp/tests/dox-tests.nydp
110
+ - lib/lisp/tests/dp-examples.nydp
133
111
  - lib/lisp/tests/dynamic-scope-test.nydp
134
112
  - lib/lisp/tests/each-tests.nydp
135
113
  - lib/lisp/tests/empty-examples.nydp
@@ -147,11 +125,15 @@ files:
147
125
  - lib/lisp/tests/isa-examples.nydp
148
126
  - lib/lisp/tests/k-examples.nydp
149
127
  - lib/lisp/tests/len-examples.nydp
128
+ - lib/lisp/tests/list-grep-examples.nydp
150
129
  - lib/lisp/tests/list-gsub-examples.nydp
151
130
  - lib/lisp/tests/list-match-examples.nydp
152
131
  - lib/lisp/tests/list-tests.nydp
132
+ - lib/lisp/tests/map-hash-examples.nydp
153
133
  - lib/lisp/tests/mapreduce-examples.nydp
154
134
  - lib/lisp/tests/mapsum-examples.nydp
135
+ - lib/lisp/tests/module-examples.nydp
136
+ - lib/lisp/tests/multi-assign-examples.nydp
155
137
  - lib/lisp/tests/none-examples.nydp
156
138
  - lib/lisp/tests/orequal-examples.nydp
157
139
  - lib/lisp/tests/parser-tests.nydp
@@ -166,6 +148,7 @@ files:
166
148
  - lib/lisp/tests/returning-examples.nydp
167
149
  - lib/lisp/tests/rfnwith-tests.nydp
168
150
  - lib/lisp/tests/seqf-examples.nydp
151
+ - lib/lisp/tests/set-difference-examples.nydp
169
152
  - lib/lisp/tests/set-intersection-examples.nydp
170
153
  - lib/lisp/tests/set-union-examples.nydp
171
154
  - lib/lisp/tests/settings-examples.nydp
@@ -173,20 +156,20 @@ files:
173
156
  - lib/lisp/tests/string-tests.nydp
174
157
  - lib/lisp/tests/syntax-tests.nydp
175
158
  - lib/lisp/tests/time-examples.nydp
159
+ - lib/lisp/tests/to-integer-examples.nydp
176
160
  - lib/lisp/tests/tuples-examples.nydp
177
161
  - lib/lisp/tests/type-of-examples.nydp
178
162
  - lib/lisp/tests/unparse-tests.nydp
163
+ - lib/lisp/tests/validation-examples.nydp
179
164
  - lib/lisp/tests/zap-examples.nydp
180
165
  - lib/lisp/tests/zip-examples.nydp
181
166
  - lib/nydp.rb
182
167
  - lib/nydp/assignment.rb
183
168
  - lib/nydp/builtin.rb
169
+ - lib/nydp/builtin/abs.rb
184
170
  - lib/nydp/builtin/apply.rb
185
- - lib/nydp/builtin/car.rb
186
- - lib/nydp/builtin/cdr.rb
187
171
  - lib/nydp/builtin/cdr_set.rb
188
172
  - lib/nydp/builtin/comment.rb
189
- - lib/nydp/builtin/cons.rb
190
173
  - lib/nydp/builtin/date.rb
191
174
  - lib/nydp/builtin/divide.rb
192
175
  - lib/nydp/builtin/ensuring.rb
@@ -212,18 +195,23 @@ files:
212
195
  - lib/nydp/builtin/quit.rb
213
196
  - lib/nydp/builtin/rand.rb
214
197
  - lib/nydp/builtin/random_string.rb
198
+ - lib/nydp/builtin/regexp.rb
199
+ - lib/nydp/builtin/ruby_wrap.rb
215
200
  - lib/nydp/builtin/script_run.rb
216
201
  - lib/nydp/builtin/set_intersection.rb
217
202
  - lib/nydp/builtin/set_union.rb
218
203
  - lib/nydp/builtin/sort.rb
219
204
  - lib/nydp/builtin/sqrt.rb
220
205
  - lib/nydp/builtin/string_match.rb
206
+ - lib/nydp/builtin/string_pad_left.rb
207
+ - lib/nydp/builtin/string_pad_right.rb
221
208
  - lib/nydp/builtin/string_replace.rb
222
209
  - lib/nydp/builtin/string_split.rb
223
210
  - lib/nydp/builtin/sym.rb
224
211
  - lib/nydp/builtin/thread_locals.rb
225
212
  - lib/nydp/builtin/time.rb
226
213
  - lib/nydp/builtin/times.rb
214
+ - lib/nydp/builtin/to_integer.rb
227
215
  - lib/nydp/builtin/to_string.rb
228
216
  - lib/nydp/builtin/type_of.rb
229
217
  - lib/nydp/builtin/vm_info.rb
@@ -295,8 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
295
283
  - !ruby/object:Gem::Version
296
284
  version: '0'
297
285
  requirements: []
298
- rubyforge_project:
299
- rubygems_version: 2.2.2
286
+ rubygems_version: 3.0.3
300
287
  signing_key:
301
288
  specification_version: 4
302
289
  summary: A civilised yet somewhat dangerous kind of Lisp for a new generation
@@ -1,7 +0,0 @@
1
- class Nydp::Builtin::Cdr
2
- include Nydp::Builtin::Base, Singleton
3
-
4
- def builtin_invoke vm, args
5
- vm.push_arg args.car.cdr
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- module Nydp::Builtin
2
- class Cons
3
- include Nydp::Builtin::Base, Singleton
4
-
5
- def builtin_invoke vm, args
6
- vm.push_arg Nydp::Pair.new(args.car, args.cdr.car)
7
- end
8
- end
9
- end