I have created this data type and function:
type Bit = Int
randomFloatList :: Int -> [Float]
randomFloatList seed = randoms (mkStdGen seed)
And I want to create a function that uses zipWith. The function has a seed as an argument that is used to the randomFloatList, if the random element is between 0 and noise then the bit is changed. I am trying to do it this way, but I am with difficulties with zipWith:
Thanks.
I believe you want to take a list of
Bits and use a random list to decide whether to alter the original. (If not, please clarify.)Notice you didn’t need some of the brackets – you don’t need brackets for function application, just for grouping.
Again, I’ve removed any reference to the list that I’m using this with –
zipWithwill send this function the single elements it needs out of the list of floats and bits.I took the liberty of defining
and could only think of one alter function:
Let’s test it:
Yup, that changed the ones it should.