[Haskell-cafe] (no subject)

Daniel Fischer daniel.is.fischer at web.de
Thu May 8 10:21:18 EDT 2008


Am Donnerstag, 8. Mai 2008 15:36 schrieb u4538637 at anu.edu.au:
> Hi I have a bit of a dilemma.I have a list of lists, eg,
> [[1,2,3],[4,5,6],[7,8,9]]. Imagine they represent a grid with 0-2 on the x
> axis and 0-2 on the y axis, eg, (0,0) is 1, (1,0) is 2, (2,1) is 6, etc and
> (2,3) is 9. I want to be able to put in the list of lists, and the (x,y)
> coordinate, and return the value. 
>
> Also, I need to be able to replace a value in the list. Eg, if I wanted to
> replace (2,3) with 100, then the output of the expression would be
> [[1,2,3],[4,5,6],[7,8,100]].
>
> Any help would be great!

To get the value at a position, look up (!!)
To replace a value, you could use zipWith



More information about the Haskell-Cafe mailing list