Or: f=: 13 :',.x,x+-/"1((<:2#y)$_2 1)*(i.<:y)>:/i.<:y' 100 f 20 100 98 103 95 106 92 109 89 112 86 115 83 118 80 121 77 124 74 127 71 f [: ,. [ , [ + [: -/"1 (_2 1 $~ [: <: 2 # ]) * ([: i. [: <: ]) >:/ [: i. [: <: ] Linda
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Linda Alvord Sent: Monday, July 13, 2015 3:39 PM To: [email protected] Subject: Re: [Jprogramming] Powerize a while. s=:100 n=:20 ,.s, s+-/"1((<:2#n)$_2 1)*(i.<:n)>:/i.<:n 100 98 103 95 106 92 109 89 112 86 115 83 118 80 121 77 124 74 127 71 Linda -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Brian Schott Sent: Monday, July 13, 2015 12:40 PM To: Programming forum Subject: [Jprogramming] Powerize a while. I have the following verb t and wonder if anyone would like to show how it could be more elegantly defined (using the Power conjunction?) I would enjoy learning your result. The intent of t is to alternatively subtract 1 or 2 from a positive number showing the intermediate results of say n=20 subtractions. e =. -&2 o =. -&1 t =. monad define n =. 20 while. n =. n - 1 do. if. 2|n do. smoutput y =. e y else. smoutput y =. o y end. end. ) t 100 98 97 95 94 92 91 89 88 86 85 83 82 80 79 77 76 74 73 71 -- (B=) ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
