Re: [Jprogramming] Determining an 'alternating' binary array

2012-07-31 Thread Thomas Costigliola
Here is a recursive solution, it stops processing when the alternating invariant becomes false. It is similar in principal to the sequential machine solution but uses $: to implement the machine. NB. assuming that the right list contains the first one, there are four cases NB. 0 0 -> true,

Re: [Jprogramming] Determining an 'alternating' binary array

2012-07-31 Thread Raul Miller
Here's an implementation which uses ;: smalt=: 12 > (3;1,~&>0 1 2 3,1 3 2 3,2 1 3 3,:3)&;:@:#.@|: Example use: smalt 1 0 0 1 0 1,:0 1 0 0 1 0 1 smalt 0 1 0 1 0,:1 0 1 0 1 1 smalt 0 0 1 0 0 0 0 1,:1 0 0 0 1 0 0 0 1 smalt 1 0 0 0 1,:0 1 1 0 0 0 smalt 1 0 0 1 0 1 1,: 0 1 0 0 1 0 0 0

Re: [Jprogramming] Determining an 'alternating' binary array

2012-07-31 Thread R.E. Boss
> Van: Peter B. Kessler > Verzonden: maandag 30 juli 2012 22:12 (...) > > This doesn't address the case where both inputs have 1's in the same column > > ]C=:2 5 $ 1 0 0 1 0 0 1 0 1 0 > 1 0 0 1 0 > 0 1 0 1 0 > (>./-<./)+/\+/1 _1 *C > 1 > > The original stateme

Re: [Jprogramming] Determining an 'alternating' binary array

2012-07-31 Thread Raul Miller
Actually, I said something in my previous post which was wrong: Function code 3 for sequential machine gives state table index. (This is not useful for a lot of the text processing I would like to do (where I want the state table index for each character being processed) but it's fine for this ap