Blocks
Blocks Transformations
Imported from the upstream Vibescript examples at blocks/transformations.vibe and runnable in the browser today.
Source
blocks/transformations.vibe
# vibe: 0.2
def double_each(pledges)
pledges.map do |pledge|
pledge * 2
end
end
def select_large_donations(donations)
donations.select do |donation|
donation[:amount] > money("50.00 USD")
end
end
def total_scores(scores)
scores.reduce(0) do |running_total, score|
running_total + score
end
end
def run
{
doubled: double_each([10, 20, 30]),
total: total_scores([100, 200, 300])
}
end
Output
Press run to execute run from this example.