With that in mind, it's fairly easy to satisfy Dan's stated requirement. Doing this efficiently will be another matter.
NB. from http://www.jsoftware.com/jwiki/DevonMcCormick/HAP_AIP?highlight=%28AIP%29 ELSE =: ` WHEN =: @. EACH =: &.> Skiena =: Parts ELSE Ones WHEN Under2 NB. (n) Skiena (p) Ones =: ,:@# Under2 =: 2 > ] Parts =: Top , Bottom Top =: ] ,. - Skiena - <. ] Bottom =: Skiena <: NB. for this specific task: rdist=:4 :0 base=. 1+(#~ x>:+/"1@:*)Skiena~y-x ({~ ?@#) ~.,/({"1~/ (A.&i.~!)@{:@$) base ) Example use: 3 rdist 6 3 2 1 3 rdist 6 1 3 2 3 rdist 6 1 1 4 3 rdist 6 1 4 1 3 rdist 6 3 1 2 3 rdist 6 2 2 2 Thanks, -- Raul On Fri, May 8, 2015 at 5:23 PM, Devon McCormick <[email protected]> wrote: > If you're interested in the "integer partion" problem in general, Howard > Peelle has J'ed it extensively: > http://www.jsoftware.com/jwiki/DevonMcCormick/HAP_AIP?highlight=%28AIP%29 . > > On Fri, May 8, 2015 at 4:58 PM, R.E. Boss <[email protected]> wrote: > >> > REB wrote: >> > > V=: Q*(%+/) 2 rnd N ?@# 0 >> > >> > This looks promising. What's rnd here? >> >> round on x decimals >> >> rnd >> +-+-+------------------------+ >> |3|:| 2 rnd y | >> | | |: | >> | | | t %~ <. 0.5+ y* t=.10^x| >> +-+-+------------------------+ >> >> >> R.E. Boss >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > > > -- > Devon McCormick, CFA > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
