I have recently encountered a problem and hope one of you can help me.
I have an init Situation in Haskell that returns the initial state. However, I want to alternate between two start values on each call, however I don't quite understand how I should do that.
The below code is not my effective code, however I have simplified the snippet so that everything relevant I believe is there.
iVal1 :: Int
iVal1 = 1
iVal2 :: Int
iVal2 = 2
data RandomSituation= RandomSituation Int
initSituation:: RandomSituation
initSituation = RandomSituation iVal1
I know currently I'm only assignign iVal1. However my goal would be= First call to "initSituation" should return "RandomSituation iVal1", the second call should return "RandomSituation iVal2", the third should return "RandomSituation iVal1" and so on...
EDIT:
As I had in mind: it is not possible. Easiest solution is to simply pass the old value as an argument, and them simply return the other one.