So the issue I have is one that, some suggested, just hard code. Since its for a finite set of things.
But thats lame.
It involved some self created data , types etc. So I already broke down the problem to a smaller problem
and thats the one I will pose here.
I now have a list of elements, only 1, 0, 2
[1,0,2, 0,0,0,2,2,1] for example. so [Int], let’s call it stateZero
I have supplied this board for example together with either a 1 or a 2
and a zero can turn into either 1 or 2.
so I need to collect what new lists could be created from this list if you can change any single 0
so say we are given 1, we could get from stateZero to
[1, 1, 2, 0, 0, 0, 2, 2, 1], or [1,0,2,1,0,0,2,2,1] or [1,0,2,0,1,0,2,2,1] or [1,0,2,0,0,1,2,2,1]
these possible results I need to get all into a list so a [ [Int] ]
How to do that ? Like this would be so easy in non-functional language with some looping
and indexing, setting elements.
I want to get this with a list comphrension like so
func i (x:xs) = [ [(y:ys)] | x < xs, x == 0]
where
y = i
it looks kinda fked up, but then again I don’t want this to become too complicated with functions all over the place for something so…simple right?