Problems wiht [DrawFunction]

Ron Wichers Schreur ronny@cs.kun.nl
Mon, 21 Jun 1999 22:11:38 +0200


Hello Paulo,

You wrote:

> I need to send a sequence of ASCII characters to be drawn in a
> [DrawFunction]. Basically, I need a kind of looping, like FOR TO NEXT
> used in Pascal.

The closest thing to an for loop is probably a comprehension. Let's
suppose that your sequence of characters is a string (array of
characters). You could draw every character in the string as
follows:

    drawChars :: {#Char} -> [DrawFunction]
    drawChars string
        =   [DrawChar string.[i]  \\ i <- [0 .. size string - 1]]

This is just an example, normally you would use DrawString in this case.

If your sequence is a list of characers, you could try something like:

    drawChars :: [Char] -> [DrawFunction]
    drawChars list
        =   [DrawChar c  \\ c <- list]

For more information see the Clean Language Reference Manual, paragraph
3.4.5 "Creating Lists".


Cheers,

Ronny Wichers Schreur