<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Dear Khurram,<br>
    <br>
    You can find more information about "cin" and "cout" like operations
    in section 5.1.1. To get access to console I/O, you need to open the
    "stdio" file. Consider the example on page 116, hello1. <br>
    <br>
    First, to get access at all to the external environment of any
    program, the main function, that is called Start in Clean, receives
    a special argument of type *World. World is an opaque type. The * in
    front of it indicates that it is special: it is a so-called unique
    value. Unique means that a value can only be used in a sensible way
    if it is not shared, i.e. there exists at any time only one
    reference to that value. Any value that satisfies this criterion can
    be updated in place, as you are used to in C(++). This is the only
    exception in a pure functional language to update values in place.
    The World is unique because the external environment of a program is
    unique: any update in place on the external environment can be
    observed by other entities in the external world. <br>
    <br>
    Second, the function stdio takes the external world and returns a
    read-write file value that is connected with your console, and a
    modified external world. You can use the function fwrites to write
    any string value to this read-write file, and thus the console. Note
    how this function updates the read-write file and hence returns a
    modified value. For hygienic reasons, every time you are done with a
    file (be it for reading, writing, or console) you close it with the
    fclose function. This updates the external environment such that the
    read-write console file is available for other functions as well.
    Finally, for hygienic reasons, the modified external environment
    value of type World must be returned by the Start function. <br>
    <br>
    Third, the hello2 example below the hello1 example shows how to read
    string input. The function freadline reads an entire line of input
    from the console, including the terminating newline character. For
    further processing Clean provides a number of conversions functions
    to turn a string value into an Integer (toInt) and a Real (toReal).
    Conversely, the following idiom makes it easy to write values to a
    write or read-write file. For instance:<br>
    <br>
    &nbsp;&nbsp;&nbsp;&nbsp; file &lt;&lt;&lt; 42 &lt;&lt;&lt; " is eqal to " &lt;&lt;&lt;
    84.0 / 2.0 &lt;&lt;&lt; '\n'<br>
    <br>
    which writes an integer, string, real, and character value
    subsequently to file.<br>
    <br>
    I hope this helps. For further question, please use the clean-list
    mailing list (clean-list AT cs DOT ru DOT nl). I am hard to reach
    the coming week due to holidays.<br>
    <br>
    Regards,<br>
    Peter<br>
    <br>
    On 4/29/2011 6:50 PM, Khurram Khan wrote:
    <blockquote cite="mid:DUB104-w303D61B3B553FFC553F30CB9A0@phx.gbl"
      type="cite">
      <style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
      <font style="" color="#000000"><font style="" face="Verdana,
          Geneva, Arial, Sans-serif">Dear Peter,<br>
          <br>
          Thanks for your quick reply. Yes, I had a look at the link and
          it does provide very useful information about Clean
          programming. However, I was unable to understand how
          input/output operations are done in Clean. For example if i
          want to input some data and then want the software to do some
          operations on it, how would that be done? Is there a way to do
          that in Clean, just like in C++ we can use "cin" and "cout"
          commands to perform those functions to print or read data
          to/from the console.<br>
          <br>
        </font></font>
      <div>Best regards<br>
        Khurram<br>
      </div>
      <br>
      <br>
      <br>
      <br>
      <hr id="stopSpelling">Date: Fri, 29 Apr 2011 17:31:33 +0200<br>
      From: <a class="moz-txt-link-abbreviated" href="mailto:P.Achten@cs.ru.nl">P.Achten@cs.ru.nl</a><br>
      To: <a class="moz-txt-link-abbreviated" href="mailto:kkjcid@hotmail.com">kkjcid@hotmail.com</a><br>
      CC: <a class="moz-txt-link-abbreviated" href="mailto:clean@cs.ru.nl">clean@cs.ru.nl</a><br>
      Subject: Re: Books/learning material on Clean for a beginner?<br>
      <br>
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <meta name="Generator" content="Microsoft SafeHTML">
      Dear Khurram,<br>
      <br>
      Thank you for your interest in Clean and functional programming.
      This style of programming is indeed very different when you're
      exposed to C and C++ only. <br>
      <br>
      Have you found the following book on the Clean wiki?<br>
      <br>
      <a moz-do-not-send="true" class="ecxmoz-txt-link-freetext"
        href="http://wiki.clean.cs.ru.nl/Functional_Programming_in_Clean"
        target="_blank">http://wiki.clean.cs.ru.nl/Functional_Programming_in_Clean</a><br>
      <br>
      This is the same text that we use to teach our students Clean and
      functional programming.<br>
      <br>
      Best regards,<br>
      Peter<br>
      <br>
      On 4/29/2011 5:16 PM, Khurram Khan wrote:
      <blockquote cite="mid:DUB104-w48666F98F383BAD6F3ECC6CB9A0@phx.gbl">
        <style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}

</style> Hi<br>
        <br>
        I am a college student, who is interested in learning functional
        programming and Clean in particular regarding an academic
        project. I do not have any previous experience of functional
        programming and I am finding it very difficult to understand
        Clean. I have many years of programming experience with C and
        C++, but it seems to be totally different when it comes to
        programming in Clean. Moreover I am not able to find any books
        on Clean which provide a good introduction to beginners, such as
        creating basic programs. <br>
        <br>
        Can you please suggest what approach should I have in order to
        learn Clean effectively? I've read some of the documentation
        provided on your website but I find it difficult to understand,
        as I think it doesnt provide enough explanation for a begineer
        (functional programmer)<br>
        <br>
        Kind regards<br>
        Khurram<br>
      </blockquote>
    </blockquote>
  </body>
</html>