Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Recursive function returns: Evaluation resulted in a stack overflow and cannot continue

Hi there,   I am trying to build a function that goes through a column/list and checks whether the data stored is of type record or list. The function is below:  - - - - - - - - - - - - - - - - -...
  • mahoneypat's avatar
    5 years ago

    If I understand your use case, here is one way to do it.  I made this this list and called it ListToCheck

     

    = {1,"text", {1..3}, [A="text"]}

     

    Then used this expression that returned a value of 2 (1 list and 1 record).

     

    = List.Count(List.Select(List.Transform(ListToCheck, each Value.Is(_, List.Type) or Value.Is(_, Record.Type)), each _ = true))

     

    If that works, you can convert it to a function with (didn't check this one but I think it will work)

     

    (listname as list) =>

    let

    x = List.Count(List.Select(List.Transform(listname, each Value.Is(_, List.Type) or Value.Is(_, Record.Type)), each _ = true))

    in

    x

     

    Pat