=?gb2312?B?tPC4tDogW0hhc2tlbGwtY2FmZV0gSG93IHRvIGRvIHRoaXMgaW4gRlAgd2E=?= =?gb2312?B?eT8=?=

Magicloud magicloud.magiclouds at gmail.com
Tue Jun 17 01:03:06 EDT 2008


OK. Here it is.
I want to make a monitor tool for linux. It runs for a long time, and =
give
out a certain process's io stat per second. The way I get io stat is to =
read
from /proc/pid/io. But the data in this file is a total, I need to read =
it
first, then next second, read it again, and shows the difference, and go =
on.
So, what is your idea?

-----=D3=CA=BC=FE=D4=AD=BC=FE-----
=B7=A2=BC=FE=C8=CB: David Roundy [mailto:daveroundy at gmail.com]=20
=B7=A2=CB=CD=CA=B1=BC=E4: 2008=C4=EA6=D4=C217=C8=D5 1:17
=CA=D5=BC=FE=C8=CB: Magicloud Magiclouds
=B3=AD=CB=CD: haskell-cafe at haskell.org
=D6=F7=CC=E2: Re: [Haskell-cafe] How to do this in FP way?

2008/6/15 Magicloud Magiclouds <magicloud.magiclouds at gmail.com>:
> Hello,
>     I am getting familiar with FP now, and I have a "program design" =
kind
of
> question.
>     Say I have something like this in C:
> static int old;
> int diff (int now) { /* this would be called once a second */
>   int ret =3D now - old;
>   old =3D now;
>   return ret;
> }
>     Because there is no "variable" in Haskell. So how to do this in a =
FP
> way?

A better question would be to think about what you are trying to
accomplish, and then ask how to achieve that through functional
programming.

David



More information about the Haskell-Cafe mailing list