Cheryl's birthday: Difference between revisions
Content added Content deleted
(→{{header|JavaScript}}: Mapped comments to stages of problem. (from core of function-nest outwards)) |
(Realize in F#) |
||
Line 65: | Line 65: | ||
</lang> |
</lang> |
||
=={{header|F_Sharp|F#}}== |
|||
<lang fsharp> |
|||
//Find Cheryl's Birthday. Nigel Galloway: October 23rd., 2018 |
|||
type Month = |May |June |July |August |
|||
let fN n= n |> List.filter(fun (_,n)->(List.length n) < 2) |> List.unzip |
|||
let dates = [(May,15);(May,16);(May,19);(June,17);(June,18);(July,14);(July,16);(August,14);(August,15);(August,17)] |
|||
let _,n = dates |> List.groupBy(fun (_,n)-> n) |> fN |
|||
let i = n |> List.concat |> List.map(fun (n,_)->n) |> Set.ofList |
|||
let _,g = dates |> List.filter(fun (n,_)->not (Set.contains n i)) |> List.groupBy(fun (_,n)-> n)|> fN |
|||
let _,e = List.concat g |> List.groupBy(fun (n,_)->n) |> fN |
|||
printfn "%A" e |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
[[(July, 16)]] |
|||
</pre> |
|||
=={{header|Go}}== |
=={{header|Go}}== |
||
<lang go>package main |
<lang go>package main |