An F# HelloWorld Style Crawler / Scraper (if you may)#
I wrote/scavenge this while Amanda Laucher's F# talk yesterday. It's a beauty, this terse F# syntactically & semantically. Having worked with scheme, experimenting with F# comes naturally however James Iry during a 1-1 discussions begs to differ that they are QUITE different. I have yet to independently verify the merit of this claim.

open System.IO
open System.Net            
            
let GetUrl(url:string) =

    let req = WebRequest.Create(url)

    // Get the response, synchronously
    let rsp = req.GetResponse()

    // Grab the response stream and a reader. Clean up when we're done
    use stream = rsp.GetResponseStream()
    use reader = new StreamReader(stream)

    // Synchronous read-to-end, returning the result
    reader.ReadToEnd()

let result = GetUrl("http://www.google.com")
printfn "%s" result





10/26/2008 5:43:32 AM (Pacific Standard Time, UTC-08:00) #    Comments [1]  |  Trackback
Tracked by:
"Interesting Finds: October 26, 2008" (Jason Haley) [Trackback]

 

10/26/2008 2:00:29 PM (Pacific Standard Time, UTC-08:00)
F# comes out of the ML family of languages. That family shares with Scheme the fact that functions are values and that free variables in lambdas are lexically scoped. So they're certainly closer to each other than they are to C or Fortran or Java.

But

Scheme: dynamically typed
ML: statically typed - the type system is in fact one of the main reasons ML was invented

Scheme: all variables are mutable
ML: variables are immutable unless marked otherwise

Scheme: macros are part of the language definition and important to how you write it
ML: macros exist in some extensions of some variation on ML

Scheme: call-with-current-continuation
ML: nope


Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

All content © 2010, Adnan Masood
About the Author
On this page
Calendar
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Archives
Sitemap
Blogroll OPML
microsoft
Blogroll
Disclaimer

Powered by: newtelligence dasBlog 1.8.5223.2

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts