nydp 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39e2357b8393c54fc0eea68f0edd2a8d6728ad3a
4
- data.tar.gz: 27f90d034ee3a3fa44fe7c24e3a08638ac5b6781
3
+ metadata.gz: b34a690426dc8586b784561503f93638b4ca32bb
4
+ data.tar.gz: 4b994623f4c7d685119046f025c1a17adccc7a13
5
5
  SHA512:
6
- metadata.gz: 18a8c415c0a4c6418a17122fd619cc840120e9a5d3fc0444185399e22d52fe4852c966f60cc67c304e7c2b38e7b449459d5cbac498caa67fe405de8eb56809a1
7
- data.tar.gz: b959fde0c9b6e51957687eccdd7252cacea90e51a82d8d166242aaaa41835035ecec79987a3cbe4ee741b2097f131401f094739e5f1b4cb5e26789992cb31c95
6
+ metadata.gz: c32cbeb7b3013042d8712958e3cafe4062f7b75850e20c9162e273bdea45d1b38e9dc61fbcabb597dacdf512b535db8e227c323c8c23726677c56d58e4d626e0
7
+ data.tar.gz: d687ddbe01b2e0aaddeecbe7849a5d4aeb6cc3c7c253d11f57555e2386670ed8252ec5338b34ee0ab8e5b59932ec9c9c424283b4985614bf79f3485a726d9ba2
@@ -57,3 +57,16 @@
57
57
  (mac auto-hash names
58
58
  ; (auto-hash a b c) same as { a a b b c c }
59
59
  `(brace-list ,@(flatten:map λn(list n n) names)))
60
+
61
+ (mac accum (accfn-name . body)
62
+ (w/uniq acc
63
+ `(let ,acc nil
64
+ (let ,accfn-name λa(push a ,acc)
65
+ ,@body
66
+ (rev ,acc)))))
67
+
68
+ (mac ++ (place inc)
69
+ `(= ,place (+ ,place ,(or inc 1))))
70
+
71
+ (def seqf (start incr)
72
+ (fn () (returning start (++ start incr))))
@@ -0,0 +1,7 @@
1
+ (examples-for accum
2
+ ("accumulate the values passed to a given function and return the list"
3
+ (accum a
4
+ (a 1)
5
+ (a 2)
6
+ (a 3))
7
+ (1 2 3)))
@@ -0,0 +1,15 @@
1
+ (examples-for ++
2
+ ("increments a variable"
3
+ (let a 3
4
+ (++ a)
5
+ (++ a)
6
+ (++ a)
7
+ a)
8
+ 6)
9
+ ("increments a variable by the specified amount"
10
+ (let a 5
11
+ (++ a 3)
12
+ (++ a 4)
13
+ (++ a 5)
14
+ a)
15
+ 17))
@@ -0,0 +1,5 @@
1
+ (examples-for seqf
2
+ ("returns a function that returns the next number in a sequence when called"
3
+ (let s (seqf 10 2)
4
+ (list (s) (s) (s) (s)))
5
+ (10 12 14 16)))
data/lib/nydp.rb CHANGED
@@ -33,9 +33,10 @@ module Nydp
33
33
  vm.thread
34
34
  end
35
35
 
36
- def self.eval_src ns, src_txt
37
- Nydp::Runner.new(VM.new, ns, Nydp::StringReader.new(src_txt)).run
38
- end
36
+ def self.reader txt ; Nydp::StringReader.new txt ; end
37
+ def self.eval_src ns, src_txt ; eval_with Nydp::Runner, ns, src_txt ; end
38
+ def self.eval_src! ns, src_txt ; eval_with Nydp::ExplodeRunner, ns, src_txt ; end
39
+ def self.eval_with runner, ns, src_txt ; runner.new(VM.new, ns, reader(src_txt)).run ; end
39
40
 
40
41
  def self.repl
41
42
  puts "welcome to nydp"
data/lib/nydp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nydp
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nydp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conan Dalton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-05 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,6 +98,7 @@ files:
98
98
  - lib/lisp/core-080-pretty-print.nydp
99
99
  - lib/lisp/core-090-hook.nydp
100
100
  - lib/lisp/core-100-utils.nydp
101
+ - lib/lisp/tests/accum-examples.nydp
101
102
  - lib/lisp/tests/add-hook-examples.nydp
102
103
  - lib/lisp/tests/auto-hash-examples.nydp
103
104
  - lib/lisp/tests/best-examples.nydp
@@ -127,6 +128,7 @@ files:
127
128
  - lib/lisp/tests/list-tests.nydp
128
129
  - lib/lisp/tests/mapsum-examples.nydp
129
130
  - lib/lisp/tests/parser-tests.nydp
131
+ - lib/lisp/tests/plus-plus-examples.nydp
130
132
  - lib/lisp/tests/pre-compile-examples.nydp
131
133
  - lib/lisp/tests/pretty-print-tests.nydp
132
134
  - lib/lisp/tests/quasiquote-examples.nydp
@@ -134,6 +136,7 @@ files:
134
136
  - lib/lisp/tests/relative-months-examples.nydp
135
137
  - lib/lisp/tests/returning-examples.nydp
136
138
  - lib/lisp/tests/rfnwith-tests.nydp
139
+ - lib/lisp/tests/seqf-examples.nydp
137
140
  - lib/lisp/tests/sort-examples.nydp
138
141
  - lib/lisp/tests/string-tests.nydp
139
142
  - lib/lisp/tests/syntax-tests.nydp