klam 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 462ec6cdadf1b62a21f9aa9fd1234e1602bd7ce8
4
- data.tar.gz: 40a63f674eede22654c41ff77c7ccd341e52a68e
3
+ metadata.gz: b3c2a2a79c7fc9bd757b979c7e30ddb9db372ee3
4
+ data.tar.gz: 331259be37b2fd3c7581bd65907b3c0bfbebae5d
5
5
  SHA512:
6
- metadata.gz: 4cdbfc50ed2c3ce0e41d5e003adf4f431c8a96e3cc36b704515aa2efba5fe7d335ea95abc99140b9b0ff796b82f2f4c04bc910330a5a2d5d578ef7e26e832a81
7
- data.tar.gz: 01fca217423bb4e6314ab207a894dbc4d662c5463a7a6cfed97c0bb183e294a45fe37d458093fd8043c7dc9d195bbf4d364b49e2d3daf0eb521abe656d2acb2c
6
+ metadata.gz: 3803840c457f33c6d61b0615fe8f09199829ee71ca1f22e4ec3a1c3ada28439e648a404266f2242e755fec8bca9f60b9a9043ef20f7936ae5e40866cc9de3ef5
7
+ data.tar.gz: 7485c26bc1e70d7d0b45b4d7fba90162b9110af12d7a729133ba0c298b54d2f5af8650a7453dd610f773e8ea2c630b52d1a26eb07e30a66455521324562bff8d
@@ -1,6 +1,12 @@
1
1
  Relase History
2
2
  ==============
3
3
 
4
+ v0.0.6 -- February 1, 2015
5
+ --------------------------
6
+ Breaking Changes
7
+ ~~~~~~~~~~~~~~~~
8
+ * `rb-send-block` no longer takes an arity argument.
9
+
4
10
  v0.0.5 -- January 31, 2015
5
11
  --------------------------
6
12
  New Features
@@ -9,14 +9,14 @@ module Klam
9
9
  alias_method :"rb-send", :rb_send
10
10
  remove_method :rb_send
11
11
 
12
- def rb_send_block(obj, method_name, blk_arity, blk, *args)
12
+ def rb_send_block(obj, method_name, blk, *args)
13
13
  if blk.instance_of?(::Symbol)
14
14
  # The caller won't take advantage of the currying, but we already
15
15
  # are tracking the curried form. This also allows for paritial
16
16
  # application of the named function, which could be interesting.
17
17
  blk = @curried_methods[blk]
18
18
  else
19
- blk = ::Klam::Primitives::Interop.uncurry(blk, blk_arity)
19
+ blk = ::Klam::Primitives::Interop.uncurry(blk)
20
20
  end
21
21
  obj.send(method_name, *args, &blk)
22
22
  end
@@ -41,44 +41,11 @@ module Klam
41
41
  remove_method :rb_const
42
42
 
43
43
  class << self
44
- def uncurry(blk, blk_arity)
45
- case blk_arity
46
- when 0
47
- uncurry0(blk)
48
- when 1
49
- blk
50
- when 2
51
- uncurry2(blk)
52
- when 3
53
- uncurry2(blk)
54
- when 4
55
- uncurry2(blk)
56
- when 5
57
- uncurry2(blk)
58
- else
59
- ::Kernel.raise ::Klam::Error, "unsupported arity: #{blk_arity}"
44
+ def uncurry(blk)
45
+ lambda do |*args|
46
+ args.reduce(blk) { |f, x| f.call(x) }
60
47
  end
61
48
  end
62
-
63
- def uncurry0(blk)
64
- -> { blk.call(:NIL) }
65
- end
66
-
67
- def uncurry2(blk)
68
- -> a, b { blk.call(a).call(b) }
69
- end
70
-
71
- def uncurry3(blk)
72
- -> a, b, c { blk.call(a).call(b).call(c) }
73
- end
74
-
75
- def uncurry4(blk)
76
- -> a, b, c, d { blk.call(a).call(b).call(c).call(d) }
77
- end
78
-
79
- def uncurry5(blk)
80
- -> a, b, c, d, e { blk.call(a).call(b).call(c).call(d).call(e) }
81
- end
82
49
  end
83
50
  end
84
51
  end
@@ -1,3 +1,3 @@
1
1
  module Klam
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -9,7 +9,7 @@ describe 'extension: Ruby interop primitives', :type => :functional do
9
9
 
10
10
  describe 'rb-send-block' do
11
11
  it 'invokes a method on a Ruby object, passing the provided block' do
12
- code = '(rb-send-block (cons 1 (cons 2 ())) map 1 (lambda X (* 2 X)))'
12
+ code = '(rb-send-block (cons 1 (cons 2 ())) map (lambda X (* 2 X)))'
13
13
  expect_kl(code).to eq([2, 4])
14
14
  end
15
15
 
@@ -17,7 +17,7 @@ describe 'extension: Ruby interop primitives', :type => :functional do
17
17
  eval_kl('(set vec (absvector 2))')
18
18
  result = eval_kl <<-EOKL
19
19
  (let V (absvector 2)
20
- (do (rb-send-block (cons 1 (cons 2 ())) each_with_index 2
20
+ (do (rb-send-block (cons 1 (cons 2 ())) each_with_index
21
21
  (lambda X (lambda Y (address-> V Y X))))
22
22
  V))
23
23
  EOKL
@@ -26,7 +26,7 @@ describe 'extension: Ruby interop primitives', :type => :functional do
26
26
 
27
27
  it 'supports symbols as blocks' do
28
28
  eval_kl('(set vec (absvector 2))')
29
- expect_kl('(rb-send-block (cons 1 (cons 2())) map 1 str)').to eq(%w{1 2})
29
+ expect_kl('(rb-send-block (cons 1 (cons 2())) map str)').to eq(%w{1 2})
30
30
  end
31
31
  end
32
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Spurrier