[clean-list] Help Please: Beginner to Clean.. Console I/O

Khurram Khan kkjcid at hotmail.com
Thu May 5 16:19:14 MEST 2011


Dear RT,

We have been studying this book: http://www.st.cs.ru.nl/papers/cleanbook/CleanBookI.pdf, and we have gone through the first four chapters and have managed to complete all exercises with them as well. We think that writing small programs in the form that you also suggested is pretty straight forward and we have got a good grasp of it. 

However, our real problems started once we started going through Chapter 5, which has examples relating I/0 in "hello1" and "hello2". 
We are learning Clean as a part of an academic project and we have a general feeling among our class that nobody is getting a hang of I/O operations in Clean, so we assume that it is not as straight-forward as it is in C++, but it would be excellent if we can learn it. One way of doing that could be by writing simple programs like the one we have discussed up til now, but we need some help from someone to show us how it could be done, and from there we should be able to write more complicated programs ourselves. 

Moreover, we are also aware of the fact that by doing regular I/O operations in functional programming might defeat the purpose of writing a program in a functional language because it will then resemble procedural programming style, but at this point of time we are more interested in learning how I/O operations are performed, because at some point you do need input from the user for a program to be useful/interactive, and it is also a vital part of our academic assignment.

Regards
Khurram 


 



> Subject: Re: [clean-list] Help Please: Beginner to Clean.. Console I/O
> From: rthappe at web.de
> Date: Thu, 5 May 2011 00:42:45 +0200
> CC: kkjcid at hotmail.com
> To: clean-list at cs.ru.nl
> 
> Khurram Khan wrote:
> 
> > We were thinking if its possible for you to translate this simple code of C++ in Clean and provide some comments on it as well. We are certain that it will help solve I/O dilemma for us, and we are deeply thankful for the time you take out to help us.
> > 
> > /* Just a simple program performing input/output to user console and performing a calculation*/
> 
> 
> Hello, I think you will fare better when you postpone console I/O and interaction a bit and get familiar with the basic features of Clean (everyday types, local binding forms, patterns, guards), most conveniently by writing and running simple programs such as the example below. [That's basically your C++ example but with hard-coded input and automatic display: Clean will display the value of START in  a console window. (This works better with mundane types such as Real or [Int] instead of the whole world.)]
> 
> Best wishes; rt
> __
> 
> module foo
> 
> import StdEnv
> 
> 
> Start :: Real
> Start = (a+b+c)/3.0
> where
> 	a = 12.3
> 	b = -1.4
> 	c = 23.1
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/clean-list/attachments/20110505/15b1b593/attachment.html>


More information about the clean-list mailing list