From: Lie Ryan on 7 May 2010 20:39 On 05/08/10 04:33, Daniel T. wrote: > Keith Thompson <kst-u(a)mib.org> wrote: >> "Daniel T." <daniel_t(a)earthlink.net> writes: >>> Nick Keighley <nick_keighley_nospam(a)hotmail.com> wrote: >>>> On 6 May, 08:50, Keith Thompson <ks...(a)mib.org> wrote: >>>> >>>>> The original problem is to traverse a 3-dimensional array. A triple >>>>> nested loop is the most obvious way to do that. There might be >>>>> some advantages in converting it to a single loop, but clarity >>>>> isn't one of them, at least in this case. >>>> >>>> I considered submitting a single loop solution as a joke. It never >>>> crossed my mind someone would seriusly propose it! >>> >>> I seriously proposed it. I think it is the best solution for the job >>> (not your code specifically of course, but the idea of a single loop >>> traversing a single container.) >> >> Can a container contain another container, which in turn contains >> another container? If so, isn't a nested loop the most natural way to >> traverse the elements? > > Then you would need an infinite number of find functions, one for each > dimension count. (i.e., a find for 1D arrays, a find for 2D arrays, a > find for 3D arrays, a find for 4D arrays, etc.) That's silly. I've never heard of any programming languages that doesn't support recursion.
From: Lie Ryan on 7 May 2010 20:41 On 05/08/10 10:39, Lie Ryan wrote: > On 05/08/10 04:33, Daniel T. wrote: >> Keith Thompson <kst-u(a)mib.org> wrote: >>> "Daniel T." <daniel_t(a)earthlink.net> writes: >>>> Nick Keighley <nick_keighley_nospam(a)hotmail.com> wrote: >>>>> On 6 May, 08:50, Keith Thompson <ks...(a)mib.org> wrote: >>>>> >>>>>> The original problem is to traverse a 3-dimensional array. A triple >>>>>> nested loop is the most obvious way to do that. There might be >>>>>> some advantages in converting it to a single loop, but clarity >>>>>> isn't one of them, at least in this case. >>>>> >>>>> I considered submitting a single loop solution as a joke. It never >>>>> crossed my mind someone would seriusly propose it! >>>> >>>> I seriously proposed it. I think it is the best solution for the job >>>> (not your code specifically of course, but the idea of a single loop >>>> traversing a single container.) >>> >>> Can a container contain another container, which in turn contains >>> another container? If so, isn't a nested loop the most natural way to >>> traverse the elements? >> >> Then you would need an infinite number of find functions, one for each >> dimension count. (i.e., a find for 1D arrays, a find for 2D arrays, a >> find for 3D arrays, a find for 4D arrays, etc.) That's silly. > > I've never heard of any programming languages that doesn't support > recursion. except for assembly, perhaps... or some very ancient or jokular languages
From: io_x on 8 May 2010 02:50 "Lie Ryan" <lie.1296(a)gmail.com> ha scritto nel messaggio news:4be4b38f$1(a)dnews.tpgi.com.au... > On 05/08/10 10:39, Lie Ryan wrote: >> On 05/08/10 04:33, Daniel T. wrote: >>> Keith Thompson <kst-u(a)mib.org> wrote: >>>> "Daniel T." <daniel_t(a)earthlink.net> writes: >>>>> Nick Keighley <nick_keighley_nospam(a)hotmail.com> wrote: >>>>>> On 6 May, 08:50, Keith Thompson <ks...(a)mib.org> wrote: >> I've never heard of any programming languages that doesn't support >> recursion. > > except for assembly, perhaps... or some very ancient or jokular languages with assembly is possible to write recursions functions too
From: Juha Nieminen on 8 May 2010 03:07 In comp.lang.c++ io_x <a(a)b.c.invalid> wrote: > with assembly is possible to write recursions functions too That's like saying that C supports object-oriented programming.
From: gwowen on 8 May 2010 04:46
On May 8, 1:39 am, Lie Ryan <lie.1...(a)gmail.com> wrote: > I've never heard of any programming languages that doesn't support > recursion. Standard Fortran, prior to 1990. It was not a bad idea, given the limited stack space on most machines, and the likelihood of stack overflow. Especially given you can always do tail recursion by hand (ObOnTopic: ... using goto.) |