The original ruby definition is 15 tokens, the .to_proc version is 13 tokens.
Orthogonality:
to_proc
3 variables (foo, n, x)
1 method call (to_proc)
1 type of separator (')
2 assignment ops (=, +=)
2 binary operators (->, .)
9 different kinds of tokens, in 5 (arbitrary) categories.
Original:
3 keywords (def, lambda, end)
3 variables (foo, n, i)
5 Separators (|, {, }, (, ))
1 assignment (+=)
12 different kinds of tokens, in 4 categories.
So the only way the original ruby version comes out ahead by these measures is that it has "fewer categories" of token types that are required. Also I think that with the 'def foo' declaration, 'foo' is not technically a variable. I don't really know ruby well enough. But you get the idea.
The original ruby definition is 15 tokens, the .to_proc version is 13 tokens.
Orthogonality:
to_proc
So the only way the original ruby version comes out ahead by these measures is that it has "fewer categories" of token types that are required. Also I think that with the 'def foo' declaration, 'foo' is not technically a variable. I don't really know ruby well enough. But you get the idea.