tag:blogger.com,1999:blog-18281936.post829930227715006263..comments2024-03-14T00:17:55.927-07:00Comments on John Liao's Blog: Exploring WPF Toolkit's DataGrid with F#John Liaohttp://www.blogger.com/profile/04740715435312568366noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-18281936.post-82543997566131265852009-06-08T10:00:51.052-07:002009-06-08T10:00:51.052-07:00There's probably many way to get rid of the wh...There's probably many way to get rid of the while loop, but I'm not sure if that's good idea or not. In the sections with code that is not purely functional, it might make more sense to have code constructs that looks imperative. But here's a sample code that does the same thing without the while statement and uses recursion:<br /><br />let rec retrieve (reader:SqlDataReader) = <br /> if reader.Read() then<br /> {FirstName = reader.GetString 3;<br /> LastName = reader.GetString 5;<br /> Email = reader.GetString 7;<br /> PhoneNumber = reader.GetString 9} :: (retrieve reader)<br /> else<br /> []<br /> <br />let query2 () = <br /> use conn = new SqlConnection(connString)<br /> do conn.Open()<br /> use comm = new SqlCommand("SELECT top 50 * FROM Person.Contact",conn)<br /> use reader = comm.ExecuteReader()<br /> retrieve readerJohn Liaohttps://www.blogger.com/profile/04740715435312568366noreply@blogger.comtag:blogger.com,1999:blog-18281936.post-79915488028987523022009-06-05T21:22:25.493-07:002009-06-05T21:22:25.493-07:00I have a question on the while loop. I am trying ...I have a question on the while loop. I am trying currently to do something similiar with out using a while. Can you code an example using recursion if possible.Coden Entepriseshttps://www.blogger.com/profile/00021347687772302278noreply@blogger.com