Custom function recursion deep dive

Expert

Write production-quality recursive custom functions using tail recursion, accumulator patterns, and safe depth guards for list processing and tree traversal.

What you'll learn

  • How standard recursion builds a call stack and its depth limit
  • How tail recursion with an accumulator avoids stack depth issues
  • How to traverse a parent-child hierarchy with recursion
  • How to write a safe recursive CF that will never blow the limit

Recursive custom functions can solve problems that no other FileMaker calculation construct can: iterating a list without While() (for FileMaker 17 compatibility), traversing hierarchical data, and building arbitrary-length output from variable inputs. Writing them well requires understanding tail recursion, accumulators, and the 10,000-call depth limit.

1/4
1

Standard recursion: sum a value list

The straightforward recursive pattern: process the first item, then recursively call the function on the remainder. Each call adds a frame to the call stack.

FileMaker Script
// Custom function: List.Sum ( list )
// Standard recursion -- stack depth = ValueCount(list)

If ( IsEmpty ( list ) ;
  0 ;
  GetAsNumber ( GetValue ( list ; 1 ) )
    + List.Sum ( RightValues ( list ; ValueCount ( list ) - 1 ) )
)

Sign in to track your progress and pick up where you left off.

Sign in to FM Dojo