An example would be usefull. Arrays can be very difficult when you see

+

them the very first time ever with the assumption that you want to try

+

them right now and that Haskell is a relatively new to you. Maybe something

+

like this could be added into the descriptions of the array-modules.

+

+

module Main where

+

+

import Data.Array.IO

+

+

-- Replace each element with 1/i, where i is the index starting from 1.

+

-- Loop uses array reading and writing.

+

loop :: IOUArray Int Double -> Int -> Int -> IO ()

+

loop arr i aLast

+

| i > aLast = return ()

+

| otherwise = do

+

val <- readArray arr i

+

writeArray arr i (val / (1+fromIntegral i))

+

loop arr (i+1) aLast

+

+

main = do

+

arr <- newArray (0,9) 1.0 -- initialise an array with 10 doubles.

+

loop arr 0 9 -- selfmade loop over elements

+

arr <- mapArray (+1) arr -- a map over elements

+

elems <- getElems arr

+

putStrLn $ "Array elements: " ++ (show elems)

+

+

[[User:Isto|Isto]] 14:43, 26 November 2006 (UTC)

== network ==

== network ==

Revision as of 14:43, 26 November 2006

If you find standard library documentation lacking in any way, please
log it here. At the minimum record what library/module/function isn't
properly documented. Please also suggest how to improve the
documentation, in terms of examples, explanations and so on.

Contents

1 base

package base
Data.Array.IO and Data.Array.MArray
descriptions

An example would be usefull. Arrays can be very difficult when you see
them the very first time ever with the assumption that you want to try
them right now and that Haskell is a relatively new to you. Maybe something
like this could be added into the descriptions of the array-modules.