---Sherlock, Ric wrote:
> > bm=: 3 : 0
> > 'n d'=. y
> > t=. >.n % >:d-n
> > d$(>:t) {. t#1
> > )
> >
> > bm 4 5
> > 1 1 0 1 1
> > bm 7 10
> > 1 1 0 1 1 0 1 1 0 1
> >
>
> but only for rational numbers >: 1r2 !!!
bm=: 3 : 0
'n d'=. y
if. s=. 1r2 > n%d do. n=. d-n end.
t=. >.n % >:d-n
r=. d$(>:t) {. t#1
if. s do. -.r end.
)
bm is now really ugly, but at least it sort of works.
What result is required for something like 2r15?
Is this OK?
bm 2 15
0 0 0 0 0 1 0 0 0 0 0 1 0 0 0
or would this be better?
0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm