Created
March 23, 2015 18:15
-
-
Save mastoj/35e442a1e5f34522baf7 to your computer and use it in GitHub Desktop.
F# Draw for meetup on meetups.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "./FSharp.Data.2.2.0/lib/net40/FSharp.Data.dll" | |
open FSharp.Data | |
open System | |
let rnd = Random() | |
type RSVP = JsonProvider<"https://api.meetup.com/2/rsvps?&sign=true&photo-host=public&event_id=220966177&page=200&key=KEY"> | |
let rsvps = RSVP.Load("https://api.meetup.com/2/rsvps?&sign=true&photo-host=public&event_id=220966177&page=200&key=KEY") | |
let mutable names = rsvps.Results | |
|> Array.filter (fun x -> (x.Response.Boolean |> Option.isSome) && (x.Response.Boolean |> Option.get)) | |
|> Array.map (fun x -> x.Member.Name) | |
|> Set.ofArray | |
let draw() = | |
let index = rnd.Next(names.Count) | |
let name = names |> Seq.skip index |> Seq.head | |
names <- (Set.remove name names) | |
name | |
draw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment