Avoid the use of for and while loops in Lobster

What happens

I need to avoid the use of for and while loops for my challenge to be approved

What do you understand or find about that problem

I know that in a lot of langs I can avoid the use of them (like map in JS), but in Lobster I can’t find a way to do it because of the limited documentation

You make any workaround? What did you do?

After searching, I didn’t find anything because of the limited documentation


These two are my principal references:

I need help with

I need a way or an idea about how to do it

The main purpose of avoiding FOR and WHILE structures is to follow the fuctional programming paradigm. So, that’s it. You can “iterate” over a structure (collection, list, vector) through RECURSIVE CALLS to a function. That’s the main idea, however you can see a good explanation of “How to convert a loop (while/for) to recursion” here: algorithms - General way to convert a loop (while/for) to recursion or from a recursion to a loop? - Software Engineering Stack Exchange

1 Like

Hi @season-embodiment

In this link you can find different ways to implement loops in lobster.


I hope that it help you.