Code:
pipe=: 1 : '((pipeVerb x)`:6)f.'
pipeVerb =: ((_2&}. , <@:capTail)^:(1<#))^:_
capTail=: 3 : '[:`(_2{y)`(_1{y)' NB. cap two from tail
Examples:
mobius =: */ @: - @: ~: @: q:
mobiusP =: */ ` - ` ~: ` q: pipe
(mobius"0 -: mobiusP"0) >:i. 5555
1
mertens0=: +/`(mobius"0)`>:`i. pipe
mertens0"0 >: i. 15
1 0 _1 _1 _2 _1 _2 _2 _2 _1 _2 _2 _3 _2 _1
Commentary:
For months I've wished that the unobtrusive tie (`) could be used
instead of the heavy at (@:). With the adverb pipe, defined above, this
becomes possible.
I submit this here for its inevitable refinement, and would like
assistance in creating a suitable Essay page on the wiki for it once it
is presentable.
Normally I bristle when somebody starts talking about "syntactic sugar"
but, in this case, that is exactly what I strove to achieve.
Questions:
Will this use of fix (f.) lead to enough problems that it should be
omitted? It seems to me that the benefits of including it outweigh the
hazards.
Would condensing the definition into a single line necessarily involve
definition of a verb within it?
How would pipe be defined tacitly? Would clarity be lost, or gained?
How would capTail be best defined tacitly? It seems harder than normal,
because of how tie works.
Is it best to keep capTail separate, or could it be nicely incorporated
into pipeVerb? It seems so clear as a component, perhaps it stands best
on its own.
Is there a better name than 'pipe' for this adverb?
Tracy Bruce Harms
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm