Here's another fun way:
zUr9 =: ([: ; <@#:@>:)^:(|.1 0"_`])
zUr9 5
1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 0 1
(zUr 10) -: 18 {. zUr9 5
1
Unfortunately, as you can see, it isn't functionally identical to the other
zUr . Whereas the other verbs grow by at most two elements each
iteration, zUr9 grows as the Fibonacci sequence:
[EMAIL PROTECTED]"0 i. 10
2 3 5 8 13 21 34 55 89 144
If we had a "Fibonacci inverse", we could use it to discover the minimum
number of iterations required to generate N bits, then use that as an
argument to zUr9 , and take the first N bits from its result.
There are other ways, of course:
zUr10 =: (-:-.%:5)&(((*>:) |@:<.@:- <.@:*) 1+i.)
zUr10 21
1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 0 1
Again, this is functionally different from previous verbs. It grows exactly
with N ; i.e. it produces precisely N bits. If we had a verb which,
given N , told us how many bits zUr N would produce, we could apply that
verb just before zUr10 and get identical results. Well, to a point. I'm
vague on the subject of floating point precision, but I'm pretty sure
-:-.%:5 will run out pretty fast.
-Dan
--
View this message in context:
http://www.nabble.com/How-to-behead-included--tf4778131s24193.html#a13674411
Sent from the J Programming mailing list archive at Nabble.com.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm