# HG changeset patch # User Adam Chlipala # Date 1348929251 14400 # Node ID e1e451cf85bbef02480b30ecf1f6f428a3d41b08 # Parent 923e097e9ba3846b93cdfc5cced612deb53092ba Simplify Reddit example more diff -r 923e097e9ba3 -r e1e451cf85bb tests/reddit.ur --- a/tests/reddit.ur Sat Sep 29 10:32:44 2012 -0400 +++ b/tests/reddit.ur Sat Sep 29 10:34:11 2012 -0400 @@ -1,24 +1,23 @@ fun main () = doc <- Feed.fetch "http://www.reddit.com/?limit=30"; - acc <- Feed.app' (Feed.tree (Feed.tagAOR "div" {DataUps = "data-ups", Class = "class"} {Style = "style"}) - (Feed.tagAOR "a" {Href = "href", Class = "class"} {Style = "style"})) - (fn (div, a) (count, list) => - return (if count >= 30 - || not (String.isPrefix {Full = div.Class, Prefix = " thing "}) - || Option.isSome (String.sindex {Haystack = div.Class, Needle = "promoted"}) - || div.Style = Some "display:none" - || a.Class <> "title " - || a.Style = Some "display:none" then - (count, list) - else - (count + 1, a.Href :: list))) - doc (0, []); + ls <- Feed.app' (Feed.tree (Feed.tagAOR "div" {DataUps = "data-ups", Class = "class"} {Style = "style"}) + (Feed.tagAOR "a" {Href = "href", Class = "class"} {Style = "style"})) + (fn (div, a) ls => + return (if not (String.isPrefix {Full = div.Class, Prefix = " thing "}) + || Option.isSome (String.sindex {Haystack = div.Class, Needle = "promoted"}) + || div.Style = Some "display:none" + || a.Class <> "title " + || a.Style = Some "display:none" then + ls + else + a.Href :: ls)) + doc []; return

Top 30 Reddit Links

    - {List.mapX (fn url =>
  1. {[url]}
  2. ) (List.rev acc.2)} + {List.mapX (fn url =>
  3. {[url]}
  4. ) (List.rev ls)}