I know I am beating a dead horse, but cannot help myself. I'll blame
some of my compulsion on my grandson visiting with his bike with only
one crank cog. Anyhow the code is slightly more concise and produces
more useful output, I believe, especially when plotted.
NB. First the basics, again, but output rearranged and plotted.
rhub=: 32 26 21 18 16 14 12 11
ccog=: 28 38 48
indices =: {@;&(i...@#)
ratios =: <"0@(/:~...@[ %/ \:~...@]) NB. sorted and boxed
combined =: ,&>/@,:&, NB. indices and ratios
gears0 =: indices combined ratios
uamend =: ({:"1...@[)`(<@}:"1...@[)`] NB. to table output
ccog gears0 rhub
load'plot'
flourish =: 'dot;pensize 3;yrange 0 5;title Bike gear ratios'
flourish plot ccog(>:@i...@#@] ;(gears0)uamend}(_1$~,&#)) rhub
ccog(>:@i...@#@]|.@,(gears0)uamend}( _$~,&#)) rhub
2%~/\ /:~ccog NB. big cog ratios
NB. Again, after filtering out Martin's "obliques"
famend =: _:`((([:< 0 1;~<:@#...@])))`] NB. fast cog
samend =: _:`((([:< _1 _2;~0:)))`] NB. slow cog
oamend =: _:`((([:< 0 _1;~...@}:@i...@#@])))`] NB. other cog
amends =: [: oamend}~ [: samend}~ famend}~
filter0=: (_&~:#])@,@ame...@i.@,&# NB. most bikes
filter =: (filter0`(a:"_))@.(1...@[) NB. for 1=#ccog
filtgears =: filter{gears0
ccog filtgears rhub
flourish plot ccog(>:@i...@#@] ;(filtgears)uamend}(_1$~,&#)) rhub
ccog(>:@i...@#@]|.@,(filtgears)uamend}( _$~,&#)) rhub
NB. repeat with other gears such as: ccog =: 38
--
(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm