Hi Claude,
Thanks a lot for the example.
Btw, is this where you are trying in-place replacement?
modifyAtIndex :: (a -> a) -> Nat -> List a -> List a
modifyAtIndex f i as =
let ias = zip nats as
g (Tuple2 j a) = case i `eq` j of
False -> a
True -> f a
in map g ias
modifyAtIndex2 :: (a -> a) -> Nat -> Nat -> List (List a) -> List (List a)
modifyAtIndex2 f i j = modifyAtIndex (modifyAtIndex f i) j
Doesn't modfiyAtIndex return a new list?
Hi,Break the problem down into parts:
On 16/07/10 07:35, C K Kashyap wrote:
Haskell without using any standard library stuff?
For example, if I wanted an image representation such as this
[[(Int,Int.Int)]] - basically a list of lists of 3 tuples (rgb) and
wanted to do in place replacement to set the pixel values, how could I
go about it.
1. replace a single pixel
2. modify an element in a list at a given index using a
given modification function
3. modify an element in a list of lists at a pair of given
indices using a given replacement function
I had a stab at it. Without any standard library stuff I couldn't figure out how to print any output, though - so who knows if the code I wrote does what I intended.
The point is, it's libraries all the way down - so use them, study them where necessary for understanding, and write them and share them when you find something missing.
Claude
--
http://claudiusmaximus.goto10.org
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe