assume there are dynamic number of nested for loop to output all combinations
in this example, there are 3 nested forloop, to generate a list of all combination such as [1,2,3], [1,3,5] etc.
if there are N nested forloop, how to use recursion to do in haskell?
pseudo code
for i from 1 to 5 do
for j from 1 to 10 do
if i < j then
for k from 1 to 50 do
if j < k then
list1 :: [i,j,k]
unfinished forloop has compile error
forloop :: Integer -> Integer -> [a]
forloop n m
| n == 1 = 1
| otherwise = if n > m
then [(forloop n-1 m)] ++ [n]
else []
expect a recursive version of function which can be saved in redis like Action type of .net framework
forloop n-1 mis parsed as(forloop n) - (1 m). Sinceforloop nis not a number, and1is not a function, the type checker will complain. What you meant there wasforloop (n-1) m.