in reply to Re^4: howto map/grep a complex structure
in thread howto map/grep a complex structure
Anonymonk originally posted a for-loop approach to processing a data structure, then asked for ways to make it more "elegant" with map and grep. Several Monks opined that, for several reasons, the for-loop code was perfectly good as it was and needed no ornamentation. I strongly agree.
Anon then replied "Ok, point taken, but I'd still appreciate some map/grep examples." The implication I took was that approaches other than map/grep would also be of interest. Several Monks responded with examples, including your recursive approach. I strongly approve these efforts; this is a teaching/learning site, after all.
So we come down to two questions that are somewhat at cross-purposes: "What's the best code for this specific application?" and "What other sorts of algorithmic approaches might be used in similar situations?" The answer to the first question is "The code we started with." The answer to the second is "There are lots of approaches that might be used with profit, including the one posted by trippledubs here!" I hope the divergence of the two questions helps explain the half-hearted nature of my approval.
Give a man a fish: <%-{-{-{-<
|
|---|