Skip to content

Commit

Permalink
handle map2pro for superators
Browse files Browse the repository at this point in the history
  • Loading branch information
jhellerstein committed Sep 21, 2011
1 parent cbd1182 commit 5d400ef
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/bud/rewrite.rb
Expand Up @@ -119,12 +119,18 @@ def do_rule(exp)
# to do this accurately (issue #225), so we just replace map calls liberally
# and define Enumerable#pro as an alias for "map".
def map2pro(exp)
# the non-superator case
if exp[1] and exp[1][0] and exp[1][0] == :iter \
and exp[1][1] and exp[1][1][1] and exp[1][1][1][0] == :call
if exp[1][1][2] == :map
exp[1][1][2] = :pro
end
end
# the superator case
elsif exp[1] and exp[1][0] == :call and (exp[1][2] == :~ or exp[1][2] == :+)
if exp[1][1] and exp[1][1][1] and exp[1][1][1][2] == :map
exp[1][1][1][2] = :pro
end
end
exp
end

Expand Down

0 comments on commit 5d400ef

Please sign in to comment.