Loops/While: Difference between revisions

(added J)
Line 75:
J is array-oriented, so there is very little need for loops. For example, one could satisfy this task this way:
 
,. <.@-:^:*^:a: 1024
 
J does support loops for those times they can't be avoided (just like many languages support gotos for those time they can't be avoided).
 
3 : 'while. 0 < y do. y =. <. -: y 1!:2 ]2 end.' 1024
while. 0 < y do.
y 1!:2 ] 2
y =. <. -: y
end.
i. 0 0
)
 
Though it's rare to see J code like this.
Anonymous user