Making a range verb in J

Viewed 131

J is a fantastic programming language that I have decided to learn. As a simple exercise, I decided to emulate a range. There is a builtin function i. that creates a range 0..i-1. Using some math, I have that this is the range between a and b:

 a + i. (b - a - 1)

Success! I thought. Now, the "simple" task of converting to a verb is set before me. This is my problem now. I have a (the left argument) being called on both sides of the verb +. I thought of using evoke, but I am not sure as how to make it work.

So my question stands: How do I convert an expression of the form a f (a g b) or, more specifically, a f (a g b h c) (and similar forms) to a pure verb? I don't want to use explicit arguments, for what's the fun in that? ;)

EDIT My solution is as thus:

range =: [(+i.)>:@-~
1 Answers
Related