After working with some text in Dequoter, I needed to sum a bunch of new-line terminated numbers. Dequoter lacks this feature, and I was wondering whether to ask the agents to add one, until I remembered that Dequoter supports plugin1. So I wrote one up. This takes a list of integers, adds them togeather, and replaces it with the sum:
d:filter "Lines: Sum" { |in|
total = 0
d:map-lines $in { |line|
total = add $total $line
}
$total
}
It’s not perfect thought. Any value not convertible to an int, including any floats, will cause it to fail. And it lacks the arbitrary precision that some apps have: we are just talking 64 bit integers here. But that’s a limitation of UCL, rather than Dequoter. With what I have now, it seems to work well enough.
-
Honestly, I’m glad I wrote about these plugins here in the first place. I completely forgot how they work. ↩︎