web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Recursive procedure with a type list as Parameter

(0) ShareShare
ReportReport
Posted on by 666

Hi, 

I started working with linear programming inside of BC and the procedure I created is a recursive procedure that receives an integer and a list as parameters. 

pastedimage1656676610064v1.png

Now the problem is the following. 
The Recursive procedure works with the integer and the values are stored at the specific stages of the recursive procedure, but the the list value is kept to whatever was last removed. 
Even when moving back to the beginning  of the first loop. the list is not returned to the initially list values.

It might be that AL does not cater for storing Lists in recursive procedures but I could find any documentation to confirm it. 


I have the same question (0)
  • Suggested answer
    Brad_P Profile Picture
    1,551 on at

    Are you modifying the list within the procedure? You're passing the list as a reference (var), which will pass the same list reference for each recursive call.

  • Hein Kruger Profile Picture
    666 on at

    Hi Brad,

    Yes, I set the first element in the list equal to origin and then I remove it from the list before passing it to the procedure again. this will continue until there is only one element left in the list where it will then return a decimal value.  

    I removed the var from the parameter and still got the same outcome.

  • Verified answer
    Brad_P Profile Picture
    1,551 on at

    Hi,

    "A List is a reference type, so assigning an instance of a list to another variable or passing as a method parameter by value (for example without var), creates a second variable that reads/writes the same list. It does not create a new list."

    docs.microsoft.com/.../list-data-type

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,496 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 961 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 870 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans