# Squares and circles (grid) (recursion vs. nested for-loops)

**URL:** https://discourse.processing.org/t/squares-and-circles-grid-recursion-vs-nested-for-loops/30433
**Category:** Beginners
**Created:** [June 2, 2021, 12:44am UTC](https://discourse.processing.org/t/squares-and-circles-grid-recursion-vs-nested-for-loops/30433 "2021-06-02T00:44:56Z")
**Posts on this page:** 1
**Showing post:** 17

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [June 2, 2021, 10:21pm UTC](https://discourse.processing.org/t/squares-and-circles-grid-recursion-vs-nested-for-loops/30433/17 "2021-06-02T22:21:18Z")

</div>

There are different techniques or tools for different purposes:

- if-clause for a condition
- for loop for a list
- nested for-loop for a grid (2D array)
- triple for-loop for a cube (3D array)
- recursion for tree structures. E.g. when you search a file in a folder which has subfolders and each of the sub-folders has files and folders in turn. This is a tree.  
Here is an example of recursion for art: [Need clarification on how this piece of found code is working (recursion) - #4 by Chrisir](https://discourse.processing.org/t/need-clarification-on-how-this-piece-of-found-code-is-working-recursion/29969/4)

Chrisir

---

_[View the full topic](https://discourse.processing.org/t/squares-and-circles-grid-recursion-vs-nested-for-loops/30433)._
