Showing posts with label f#. Show all posts
Showing posts with label f#. Show all posts

Tuesday, April 27, 2010

F# weirdness of the day...

I have a piece of code that says:
links
    |> Seq.map (fun x -> x.GetAttributeValue ("href", "no url"))

Which I wanted to rewrite to "the other syntax" accepted by F#:
links
    |> Seq.map (fun x -> (x.GetAttributeValue "href" "no url"))

But I have no luck. The amusing thing is the error message I get from Visual Studio:
The member or object constructor 'GetAttributeValue' taking 2 arguments are not accessible from this code location. All accessible versions of method 'GetAttributeValue' take 2 arguments.
Say what?

[p.s. I posted this to Stack Overflow to in hopes of getting a bit of wisdom. Check there for possible answers.]

Getting all a hrefs from a webpage -- F# warm-ups

Been needing this for quite some time, and decided it was about time to tackle it as a way to flex my F# muscles a bit. I wanted to make this a command line utility, but haven't gotten around to it yet. If I do, I'll have it consume the html from STDIN, and spit the links to STDOUT. I want to do it that way to allow flexibility in how the pages are fetched.

Here is the code: