|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
pedrotester Smarty Regular
Joined: 06 Jun 2019 Posts: 40
|
Posted: Fri Jun 14, 2019 9:12 pm Post subject: |
|
|
That doesn't answer my question, I still have to do twice the same thing. Is it normal? yes or no, no riddle plz |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Jun 14, 2019 9:18 pm Post subject: |
|
|
No, it's not the same thing.
If my answer "doesn't answer your question", then google the difference yourself. |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Sun Jun 16, 2019 2:40 am Post subject: |
|
|
A multi-level parent->child hierarchy of similar structure is the very definition of recursion. (See: fractal)
Technically, you don't need to recurse. You can do the same with a massive amount of repetitive code. But doing that would require you to have an intimate knowledge of the nature of your source data. For example, you know for a fact that you only have, and only will ever have, at most, three generations of relationships with three siblings in each generation.
And if that is your intended structure - three generations - then massive amounts of repeating code would suffice.
The problems start when you need to change some aspect of each sibling. Change massive numbers of instances - or just one that gets recursed (or is a function call).
So, use recursion to construct your hierarchical structure, and use recursion to deconstruct that structure into the required displayable orientation/organization.
This is a general programming (problem-solving) task -- breaking a large pattern into manageable, repeatable, smaller and identical patterns. |
|
Back to top |
|
pedrotester Smarty Regular
Joined: 06 Jun 2019 Posts: 40
|
Posted: Mon Jun 17, 2019 7:33 pm Post subject: |
|
|
thank you for explanation! |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|