Skip to content

Commit

Permalink
Fix enum size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
mwpastore committed Sep 16, 2016
1 parent 4118c4f commit 10ba4b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ commas!
You've probably noticed that in order to use Ioughta in the top-level
namespace, we need to explicitly specify the `Object` receiver (just like we
need to do for `#const_set`). I didn't want to get too crazy with the
monkeypatching and/or dynamic dispatch. No such limitation exists when
including Ioughta in a module or class, thanks to the available context. Also,
if the `ioughta_const` and `ioughta_hash` methods are too ugly for you (I don't
blame you), they're aliased as `iota_const` and `iota_hash`, respectively.
monkeypatching and/or delegation. No such limitation exists when including
Ioughta in a module or class, thanks to the available context. Also, if the
`ioughta_const` and `ioughta_hash` methods are too ugly for you (I don't blame
you), they're aliased as `iota_const` and `iota_hash`, respectively.

Here is a very contrived and arbitrary example:

Expand Down
8 changes: 5 additions & 3 deletions lib/ioughta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ def pair(data, &block)
data = data.flatten(1)
lam = (data.shift if data[0].respond_to?(:call)) || block || DEFAULT_LAMBDA

data.map.with_index do |c, i, j = i.succ|
[c, data[j].respond_to?(:call) ? lam = data.slice!(j) : lam]
data.map.with_index do |nom, i, j = i.succ|
[nom, data[j].respond_to?(:call) ? lam = data.slice!(j) : lam]
end
end

def each_resolved_pair(data)
return enum_for(__method__, data) { data.length / 2 } unless block_given?
return enum_for(__method__, data) do
data.count { |nom, | nom != SKIP_SYMBOL }
end unless block_given?

data.each_with_index do |(nom, lam), iota|
val = lam[*[iota, nom].take(lam.arity.abs)]
Expand Down

0 comments on commit 10ba4b6

Please sign in to comment.